Opencv保存读取float类型深度图
保存
MyData.h_people_depth = cv::cuda::GpuMat(PROJECTION_HEI, PROJECTION_WID, CV_32FC1, cv::Scalar(0, 0, 0));
cv::Mat people_depth;
MyData.h_people_depth.download(people_depth);
cv::Mat people_depth_save(people_depth.rows, people_depth.cols, CV_8UC4, people_depth.data);
cv::normalize(people_depth, people_depth, 0, 1.0, cv::NORM_MINMAX);
cv::imshow("people_depth", people_depth);
cv::imshow("people_depth_save", people_depth_save);
cv::imwrite("../res/people_depth.png", people_depth_save);
读取
Mat depth = imread("../res/people_depth.png", IMREAD_UNCHANGED);
for(int i=0;i<depth.rows;i++){
for(int j=0;j<depth.cols;j++){
if(depth.at<float>(i,j) > 0)
printf("%f \n",depth.at<float>(i,j));
Point2d p1 = pixel2cam(Point2d(i,j),K1);
}
}
Fighting~