locked
About RGBQUAD type to OpenCV type RRS feed

  • Question

  • m_DrawDepth.DrawFrame( (BYTE*) m_rgbWk );

    Can I use m_rgbWk to get a lpimage data?

    I want to use OpenCV to process Kinect photo.

    Sorry,my english is poor! And, really thanks for all!!

    Monday, July 18, 2011 3:58 PM

Answers

  • I used cvSetData to get that data into an OpenCV image, and that works. You need to initialize the image header correctly, though.
    Monday, July 18, 2011 4:05 PM
  • The part to set the data is correct.

    For the depth image, since OpenCV cannot display an image which is of depth of 16, you'll need to convert it to a gray scale image. You can create do like:

    DepthImageGray = cvCreateImage(cvSize(640, 480), 8, 1);

    Then you can loop through the DepthImage and scale the data to 8 bits,

    or you can try cvConvertScale(DepthImage, DepthImageGray, 1/16.0, 0);

     

    For the color image, the format is BGRA from Kinect, so you have to create like ColorImage = cvCreateImage(cvSize(640, 480), 8, 4), then set the data.

     

    And remember to add cvWaitKey(10) at the end of the loop to let the display window refresh the data.

    • Proposed as answer by Xiyu Tuesday, July 19, 2011 1:41 PM
    • Marked as answer by Zhong-Ze Xie Tuesday, July 19, 2011 4:40 PM
    Tuesday, July 19, 2011 11:49 AM

All replies

  • I used cvSetData to get that data into an OpenCV image, and that works. You need to initialize the image header correctly, though.
    Monday, July 18, 2011 4:05 PM
  • Is like this?
    IplImage * kinectDepthImage ;
    DepthImage = cvCreateImage( cvSize(640,480), 16, 1);
    cvSetData(DepthImage, (BYTE*) m_rgbWk, kinectDepthImage->widthStep);
    cvShowImage("DepthImage",DepthImage);

    But my code has some errors.
    My OpenCV's Windows continued to wait state.
    Can you help me to see which side wrong?
    Really thank you very much!!



    Tuesday, July 19, 2011 8:16 AM
  • The part to set the data is correct.

    For the depth image, since OpenCV cannot display an image which is of depth of 16, you'll need to convert it to a gray scale image. You can create do like:

    DepthImageGray = cvCreateImage(cvSize(640, 480), 8, 1);

    Then you can loop through the DepthImage and scale the data to 8 bits,

    or you can try cvConvertScale(DepthImage, DepthImageGray, 1/16.0, 0);

     

    For the color image, the format is BGRA from Kinect, so you have to create like ColorImage = cvCreateImage(cvSize(640, 480), 8, 4), then set the data.

     

    And remember to add cvWaitKey(10) at the end of the loop to let the display window refresh the data.

    • Proposed as answer by Xiyu Tuesday, July 19, 2011 1:41 PM
    • Marked as answer by Zhong-Ze Xie Tuesday, July 19, 2011 4:40 PM
    Tuesday, July 19, 2011 11:49 AM
  • I use the code that write "cvCreateImage(cvSize(320, 240), 8, 4)".

    And it's success!!

    Thank you so mush!!

    Tuesday, July 19, 2011 12:56 PM
  • Why dont use Mat instead?, since youre aready working in c++ (I suppose). Imho, its much simplier to manipulate.
    Sunday, July 24, 2011 10:14 PM