Ask Your Question
0

I have some problem with GMM

asked 2016-12-03 04:45:06 -0600

Ruby_Sheng gravatar image

updated 2016-12-03 05:47:04 -0600

this is my code

#include <opencv2\opencv.hpp>
using namespace cv;
int main(){
VideoCapture video(0);
Mat frame, mask, thresholdImage, output;
Ptr<BackgroundSubtractorMOG2> subtractor = cv::createBackgroundSubtractorMOG2(20, 16, true);
namedWindow("background");
while (true){
    video >> frame;
    subtractor(frame, mask, 0.001);
    imshow("background", mask);
    char c = (char)waitKey(20);
    if (c == 27)
        break;
}
return 0;
}

There's something wrong with "substractor". I really don't know what's going on with the "subtractor"...

thanks

p.s. I am using opencv310, maybe sth about the version?

edit retag flag offensive close merge delete

Comments

would you be so nice, and remove the screenshot, and give us a text version of your code, and the exact error , please ?

berak gravatar imageberak ( 2016-12-03 04:50:06 -0600 )edit
1

hello, I've changed it. And there are 2 errors.

  1. C2064
  2. IntelliSense: Calls a class type object without the appropriate operator () or converts the function to a type that points to a function
Ruby_Sheng gravatar imageRuby_Sheng ( 2016-12-03 05:47:24 -0600 )edit

thanks a lot ! (now it can be properly indexed, ppl can cp/paste your code /errors and so on ..

berak gravatar imageberak ( 2016-12-03 05:53:35 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-03 05:59:38 -0600

berak gravatar image

updated 2016-12-03 06:00:27 -0600

it's some version problem, while in opencv3, you have to use:

Ptr<BackgroundSubtractorMOG2> subtractor = cv::createBackgroundSubtractorMOG2(20, 16, true);
subtractor->apply(frame, mask, 0.001);

(call an "apply" function on a pointer)

while with opencv2.4, it would have been:

BackgroundSubtractorMOG2 subtractor(20, 16, true);
subtractor(frame, mask, 0.001);

(call a () operator on a stack object)

please make sure to use appropriate docs and samples for your version.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-12-03 04:45:06 -0600

Seen: 143 times

Last updated: Dec 03 '16