Software Archive
Read-only legacy content
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
17065 Discussions

cannot access to camera streams by Open CV

tommaso_c_
Beginner
202 Views

Hi!

I'm tring to stream the R200 with Open CV, using this code

http://www.samontab.com/web/2016/04/interfacing-intel-realsense-f200-with-opencv/ 

I can build the code on Visual Studio but the windows (screens) of RGB, depth and IR are completely black and it's to work.

Ideas?

Thanks

0 Kudos
11 Replies
Johannes_V_
New Contributor I
202 Views

The code looks fine. I suppose its a realsense problem.

Do the samples from the SDK sample browser work?

tommaso_c_
Beginner
202 Views

yes they work good! It doesn't work just when I try to open from Open CV 

samontab
Valued Contributor II
202 Views

Try saving the images to disk with cv::imwrite, and check those images with a photo viewer. Maybe you have some issues with the highgui library (the library part dedicated to drawing on a window)

You can also check the contents of the data coming from the RealSense camera at the appropriate time.

Maybe there's a problem at the conversion of the formats. Read the comment in the page.

And, of course, you need light :)

tommaso_c_
Beginner
202 Views
I dont Think is the format. I am not able to Switch on the R200 from open CV.
samontab
Valued Contributor II
202 Views

Maybe you are not linking the correct libraries?

OpenCV really has nothing to do with the camera acquisition...

IEBEI
Novice
202 Views

Here is a simplified version of what works for me

 

PXCImage *color_image = sample->color;
PXCImage::ImageInfo color_info = color_image->QueryInfo();
PXCImage::ImageData color_data;
color_image->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB32, &color_data);
IplImage* colorimg = cvCreateImageHeader(cvSize(color_info.width, color_info.height), 8, 4);
cvSetData(colorimg, color_data.planes[0], color_info.width * 4 * sizeof(pxcBYTE));
Mat color_img_mat = cvarrToMat(colorimg);
color_image->ReleaseAccess(&color_data);

 

tommaso_c_
Beginner
202 Views
Changing the format, I got a better resolution for the color And depth stream but the IR still dont work. I will try your code! If it doesnt work I ll check the libraries again
tommaso_c_
Beginner
202 Views
Ok I finally Found the solution! Actually as You told it was a problem of formats! In The near future I m going to post the entire code. Thank You everyone
samontab
Valued Contributor II
202 Views

Remember to set the IR stream to 8 bits (PXCImage::PIXEL_FORMAT_Y8), in OpenCV you use CV_8UC1.

And also set the pitch/step in both directions of the conversion, like this in each case:

data.pitches[0] = cvImage.step

cv::Mat ocvImage = cv::Mat(cv::Size(width, height), type, data.planes[0], data.pitches[0]);

Johannes_V_
New Contributor I
202 Views

samontab wrote:

Remember to set the IR stream to 8 bits (PXCImage::PIXEL_FORMAT_Y8), in OpenCV you use CV_8UC1.

And also set the pitch/step in both directions of the conversion, like this in each case:

data.pitches[0] = cvImage.step

cv::Mat ocvImage = cv::Mat(cv::Size(width, height), type, data.planes[0], data.pitches[0]);

forgive me my questions, but where to set the stream to 8 bits?

as for now i only activate the stream by the sense manager over

PXCSenseManager *sm=PXCSenseManager::CreateInstance();

sm->EnableStream(PXCCapture::STREAM_TYPE_IR,320,240);

 

thank you samontab

 

samontab
Valued Contributor II
202 Views
Reply