Object Detection and False Detection Evaluation · Study
English translation
Execution conditions
Use opencv-python-headless, NumPy, and Matplotlib.
Topics covered
More detections do not necessarily mean a better setting. Compare with known circle positions and sizes to identify false detections.
Overall workflow
Ground truth image → Hough detection → one-to-one matching → misses/false detections
Match detections to ground truth
Circle detection results include a center and radius. Creating a small image with known ground truth first lets you distinguish misses, duplicates, and false detections. Do not match multiple detections to one circle as correct simultaneously.
Roles of thresholds and preprocessing
Lowering the HoughCircles detection threshold can yield more candidates, but also more false detections. Noise reduction filters can also blur boundaries.
Compare detection counts, position errors, and processing times under the same conditions.
Worked example
Draw circles in a 160×200 grayscale image with centers (50,50), (140,70), (90,120) and radii 15,20,12.
import numpy as np
import matplotlib.pyplot as plt
import cv2 as cv
truth=[(50,50,15),(140,70,20),(90,120,12)]
image=np.full((160,200),230,dtype=np.uint8)
for x,y,r in truth:cv.circle(image,(x,y),r,30,-1)
blur=cv.GaussianBlur(image,(5,5),1)
def detect(frame,threshold=20):
return cv.HoughCircles(frame,cv.HOUGH_GRADIENT,dp=1,minDist=25,param1=100,param2=threshold,minRadius=8,maxRadius=25)
found=detect(blur);print(found)
plt.imshow(image,cmap='gray')
if found is not None:
for x,y,r in found[0]:plt.gca().add_patch(plt.Circle((x,y),r,fill=False,color='tab:red'))
[[[140.5 70.5 19.6] [ 50.5 50.5 14.7] [ 90.5 120.5 11.3]]]
Official documentation and data
Reference example
View more examples