I am completely new to OpenCV and I'm trying to initialize two cv::Mat
matrices from two different type of data. One is simple one-channel array of uint16_t
gray values, second should hold RGB values from array of uint8_t
values holding RGB 565 (each pixel occupy 2 uint8_t
, so it's basically array of uint16_t
). I'd like to have one single-chanell matrix, and one 3-chanell matrix (which will probably be converted to one chanelly sometime... but I'm not quite there yet.
function(uint16_t *oneChanell, int oneChanellWidth, int oneChanellHeight, uint8_t *rgb, int rgbWidth, int rgbHeight){
...
cv::Mat M1 = cv::Mat(oneChanellHeight, oneChanellWidth, CV_16UC1, oneChanell);
cv::Mat M2 = cv::Mat(rgbHeight, rgbWidth, CV_16UC3, rgb);
...
}
Now, I am aware that the second initialization is wrong. So that is one part of my question, how to best convert array of rgb565values to cv::Mat
.
In my understanding however, the first initialization should work. When tested with cv::imwrite()
, the first yields just blank white picture of correct size, the second three partially overlapping silhouettes of the same (correct) picture, but not in RGB. Any advice would be appreciated.