Items with no label
3335 Discussions

Get image information to using it in OpenCV

idata
Employee
1,654 Views

Hi,

I'm trying to use the Intel's SDK and OpenCV at the same time, but I don't know how to get the information about the images in OpenCV (Mat type).

I saw this link: http://stackoverflow.com/questions/32609341/convert-a-pxcimage-into-an-opencv-mat c++ - Convert a PXCImage into an OpenCV Mat - Stack Overflow but it doesn't work for me (I'm using the last SDK versión and the SR300 sensor).

Can anyone help me?

Thanks in advance,

0 Kudos
13 Replies
MartyG
Honored Contributor III
550 Views

This link looks at conversions to .mat using the official SDK. Have you seen that one already?

https://software.intel.com/en-us/forums/realsense/topic/538066 Use openCV with Intel Realsense SDK

idata
Employee
550 Views

Thanks MartyG, but that question it isn't answered... At the end of the post they redirect him to the Stack Overflow post...

I saw that maybe with the library librealsense maybe I can do the conversion, but I don't know how to install it, if anyone can offer any help I'll be grateful!

PD: This are my data image format that the camera provides:

//PXCImage::PIXEL_FORMAT_YUY2; <-- RGB format

//PXCImage::PIXEL_FORMAT_Y16; <--- IR format

0 Kudos
MartyG
Honored Contributor III
550 Views

Yes, the majority of OpenCV use with RealSense that I have seen has been related to using it with Librealsense. I was going to mention Librealsense in my original message but then saw that you were using OpenCV with the official Intel SDK, so thought it might be irrelevant to your question.

Projects on GitHub do tend to have unfriendly documentation. I recently pointed someone to this setup guide, which was more friendlier presented than most:

http://wiki.ros.org/librealsense http://wiki.ros.org/librealsense

And here's the official Librealsense one.

https://github.com/IntelRealSense/librealsense/blob/master/doc/installation.md librealsense/installation.md at master · IntelRealSense/librealsense · GitHub

0 Kudos
idata
Employee
550 Views

Thanks, but I'm still don't understand exactly how to install it... I tried to do the installation pre-requisites as 'Enable Kernel Sources'. I haven't got the file and I don't know how to execute this one... Sorry if it's a silly question but I've never done this before...

0 Kudos
MartyG
Honored Contributor III
550 Views

It's not a silly question at all. I've never installed Linux on a hard drive myself. I did recently install it successfully on a USB storage stick though when I was setting up a boot drive for the RealSense Robotics Kit, and that went fine because it involved using an easy tool to set the drive up using the Ubunti Linux 'iso' file I'd downloaded. If you have a spare USB stick, I'll link you to the instructions.

https://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows How to create a bootable USB stick on Windows | Ubuntu

0 Kudos
idata
Employee
550 Views

So I need a Virtual Machine or something like that? The instructions of librealsense said concretely don't do that:

"**Note:** Due to the USB 3.0 translation layer between native hardware and virtual machine, the librealsense team does not recommend or support installation in a VM."

So I figured that there is another option to install it just in Windows, but maybe I'm wrong. As I told you, I didn't do that before.

0 Kudos
MartyG
Honored Contributor III
550 Views

If you want to keep Windows, I would recommend creating a USB boot drive of Linux, so that you can boot your PC normally to Windows when the USB stick is removed from your machine.

Your other option is the one that you were pursuing originally, to try to do the .mat format conversion using windows and the official RealSense SDK.

Using Librealsense on Windows seems like it may be more trouble than it's worth.

https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_windows.md librealsense/installation_windows.md at master · IntelRealSense/librealsense · GitHub

0 Kudos
idata
Employee
550 Views

Thanks for the help MartyG.

I'm trying to do the conversion with the official SDK, but it doesn't work well.

colorIm->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_YUY2, &frmData);

image_openCV = Mat(Size(640, 480), CV_8UC3, frmData.planes[0]);

I tried anorher formats but it's still not working

0 Kudos
MartyG
Honored Contributor III
550 Views

This suggestion from the ever-reliable Samontab looks interesting.

https://software.intel.com/en-us/forums/realsense/topic/624897 converting PXCImage to Mat format

0 Kudos
idata
Employee
550 Views

I checked on that code to write the lines I put... But it's not working and I don't know why.

0 Kudos
MartyG
Honored Contributor III
550 Views

I think you've researched this well enough that you will have seen any link that I find. Usually, someone on this forum just pops up with a solution that works.

0 Kudos
idata
Employee
550 Views

Hi MQMQ,

 

 

Are you getting data at all with the two main implementations that you have tried? The one from Stack Overflow and the one from Samontab (make sure to check the video too, there's some information in it that's not specified in the thread). I'm still not sure what data you're receiving (if any).

 

Also, check this link from Samontab as well http://www.samontab.com/web/2016/04/interfacing-intel-realsense-f200-with-opencv/ http://www.samontab.com/web/2016/04/interfacing-intel-realsense-f200-with-opencv/. I would suggest to try with a previous RealSense SDK distribution, here's the link to download the previous one http://registrationcenter-download.intel.com/akdlm/irc_nas/vcp/9078/intel_rs_sdk_offline_package_10.0.26.0396.exe https://communities.intel.comhttp://registrationcenter-download.intel.com/akdlm/irc_nas/vcp/9078/intel_rs_sdk_offline_package_10.0.26.0396.exe.

 

 

Regards,

 

-Pablo
0 Kudos
idata
Employee
550 Views

I don't know what I changed but suddendly works! Thanks for the help!

0 Kudos
Reply