opencv - Remove Shadow from Extracted Foreground -
i'm newbie opencv + c++ + visual studio 2012. , need learn them. here's code background substraction/foreground extraction, , need remove shadow foreground, , include them background model.
include opencv2/opencv.hpp include iostream include vector int main(int argc, char *argv[]) { cv::mat frame; cv::mat back; cv::mat fore; cv::videocapture cap(0); cv::backgroundsubtractormog2 bg; bg.nmixtures = 3; bg.bshadowdetection = true; bg.nshadowdetection = 0; //resolved! bg.ftau = 0.5; //resolved! std::vector<std::vector<cv::point> > contours; cv::namedwindow("frame"); cv::namedwindow("background"); for(;;) { cap >> frame; bg.operator ()(frame,fore); bg.getbackgroundimage(back); cv::erode(fore,fore,cv::mat()); cv::dilate(fore,fore,cv::mat()); cv::findcontours(fore,contours,cv_retr_external,cv_chain_approx_none); cv::drawcontours(frame,contours,-1,cv::scalar(0,0,255),2); cv::imshow("frame",frame); cv::imshow("background",back); if(cv::waitkey(30) >= 0) break; } return 0; } i've changed bshadowdetection = true or false nothing happened. should do? thanks. :)
nb: sorry bad english. :d
================
resolved!
if want remove shadow foreground, add code below after bg.bshadowdetection = true:
bg.nshadowdetection = 0 , bg.ftau = 0.5, see code above! :d
if shadow still detected, can adjust value.
bg.ftau = 0.5 means if pixel more 2 times darker not shadow.
bg.nshadowdetection default value 127. if wanna remove shadow set foreground min.threshold 127. or can set bg.nshadowdetection 0 me.
cheers! :d
resolved!
if want remove shadow foreground, add code below after bg.bshadowdetection = true:
bg.nshadowdetection = 0 , bg.ftau = 0.5, see code above in question! :d
if shadow still detected, can adjust value.
bg.ftau = 0.5 means if pixel more 2 times darker not shadow.
bg.nshadowdetection default value 127. if wanna remove shadow set foreground min.threshold 127. or can set bg.nshadowdetection 0 me.
cheers! :d
Comments
Post a Comment