a temporal removal of depth results in a ghostly image

        cv::addWeighted(depth_image_ocv, 1.0 - factor, last_image, factor, 0.0, result);

The above line only works correctly if depth_image_ocv and last_image matrices are both floating-point type (F32_C1). However, look here:

        last_image = result;

This doesn’t make a copy of result into last_image; it only copies a reference, so last_image and result are the same matrix from here on out.

That matrix is subsequently clobbered by converting it to byte type:

        result.convertTo(result, CV_8UC1);

So this doesn’t just affect result, but last_image too. Use clone or copyTo instead of operator= to get an actual copy of an OpenCV matrix.

(It’s bad API design that goes contrary to C++ idioms, but it probably won’t ever be fixed.)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top