Items with no label
3338 討論

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

mgum1
初學者
2,229 檢視

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 積分
1 解決方案
MartyG
榮譽貢獻者 III
1,342 檢視

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

在原始文章中檢視解決方案

4 回應
MartyG
榮譽貢獻者 III
1,343 檢視

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

mgum1
初學者
1,342 檢視

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?

MartyG
榮譽貢獻者 III
1,342 檢視

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.

mgum1
初學者
1,343 檢視

Thanks alot!

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

回覆