Items with no label
3335 Discussions

Question) How can i convert rs2::frameset -> iplimage ?

mgum1
Beginner
1,453 Views

Hello, i'm sorry for serial question, but i can't find place where can i ask some problem directly about RealSense SDK.

Question)

I referenced below sentence in visual studio.

static rs2::frameset current_frameset;

than, i want convert this "current_frameset" variable to iplimage for using openCV.

how can i change this one? (exactly, rs2::video_frame -> CvCapture * )

i tried this one,

cv::Mat img(480,640, CV_8UC3, (uchar3 *)frame->get_frame_data(rs2::stream::current_frameset));

but it came up only error that i can't understand.

so, i wish sentence like " frame = Cv ... " (frame is iplimage variable)

thank for help!

0 Kudos
1 Solution
MartyG
Honored Contributor III
566 Views

The article below discusses doing the conversion with the older R200 and SR300 camera models in Librealsense 1, and may give you some hints that you can adapt for RS2.

For example, one suggestion for an approach is:

IplImage *I = cvCreateImageHeader(cvSize(dc_frame->size[0],dc_frame->size[1]),IPL_DEPTH_8U,1);

cvSetData(I,dc_frame->image,dc_frame->size[0]);

http://answers.opencv.org/question/128296/realsense-r200-difference-between-saved-images-and-live-stream/ realsense R200, difference between saved images and live stream? - OpenCV Q&A Forum

View solution in original post

0 Kudos
4 Replies
MartyG
Honored Contributor III
567 Views

The article below discusses doing the conversion with the older R200 and SR300 camera models in Librealsense 1, and may give you some hints that you can adapt for RS2.

For example, one suggestion for an approach is:

IplImage *I = cvCreateImageHeader(cvSize(dc_frame->size[0],dc_frame->size[1]),IPL_DEPTH_8U,1);

cvSetData(I,dc_frame->image,dc_frame->size[0]);

http://answers.opencv.org/question/128296/realsense-r200-difference-between-saved-images-and-live-stream/ realsense R200, difference between saved images and live stream? - OpenCV Q&A Forum

0 Kudos
mgum1
Beginner
566 Views

Thank you.

i've another question.

is that also work in SDK 2.0 as rs2::video_frame to CvCapture?

simply, i want convert "rs2::video_frame" variable to "CvCapture* "

example) frame = cvQueryFrame(color); // it didn't work. how can i fix it?

0 Kudos
MartyG
Honored Contributor III
566 Views

Bear in mind that I am adapting an instruction to convert cv::VideoCapture to CvCapture, so this may be wrong. You could try:

rs2::video_frame capture1(fileName);

if (!capture.isOpened())

{

// failed, print error message

}

****************

I believe that in the above script, capture1 is a custom variable name chosen by its author and you could use your own name.

0 Kudos
mgum1
Beginner
567 Views

Thanks alot!

i'll try to modify this one and above instruction.

0 Kudos
Reply