Software Archive
Read-only legacy content
17061 Discussions

R200 Processing depth images, OpenCV

Thomas_5207
New Contributor I
428 Views

Hi there,

I have decided I want to do some smoothing of the depth images before I construct a point cloud from the data. I might be trying different algorithms, so working in the PXC format and writing filters myself might not be the best use of time when OpenCV can do that for me. So I try and make an OpenCV Mat.

From my understanding. When I set up the depth stream it is 16-bit unsigned. I then try to set up an OpenCV Mat as so (I have looked around at other forum posts prior to this).

cv::Mat matDepth(cv::Size(dHeight, dWidth), CV_16U, ddata.planes[0], ddata.pitches[0]);

It doesn't complain but when I use imshow() I'm left with a black image with just a bar across the image which does not correspond to the image. I tried converting the Mat to 8 bit but still issues there. Am I setting up the matrix wrongly? If I am right I want to smooth on the 16 bit image anyway so I am not losing detail.

Thanks.

 

0 Kudos
1 Solution
samontab
Valued Contributor II
428 Views

This is for the F200, but the OpenCV conversion should be similar:

https://www.youtube.com/watch?v=wIkIdjN6Oyw

View solution in original post

0 Kudos
2 Replies
samontab
Valued Contributor II
429 Views

This is for the F200, but the OpenCV conversion should be similar:

https://www.youtube.com/watch?v=wIkIdjN6Oyw

0 Kudos
Thomas_5207
New Contributor I
428 Views

samontab wrote:

This is for the F200, but the OpenCV conversion should be similar:

https://www.youtube.com/watch?v=wIkIdjN6Oyw

Thank you, I actually had already looked at that video prior. I realised just a few minutes ago it was because I had my size defined as cv::Size(height, width), instead of cv::Size(width, height). OpenCVs [row, col] format or [col, row] format tricks me up yet again! It works now.

I am just trying to work on how to make the conversion back to PXCImage.

0 Kudos
Reply