I'm working on an object detection project. I use OpenCV 4.0.0 and codeblocks 16.01 on Ubuntu 18.04.1. I'm testing the watershed distance transform technique using the code in this tutorial:
I just modified the path to my test image, so:
// Load the image
CommandLineParser parser( argc, argv, "{@input | ../../testes/img1.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ) );
if( src.empty() )
{
cout << "Could not open or find the image!\n" << endl;
cout << "Usage: " << argv[0] << " <Input image>" << endl;
return -1;
}
else cout << "img ok\n";
The rest of the code is exactly the same as the tutorial. However, when you run it, the following error message appears:
Doesanyonehaveanyideawhatmightbehappening?
EDIT:I'vebeentestingstepbystepalgorithm,sotheerrorhappensin:
//PerformthedistancetransformalgorithmMatdist;distanceTransform(bw,dist,DIST_L2,3);//Normalizethedistanceimageforrange={0.0,1.0}//sowecanvisualizeandthresholditnormalize(dist,dist,0,1.0,NORM_MINMAX);imshow("Distance Transform Image", dist);
The dist image after running the distanceTranform () function is totally black, and the error occurs in normalize ().