-2

Hello everyone I used MOG2 function in C# there was no problem but when i try to do same thing on C++ there is a strange result. I believe it's about image's channels but i couldn't fix it . I need a hand thanks .

Mat mask;

Ptr<BackgroundSubtractor> sub ;
sub=createBackgroundSubtractorMOG2();
sub->apply(frame,mask);

This is a pretty simple define but the result is like this.

The result of MOG2

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87

1 Answers1

0

I solved this problem . The problem is defining the functions in the frame events.

So this Ptr<BackgroundSubtractor> sub ; part must defined in the header file and sub=createBackgroundSubtractorMOG2(); must be defined in the click even not the frame event.

I hope this helps if anyone needs the solution.