1 | initial version |
You use BackgroundSubtractorMOG2 (OpenCV). It can detect shadow. Then you use threshold to remove shadow.
// Init background substractor
Ptr<backgroundsubtractor> bg_model = createBackgroundSubtractorMOG2().dynamicCast<backgroundsubtractor>();
bg_model->apply(img, mask);
threshold(mask, mask, 200, 255, THRESH_BINARY);
2 | No.2 Revision |
You use Apply BackgroundSubtractorMOG2 (OpenCV). to solve it. It can detect shadow. Then you use threshold to remove shadow.
// Init background substractor
Ptr<backgroundsubtractor> bg_model = createBackgroundSubtractorMOG2().dynamicCast<backgroundsubtractor>();
bg_model->apply(img, mask);
threshold(mask, mask, 200, 255, THRESH_BINARY);