Sl::zed::Mat depthmap= zed->normalizeMeasure(sl::zed::MEASURE::DEPTH) ![]() get depth image and copy to opencv data As you can see, we can directly copy the buffer of the zed::Mat into the buffer of cv::Mat : Then, we just retrieve the color image and depth map and copy the buffers in our two OpenCV matrix. Here, we decide to use the FILL sensing mode. STANDARD mode is suited for applications such as collision avoidance and navigation, while FILL mode is targeted at augmented reality and computational imaging where a fully dense depth map is needed. There are two sensing modes available: STANDARD and FILL. To grab an image and depth, we first need to select a sensing mode. The simplest way is to create a ‘while’ loop and handle all the events with OpenCV. Capture and display color image and depth Let’s choose a 720 x 404 size and create the OpenCV windows.ģ. On the display side, we will create smaller windows to make sure they fit on our screen. Then, we initialize the ZED with its depth computation mode (QUALITY, MEDIUM, PERFORMANCE or NONE), device number and verbosity. Please note that there are four resolutions and framerate available, as detailed in our Developer’s guide. Each image will have a 1920×1080 resolution. Let’s create our ZED Camera object and select its resolution. Then create your standard main function:ĭo not forget to add the links to OpenCV (headers and libs) and ZED SDK (headers and libs). Let’s break down the code piece by piece.Ĭreate a main C++ file and include standard headers for I/O, OpenCV (core, highgui and imgproc), and ZED (Camera.hpp). Memcpy(depth.data,depthmap.data,width*height*4*sizeof(uchar)) Ĭv::resize(image, imageDisplay, displaySize) Ĭv::resize(depth, depthDisplay, displaySize) Sl::zed::Mat depthmap = zed->normalizeMeasure(sl::zed::MEASURE::DEPTH) ![]() Memcpy(image.data,left.data,width*height*4*sizeof(uchar)) Sl::zed::Mat left = zed->retrieveImage(sl::zed::SIDE::LEFT) If (!zed->grab(sl::zed::SENSING_MODE::FILL)) Grab frame and compute depth in FILL sensing mode Sl::zed::ERRCODE err = zed->init(sl::zed::MODE::PERFORMANCE, 0, true) Ĭv::namedWindow("Image", cv::WINDOW_AUTOSIZE) Ĭv::namedWindow("Depth", cv::WINDOW_AUTOSIZE) Ĭv::Mat imageDisplay(displaySize, CV_8UC4) Ĭv::Mat depthDisplay(displaySize, CV_8UC4) Initialize ZED color stream in HD and depth in Performance mode The code of this tutorial is a simplified version of the sample “ZED with OpenCV” available on our GitHub page.īefore starting this tutorial, make sure you have OpenCV installed and read our tutorial “How to Build an App with the ZED SDK” which will help you set up your coding environment and build applications with the ZED SDK. In this tutorial, you will learn how to use the ZED SDK to capture and display color and depth images from your ZED. Important: This article is outdated (ZED SDK 1.2).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |