0
I am working on an object detection project. I use Opencv 4.0.0 and codeblocks 16.01 on Ubuntu 18.04.1. I am testing the Watershed Distance Transform technique using the code of this tutorial:
https://docs.opencv.org/4.0.0/d2/dbd/tutorial_distance_transform.html
I just changed 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 in the tutorial. However, when executing it, the following error message appears:
Does anyone have any idea what might be going on?
EDIT: I was testing step by step of the algorithm, here the error happens in:
// Perform the distance transform algorithm
Mat dist;
distanceTransform(bw, dist, DIST_L2, 3);
// Normalize the distance image for range = {0.0, 1.0}
// so we can visualize and threshold it
normalize(dist, dist, 0, 1.0, NORM_MINMAX);
imshow("Distance Transform Image", dist);
The image dist after performing the distanceTranform() function becomes totally black, and the error happens in normalize().
Hello. From the error message, it seems that the problem occurs when displaying the image in a graphic window (more specifically, when setting the image in the window widget). Your code works with the original tutorial image?
– Luiz Vieira
The same thing happens. After several tests I found out where the error is (I edited the question), but I do not know how to solve...
– zampnrs
You may be using a different image type from the example. The image of the example is in https://github.com/opencv/opencv/blob/master/samples/data/cards.png Compare image to image depth of both (Gray, color, 8 bits, 16 bits)?
– dpetrini