I have a camera rigidly attached to a tool. A portion of this tool is included in the field of view of the camera itself. The tool is always on the move. My goal is to retrieve from each image acquired by the camera the segmentation of the tool. I want then to apply the BackgroundSubtractorMOG2 in order to highlight only the portion of the image that doesn't change over time (the tool).
The code of the function i'm using is the following (c++ code).
Mat Background_removal(Mat img)
{
Mat img_fore;
Mat background;
Mat foreground;
const int nmixtures=10;
const bool shadow=false;
const int history =1000;
BackgroundSubtractorMOG2 mog(history,nmixtures,shadow);
mog.operator()(img,foreground);
return foreground;
}
My issue is that this function returns an image completely white. What am I doing wrong?