mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
revamped
This commit is contained in:
parent
a161598c76
commit
85c27e5a69
@ -7,6 +7,20 @@
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
void help()
|
||||
{
|
||||
cout << "\nThis program demonstrates the famous watershed segmentation algorithm in OpenCV: watershed()\n"
|
||||
"Usage:\n"
|
||||
"./watershed [image_name -- default is fruits.jpg]\n" << endl;
|
||||
|
||||
|
||||
cout << "Hot keys: \n"
|
||||
"\tESC - quit the program\n"
|
||||
"\tr - restore the original image\n"
|
||||
"\tw or SPACE - run watershed segmentation algorithm\n"
|
||||
"\t\t(before running it, *roughly* mark the areas to segment on the image)\n"
|
||||
"\t (before that, roughly outline several markers on the image)\n";
|
||||
}
|
||||
Mat markerMask, img;
|
||||
Point prevPt(-1, -1);
|
||||
|
||||
@ -30,7 +44,6 @@ void onMouse( int event, int x, int y, int flags, void* )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
char* filename = argc >= 2 ? argv[1] : (char*)"fruits.jpg";
|
||||
@ -38,17 +51,10 @@ int main( int argc, char** argv )
|
||||
|
||||
if( img0.empty() )
|
||||
{
|
||||
cout << "Usage: watershed <image_name>\n";
|
||||
cout << "Couldn'g open image " << filename << ". Usage: watershed <image_name>\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout << "Hot keys: \n"
|
||||
"\tESC - quit the program\n"
|
||||
"\tr - restore the original image\n"
|
||||
"\tw or SPACE - run watershed algorithm\n"
|
||||
"\t\t(before running it, roughly mark the areas on the image)\n"
|
||||
"\t (before that, roughly outline several markers on the image)\n";
|
||||
|
||||
help();
|
||||
namedWindow( "image", 1 );
|
||||
|
||||
img0.copyTo(img);
|
||||
|
Loading…
Reference in New Issue
Block a user