OpenCV 3.0 RGBD DepthCleaner

时间:2015-07-10 08:01:56

标签: c++ kinect opencv3.0 image-enhancement

使用DepthCleaner()函数和method = DEPTH_CLEANER_NIL来清理深度图像时遇到一些困难。此功能在OpenCV 3.0.0中发布。因此,找到此功能的有用文档还为时过早。如果你们中的任何人已经使用过这个功能,请告诉我用哪一组功能和代码来获得干净的深度图像。让我们说,我有一个来自Kinect1的深度图像命名为' Img1.png'。我正在声明图像并使用DepthCleaner,如下所示:

    char fileName[64];
    Mat depth_image = Mat(480, 640, CV_16UC1);
    Mat output = Mat(480, 640, CV_16U);

    snprintf(fileName, sizeof(fileName), "Depth_Image/Img1.png");
    depth_image = imread(fileName, -1);
    namedWindow("Input image",WINDOW_AUTOSIZE);
    imshow ("Input image",depth_image);

    DepthCleaner* depthc = new DepthCleaner(CV_16U, 3, DepthCleaner::DEPTH_CLEANER_NIL);

    depthc->operator ()(depth_image,output);
    namedWindow("depthCleaner",WINDOW_AUTOSIZE);
    imshow ("depthCleaner",output);

我正在使用C ++。但是,我没有正确的结果。我想我在代码中做错了。我也试过使用这组代码:

char fileName[64];
Mat depth_image = Mat(480, 640, CV_16UC1);
Mat output = Mat(480, 640, CV_16U);

float fx = 525.0f, // default
          fy = 525.0f,
          cx = 319.5f,
          cy = 239.5f;
    Mat cameraMatrix = Mat::eye(3,3,CV_32FC1);
    {
        cameraMatrix.at<float>(0,0) = fx;
        cameraMatrix.at<float>(1,1) = fy;
        cameraMatrix.at<float>(0,2) = cx;
        cameraMatrix.at<float>(1,2) = cy;
    }

snprintf(fileName, sizeof(fileName), "Depth_Image/Img1.png");
depth_image = imread(fileName, -1);
namedWindow("Input image",WINDOW_AUTOSIZE);
imshow ("Input image",depth_image);

Mat point3DMat;
depthTo3d(depth_image, cameraMatrix, point3DMat);

DepthCleaner* depthc = new DepthCleaner(CV_16U, 3, DepthCleaner::DEPTH_CLEANER_NIL);

depthc->operator ()(point3DMat,output);
namedWindow("depthCleaner",WINDOW_AUTOSIZE);
imshow ("depthCleaner",output);

但是,它也没有帮助我;在上面的代码中获取此行的编译器错误:

depthc->operator ()(point3DMat,output);). 

如果你能指出我正确的方向,那将是一个很大的帮助。

1 个答案:

答案 0 :(得分:0)

OpenCV Error: Assertion failed (depth.type() == (((6) & ((1 << 3) - 1)) + (((1)-1) << 3)) || depth.type() == (((5) & ((1 << 3) - 1)) + (((1)-1) << 3)) || depth.type() == (((2) & ((1 << 3) - 1)) + (((1)-1) << 3)) || depth.type() == (((3) & ((1 << 3) - 1)) + (((1)-1) << 3))) in depthTo3d, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/opencv_contrib/rgbd/src/depth_to_3d.cpp, line 232

terminate called after throwing an instance of 'cv::Exception'

   what():  /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/opencv_contrib/rgbd/src/depth_to_3d.cpp:232: error: (-215) depth.type() == (((6) & ((1 << 3) - 1)) + (((1)-1) << 3)) || depth.type() == (((5) & ((1 << 3) - 1)) + (((1)-1) << 3)) || depth.type() == (((2) & ((1 << 3) - 1)) + (((1)-1) << 3)) || depth.type() == (((3) & ((1 << 3) - 1)) + (((1)-1) << 3)) in function depthTo3d

我找到了有关的问题。什么?