cv::addWeighted(depth_image_ocv, 1.0 - factor, last_image, factor, 0.0, result);
The above line only works correctly if
last_image matrices are both floating-point type (
F32_C1). However, look here:
last_image = result;
This doesn’t make a copy of
last_image; it only copies a reference, so
result are the same matrix from here on out.
That matrix is subsequently clobbered by converting it to byte type:
So this doesn’t just affect
last_image too. Use
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.