I am trying to detect a defect on a bottle's body. It was very strange that circles are located on the white and light dark circles, not only on the black even though I specified black.
While browsing the net I saw this topic by an expert who confirmed from his side that the color feature is not working properly here. that's the link (You can see it highlighted in red): https://www.learnopencv.com/blob-detection-using-opencv-python-c/
That's the related chunk of my code :
params.filterByArea = true;
params.minArea = 32;
params.maxArea = 60;
params.filterByColor = true;
params.blobColor = 0;
params.filterByConvexity = true;
params.minConvexity = 0.4;
threshold(src_gray, dst, threshold_value, max_BINARY_value, threshold_type);
imwrite("C:\\Documents\\Output testing\\output.jpg", dst);
Ptr<SimpleBlobDetector>detector = SimpleBlobDetector::create(params);
std::vector<KeyPoint> keypoints;
detector->detect(dst, keypoints); // keypoints vector to store the coordinates of the defects, as well as other parameters like size,etc..
//detector.detect(defect_inv, keypoints);
Mat blob_bottle;
drawKeypoints(dst, keypoints, blob_bottle, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS); // drawing a red circle around the defect on the original masked corrected image
imwrite("C:\\Documents\\Output testing\\BlobTest.jpg", blob_bottle);
`
That's the output I'm getting : https://i.stack.imgur.com/u4h4p.jpg , you can see a dark hole, that's the one I am supposed to detect. but changing features (in theory) is not really corresponding the same in reality.
Any help? I also cannot find a clear documentation for the blob topic.