Number of circles in region of interest

asked 2020-01-25 08:13:27 -0500

whale gravatar image

I want to be able to count the number of circles in areas of interest, but I am new to python and don't know how to do it. Any help would be greatly appreciated.

import numpy as np
import cv2

img = np.zeros((512,512,3), np.uint8)

cv2.rectangle(img, (30,30), (250,200), (0,0,255), 2)
cv2.rectangle(img, (130,300), (400,400), (0,0,255), 2)

cv2.circle(img, (447,63), 8, (255,255,255), -1)
cv2.circle(img, (80,63), 8, (255,255,255), -1)
cv2.circle(img, (180,120), 8, (255,255,255), -1)
cv2.circle(img, (180,350), 8, (255,255,255), -1)
cv2.circle(img, (250,350), 8, (255,255,255), -1)
cv2.circle(img, (320,350), 8, (255,255,255), -1)
cv2.circle(img, (320,150), 8, (255,255,255), -1)
cv2.circle(img, (400,220), 8, (255,255,255), -1)

roi_one = img[30:200, 30:250]
roi_two = img[300:400, 130:400]

cv2.imshow("ROI ONE", roi_one)
cv2.imshow("ROI TWO", roi_two)
cv2.imshow("IMAGE",img)
cv2.waitKey(0)
edit retag flag offensive close merge delete

Comments

LBerger gravatar imageLBerger ( 2020-01-25 08:38:52 -0500 )edit