Items with no label
공지
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
3338 토론

Retrieving depth information from ZR300

nnain1
새로운 기여자 I
2,500 조회수

I used ZR300 for depth measurement.

I can't retrieve correct Depth matrix from the camera.

What I did was as follow and retrieve the depth matrix from the stream.

const uint16_t * depth_image = (const uint16_t *)dev->get_frame_data(rs::stream::depth);

float scale = dev->get_depth_scale();

float data[HEIGHT*WIDTH];

for(int dy=0; dy

{

for(int dx=0; dx

{

uint16_t depth_value = depth_image[dy * depth_intrin.width + dx];

if(depth_value == 0)

continue;

else

data[dy*dx] = (float)depth_value * scale;

}

}

Mat depthimage(HEIGHT, WIDTH, CV_32FC1, &data);

Mat colorimage(HEIGHT, WIDTH, CV_8UC3, (uchar*)dev->get_frame_data(rs::stream::color));

imshow("dst", depthimage);

waitKey(1);

dst.release();

I have another depth follow sample from realsense, that has correct object.

The code is

glPixelTransferf(GL_RED_SCALE, 0xFFFF * dev->get_depth_scale() / 2.8f);

glDrawPixels(WIDTH, HEIGHT, GL_RED, GL_UNSIGNED_SHORT, dev->get_frame_data(rs::stream::depth));

glPixelTransferf(GL_RED_SCALE, 1.0f);

Red color image is the one following sample program and the image "dst" is the one using the first code.

Another one is the color image, we can see there is a cabinet.

Why I don't have correct depth image, what is wrong with my code?

0 포인트
6 응답
idata
직원
1,174 조회수

Hello inmn,

 

Sorry for the late response. While we don't usually debug customer's code, I am trying to reproduce your issue but have encountered some obstacles. Please stay tuned...

 

 

Regards,

 

Jesus

 

Intel Customer Support

 

0 포인트
idata
직원
1,174 조회수

Hello inmn,

 

 

It seems that you have to do a conversion of the pixel formats from RealSense to OpenCV. See the file https://github.com/IntelRealSense/realsense_sdk_zr300/blob/master/sdk/src/core/image/image_conversion_util.cpp for an example of how to do this.

 

 

Let us know if this helps.

 

 

Regards,

 

Jesus

 

Intel Customer Support
0 포인트
nnain1
새로운 기여자 I
1,174 조회수

Hello Jesus,

Many thanks for the reply.

I have the same issue for color image. I tried to grab into Opencv's Mat image.

What I did was

dev.enable_stream(rs::stream::color, 640, 480, rs::format::bgr8, 60); cv::Mat colorImg(480, 640, CV_8UC3, (unsigned char *)dev.get_frame_data(rs::stream::color)); imshow("colorImg",colorImg); cv::waitKey(1);

Then my color image became. Is that the same issue as I need to pixel format conversion?

0 포인트
nnain1
새로운 기여자 I
1,174 조회수

Can I have any sample of usage?

0 포인트
nnain1
새로운 기여자 I
1,174 조회수

Thanks now ok.

I take the image as rgb8

dev.enable_stream(rs::stream::color, 640, 480, rs::format::rgb8, 60);

Then convert to RGBtoBGR

cv::cvtColor(srcMat, grayMat, CV_RGB2BGR);

It works.

0 포인트
nnain1
새로운 기여자 I
1,174 조회수

Hello Jesus,

Many thanks for the reply.

I have the same issue for color image. I tried to grab into Opencv's Mat image.

What I did was

dev.enable_stream(rs::stream::color, 640, 480, rs::format::bgr8, 60); cv::Mat colorImg(480, 640, CV_8UC3, (unsigned char *)dev.get_frame_data(rs::stream::color)); imshow("colorImg",colorImg); cv::waitKey(1);

Then my color image became. Is that the same issue as I need to pixel format conversion?

0 포인트
응답