0

I have ZR300 realsense camera and trying to have color image. What I did are

dev.enable_stream(rs::stream::color, 640, 480, rs::format::bgr8, 60);
cv::Mat colorImg(480, 640, CV_8UC3, (unsigned char *)dev.get_frame_data(rs::stream::color));
imshow("colorImg",colorImg);
cv::waitKey(1);

But I have color image as

enter image description here

Why I don't have correct image?

batuman
  • 7,066
  • 26
  • 107
  • 229
  • Check the size of the frame you receive matches the size you expect. Try putting a red, transparent sweet wrapper (or filter) over the lens and see if you can identify the red pixels which will be higher than the green or blue, then use a green filter, then blue. Is it possible the camera produces planar data ratherthan packed, i.e. RRRGGGBBB rather than RGB RGB RGB? – Mark Setchell Jan 31 '18 at 08:04
  • Since I have set frame size (640 x 480) in enable_stream(), frame size shouldn't be issue. – batuman Jan 31 '18 at 09:37
  • Nothing *”should be a problem”* but there clearly is a problem :-) – Mark Setchell Jan 31 '18 at 09:56
  • Try taking the first 640x480 bytes as a greyscale image. Then try taking bytes 0, 3, 6 as a greyscale image. Then bytes 0, 4, 8... – Mark Setchell Jan 31 '18 at 10:16
  • It is ok now. I take the image is rgb8 in dev.enable_stream(rs::stream::color, 640, 480, rs::format::rgb8, 60); then converto RGBtoBGR as cv::cvtColor(srcMat, grayMat, CV_RGB2BGR);. Then OK. – batuman Feb 01 '18 at 02:34

0 Answers0