Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
14 Views

cannot access to camera streams by Open CV

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
Highlighted
New Contributor I
14 Views

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

Do the samples from the SDK sample browser work?

0 Kudos
Highlighted
Beginner
14 Views

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

0 Kudos
Highlighted
Valued Contributor II
14 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 :)

0 Kudos
Highlighted
Beginner
14 Views

I dont Think is the format. I am not able to Switch on the R200 from open CV.
0 Kudos
Highlighted
Valued Contributor II
14 Views

Maybe you are not linking the correct libraries?

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

0 Kudos
Highlighted
Novice
14 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);

 

0 Kudos
Highlighted
Beginner
14 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
0 Kudos
Highlighted
Beginner
14 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
0 Kudos
Highlighted
Valued Contributor II
14 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]);

0 Kudos
Highlighted
New Contributor I
14 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

 

0 Kudos
Highlighted
Valued Contributor II
14 Views

0 Kudos