OpenCV 3.0 RGBD depth cleaner

asked 2015-07-09 13:45:42 -0600

TariqulIslamRostock gravatar image

updated 2015-07-13 07:26:11 -0600

Hello everyone,

I am having some difficulties to use the function DepthCleaner () with method = DEPTH_CLEANER_NIL to clean a depth image. This function is released in OpenCV 3.0.0. So, it's too early to find useful documentation for this function. If anyone of you have already used this function, could you please inform me which set of functions and codes I use to get a clean depth image. Let's say, I have a depth image from Kinect1 names as 'Img1.png'. I am declaring the image and using DepthCleaner as follows:

    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);

I am using C++. But, I am not having correct result. I guess I am doing something wrong in the codes. I have also tried using this set of codes:

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);

But, it did not help me either; getting compiler error for this line in the above piece of code:

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

It would be a great help if you can point me to the right direction.

edit retag flag offensive close merge delete

Comments

what is the type when you use point3DMat.depth() . I use the datatype CV_32FC1 instead of CV_16UC1 without errors. If you get a number I can check for you

martijnvwezel gravatar imagemartijnvwezel ( 2015-09-03 09:05:54 -0600 )edit