I am currently using opencv to detect simple points in shapes. At first I used C ++ and everything worked fine. Now I'm trying to do the same with Python, since I need to use it on the Internet, and edge detection does not seem to work either.
Here is my C ++ code:
_src = cv::imread(_imagePath); cv::Mat gray; cv::cvtColor(_src, gray, CV_BGR2GRAY); cv::Mat bw; cv::Canny(gray, bw, 0, 50, 5); cv::findContours(bw.clone(), allCountours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE);
As you can see, this is pretty simple, the same code is Python:
self._src = cv2.imread(self._imagePath) gray = cv2.cvtColor(self._src, cv2.COLOR_BGR2GRAY) bw = cv2.Canny(gray, 0, 50, 5) allCountours, hierarchy = cv2.findContours(bw.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
To show the results, I used drawcontours with random colors on different paths:

As you can see, in C ++ every outline of the figure is detected properly, although it is not perfect, whereas in Python I have much more outlines. Each time the line breaks a bit, a new contour is detected. Any idea how I could fix this? Thank you!