|
|
|
@ -6,6 +6,15 @@ |
|
|
|
|
|
|
|
|
|
using namespace cv; |
|
|
|
|
|
|
|
|
|
void help() |
|
|
|
|
{ |
|
|
|
|
printf("\n" |
|
|
|
|
"This program demonstrated a simple method of connected components clean up of background subtraction\n" |
|
|
|
|
"When the program starts, it begins learning the background. You can toggle background learning on and off\n" |
|
|
|
|
"by hitting the space bar.\n" |
|
|
|
|
"Call\n" |
|
|
|
|
"./segment_objects [video file, else it reads camera 0]\n\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void refineSegments(const Mat& img, Mat& mask, Mat& dst) |
|
|
|
|
{ |
|
|
|
@ -52,6 +61,8 @@ int main(int argc, char** argv) |
|
|
|
|
VideoCapture cap; |
|
|
|
|
bool update_bg_model = true; |
|
|
|
|
|
|
|
|
|
help(); |
|
|
|
|
|
|
|
|
|
if( argc < 2 ) |
|
|
|
|
cap.open(0); |
|
|
|
|
else |
|
|
|
@ -59,7 +70,7 @@ int main(int argc, char** argv) |
|
|
|
|
|
|
|
|
|
if( !cap.isOpened() ) |
|
|
|
|
{ |
|
|
|
|
printf("can not open camera or video file\n"); |
|
|
|
|
printf("\nCan not open camera or video file\n"); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -93,7 +104,10 @@ int main(int argc, char** argv) |
|
|
|
|
if( keycode == 27 ) |
|
|
|
|
break; |
|
|
|
|
if( keycode == ' ' ) |
|
|
|
|
{ |
|
|
|
|
update_bg_model = !update_bg_model; |
|
|
|
|
printf("Learn background is in state = %d\n",update_bg_model); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|