I can use updateHistoryImage with a stereo image?

asked 2019-01-21 05:39:12 -0500

ObiWan12339 gravatar image

updated 2019-01-21 05:42:50 -0500

I am working with a 8UC3 stereo image, but the function updateHistoryImage works only with 8UC1 and 32UF1...

The error: OpenCV(4.0.1-dev) Error: Assertion failed (_silhouette.type() == CV_8UC1 && _mhi.type() == CV_32FC1) in cv::motempl::updateMotionHistory, file C:\opencv4\opencv_contrib-master\modules\optflow\src\motempl.cpp, line 76

I tried to convert the stereo image to 1 level but nothing... How can I make it work?

frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camera
    frame depth = data.get_depth_frame().apply_filter(color_map);
    const int w = depth.as<video_frame>().get_width();
    const int h = depth.as<video_frame>().get_height();
    Mat image(Size(w, h), CV_8UC3, (void*)depth.get_data(), Mat::AUTO_STEP);
    Mat image2(Size(w, h), CV_8UC3, (void*)depth.get_data(), Mat::AUTO_STEP);
    absdiff(image, image2, differenceImage);
    threshold(differenceImage, silhouette, 127, 255, THRESH_BINARY);

    mhi = Mat::zeros(image.size(), CV_32FC1);
    updateMotionHistory(silhouette, mhi, timestamp, MHI_DURATION);
edit retag flag offensive close merge delete


imho, you need to explain, what is in your stereo images, and how that relates to motion

berak gravatar imageberak ( 2019-01-21 06:08:58 -0500 )edit

It's referred to hand gestures..

ObiWan12339 gravatar imageObiWan12339 ( 2019-01-21 08:23:44 -0500 )edit

i still have no idea, what you're trying to achieve here, but please take another look at the sample -- creating a new mhi Mat each time is for sure wrong, you have to do that only once (and keep it around for updating

also, while that example has an absdiff, too, those frames are consecutive in time, there, not "spatially different", but at the same time.

idk., if your setup makes any sense, here.

berak gravatar imageberak ( 2019-01-21 08:53:27 -0500 )edit