Spatial and temporal averaging on depth image

Viewed 132

I would like to do Spatial and temporal on a depth image. The spatial average can be achieved by convolution (cv::filter2D), for temporal average you would need to accumulate() N images, and divide by N but I don't know how to use OpenCV to do that.

I'm acquiring depth image from a camera.

What I tried for the spatial filter is

cv::Mat dst;
int kernel_size = 2;
cv::Mat kernel = cv::Mat::ones(kernel_size, kernel_size, CV_32F) / (float)(kernel_size * kernel_size);

Then apply filter:

filter2D(depth_image_ocv, dst, -1, kernel, cv::Point(-1, -1), 0, cv::BORDER_DEFAULT);
cv::imshow("Filtered Depth", dst);
cv::imshow("Depth", depth_image_ocv);

However, the result is horrible, see below:

enter image description here

0 Answers
Related