How to get the depth value of the depth map saved in the folder

Read the clip depth map saved in the file and return 0 with getvalue() to read the distance:
if (zed.grab() == ERROR_CODE::SUCCESS) {
// A new image and depth is available if grab() returns SUCCESS
zed.retrieveImage(image, VIEW::LEFT); // Retrieve left image
zed.retrieveMeasure(depth_map, MEASURE::DEPTH); // Retrieve depth
depth_map.write(“D:/A deep learning/Intelligent sorting system/photo.png”);
sl::Mat image;
image.read(“D:/A deep learning/Intelligent sorting system/photo.png”);
float L;
image.getValue(760, 320, &L);
cout << “距离:” << L << endl;
}

Hello, I think you are mixing things between sl::Mat and cv::Mat. We provide a function slMatToCvMat that makes the conversion. then you can write myCvMat.write(...) and have your depth map written to the disk.

As you said, I convert the depth image format to CV and save it in disk, read the depth picture in disk, and using image.at() to get the depth value will return nan or -inf. How to solve this problem
if (zed.grab() == ERROR_CODE::SUCCESS) {
// A new image and depth is available if grab() returns SUCCESS
zed.retrieveImage(image, VIEW::LEFT); // Retrieve left image
zed.retrieveMeasure(depth_map, MEASURE::DEPTH); // Retrieve depth
cv::Mat depth_image_ocv = slMat2cvMat(depth_map);
cv::imwrite(“D:/A deep learning/Intelligent sorting system/signal-photo/” + to_string(1) + “depth” + “.tiff”, depth_image_ocv);
cv::Mat gg = cv::imread(“D:/A deep learning/Intelligent sorting system/signal-photo/” + to_string(1) + “depth” + “.tiff”, cv::IMREAD_UNCHANGED);
double bb = gg.at(760, 320);
cout << “bb为:” << bb << endl;

		}

Hi,
if you use the ZED SDK to save depth map as PNG it will be in 16bits (values in millimeters) you can’t try to read it as a float value.
If you want to read it with opencv you have to use the IMREAD_UNCHANGED option.

Hello, I used IMREAD_UNCHANGED in the program. But there will be a return value of nan or -inf, how to save the depth map with the ZED SDK, how to get its depth value? I want to know a way to save the depth map and read the depth map to get the depth value, can you teach me?

 // retrieve Depth:
  zed.retrieveMeasure(depth_map, MEASURE::DEPTH_U16_MM);

  sl::ushort1 zval;
  int x = 50;
  int y = 70;
//  read depth value from retrieved depth map
  depth_map.getValue(x, y, &zval);  
  std::cout << "Depth at " << x << ";" << y << " is " << zval << " Millimeters" << std::endl;
  

  string depth_name("depth_map.png");
// save the depth map (as 16bits PNG)
  depth_map.write(depth_name.c_str());
// read the depth map
  auto depth_ = cv::imread(depth_name, cv::IMREAD_UNCHANGED);
  // get the same pixel value
  zval = depth_.at<unsigned short>(y, x);
  std::cout << "Depth READ at " << x << ";" << y << " is " << zval << " Millimeters" << std::endl;