Reputation: 167
I am taking in RGB data from my Kinect and trying to put it into an OpenCV matrix. The data is held in "src":
Mat matrixImageRGBA(w, h, CV_8UC4);
memcpy(matrixImageRGBA.data, src, sizeof(byte) * w * h * 4);
However, when I use "imshow" to see the image, it is tiled four time horizontally. I am using the following command:
imshow("Window", matrixImageRGBA);
waitKey(500);
Does anyone have any idea of what the problem may be here? It's driving me nuts.
Thanks!
Upvotes: 0
Views: 205
Reputation: 10886
You have w
and h
backwards. According to the docs the constructor takes the height
as the first argument:
Mat (int rows, int cols, int type)
Also, I would recommend using this constructor:
Mat(int rows, int cols, int type, void *data, size_t step=AUTO_STEP)
instead of copying to the data
field (since you are using no padding at the end of each row use the default AUTO_STEP
for step
).
Upvotes: 3