First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered Mar 14 '13

berak gravatar image
  1. cv::Mat raw(640, 480, CV_8UC1, frame->buffer.data()); i'm unshure about bayer images, but CV_8UC1 would mean, that your input image has 1 channel only(gray). try CV_8UC3 (3 uchar channels) i think, you truncated it
  2. it's rows, cols there, not width height. (yes, happy here to confuse it evey 2nd time, too)
    so : cv::Mat raw(480,640, CV_8UC3, frame->buffer.data());
  3. BONUS: NO, that constructor only copies the pointer and sets up rows/cols and such, no deep copy, so careful with that!!. but you're safe here, since the following cvtColor() WILL alloc new space for the result image
click to hide/show revision 2
No.2 Revision
  1. cv::Mat raw(640, 480, CV_8UC1, frame->buffer.data()); i'm unshure about bayer images, but CV_8UC1 would mean, that your input image has 1 channel only(gray). try CV_8UC3 (3 uchar channels) i think, you truncated it
  2. it's rows, cols there, not width height. (yes, happy here to confuse it evey 2nd time, too)
    so : cv::Mat raw(480,640, CV_8UC3, frame->buffer.data());
  3. BONUS: NO, that constructor only copies the pointer and sets up rows/cols and such, no deep copy, so careful with that!!. but you're safe here, since the following cvtColor() WILL alloc new space for the result imageimage. in other situations, when you're using such a constructor with a 'borrowed' pointer you'd want to clone() it