revamped
This commit is contained in:
parent
a161598c76
commit
85c27e5a69
@ -7,6 +7,20 @@
|
|||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
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;
|
Mat markerMask, img;
|
||||||
Point prevPt(-1, -1);
|
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 )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
char* filename = argc >= 2 ? argv[1] : (char*)"fruits.jpg";
|
char* filename = argc >= 2 ? argv[1] : (char*)"fruits.jpg";
|
||||||
@ -38,17 +51,10 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
if( img0.empty() )
|
if( img0.empty() )
|
||||||
{
|
{
|
||||||
cout << "Usage: watershed <image_name>\n";
|
cout << "Couldn'g open image " << filename << ". Usage: watershed <image_name>\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
help();
|
||||||
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";
|
|
||||||
|
|
||||||
namedWindow( "image", 1 );
|
namedWindow( "image", 1 );
|
||||||
|
|
||||||
img0.copyTo(img);
|
img0.copyTo(img);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user