Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

How to remove detected shadows from foreground image in the light projector

$
0
0
Hi guys, i applying background subtraction MOG2 to detect hand in the beam light of projector. I already done this much, but i can remove shadow in foreground image. I already changes the parameter threshold to 127 to remove shadow and changes bShadowDetection in MOG2. Please help me to solve it, give me suggestion or anythings. This is sample picture that i take: ![image description](/upfiles/14413819121646062.png) int main(int argc, char *argv[]) { cv::Mat src, srcdown, bg, frMOG2, erframe, dlframe; namedWindow("windows 1", CV_WINDOW_AUTOSIZE); cv::VideoCapture cap(0); cv::BackgroundSubtractorMOG2 bgMOG2 = cv::BackgroundSubtractorMOG2(3000, 16.0, true); if (!cap.isOpened()){ printf("--(!)no frame from camera\n"); return -1; }; for (;;) { cap >> src; bgMOG2.operator()(src, frMOG2); cv::threshold(frMOG2, thrframe, 127, 255, cv::THRESH_BINARY); cv::dilate(thrframe, dlframe, cv::Mat()); cv::erode(dlframe, erframe, cv::Mat()); std::vector>contours; cv::findContours(erframe, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); for (int i = 0; i < contours.size(); i++) { if (contourArea(contours[i]) >= 500) { vector> tcontours; tcontours.push_back(contours[i]); cv::drawContours(srcdown, tcontours, -1, cv::Scalar(0, 0, 255), 2); } } cv::imshow("windows 1", srcdown); if (waitKey(30) >= 0) break; } return(0); }

Viewing all articles
Browse latest Browse all 41027

Trending Articles