简体   繁体   中英

opencv realsense 16 bit depth image

I have a realsense camera and I'm trying to read a 16 bit depth image. I have a problem - when I create direct opencv mat with 16 bit values I see only black image. When I convert 16 bit image to 8 bit with 255/1000 scale, I get normal image, but I don't want to lose that information.

depthImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_DEPTH, &depthImgData);

pxcBYTE* cpixels = depthImgData.planes[0];

Mat r_depth(frameSize, CV_16UC1, cpixels);

Here's my code, where I convert image.

Could you please tell me what is the reason of such behaviour and how to get 16 bit image?

which RealSense device do you use? R200, LR200, SR300 or D410?

Suggest to use the librealsense library/APIs which is maintained on GitHub. Configure the depth format to RS2_FORMAT_Z16. And, I use below code to get 16bit depth data.

auto frame = queue.wait_for_frame();

Mat depth16(Size(640, 480), CV_16U, (void*)frame.get_data(), Mat::AUTO_STEP);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM