
Code:
# coding: utf-8
The import cv2
The import numpy as np
# read source map
Img=cv2. Imread (r "D: \ \ 1. JPG")
Cv2. Imshow (' image 'img)
# pretreatment
Gray=cv2. CvtColor (img, cv2 COLOR_RGB2GRAY)
The blur=cv2. GaussianBlur (gray, (17, 17), 0)
The kernel=cv2. GetStructuringElement (cv2 MORPH_RECT, (10, 10))
Open_=cv2. MorphologyEx (the blur, cv2 MORPH_OPEN, kernel)
Edge=cv2. Canny (open_, 50, 100, apertureSize=3)
# hoff round
Circles=cv2. HoughCircles (edge, cv2. HOUGH_GRADIENT, 1, 30, param1=100, param2=30, minRadius=0, maxRadius=0)
Circles=np. Uint16 (np) around (circles) # circles contain's center and radius value into an integer
For I circles in [0, :] :
Cv2. Circle (img, (I [0], I [1]), I [2], (0, 0, 255), 2) # circle
Cv2. Circle (img, (I [0], I [1]), 2, (0, 0, 255), 2) # painting circle
Cv2. Imshow (" circles ", img)
# exit
Cv2. WaitKey (0)
Cv2. DestroyAllWindows ()
Source:

Results: only identify three, has failed to identify several other,
