0

This code has been successful for localizing and cropping the iris:

image

# circles = cv2.HoughCircles(canny,cv2.HOUGH_GRADIENT,1,10000,param1=50,param2=30,minRadius=50,maxRadius=100)
circles = cv2.HoughCircles(canny,cv2.HOUGH_GRADIENT,1,10000,param1=50,param2=30,minRadius=0,maxRadius=1000)

height,width = gray.shape
r = 0
mask = np.zeros((height,width), np.uint8)
for i in circles[0,:]:
    cv2.circle(bgr,(i[0],i[1]),i[2],(0,255,0),3)
    cv2.circle(mask,(i[0],i[1]),i[2],(255,255,255),thickness=-1)
    blank_image = bgr[:int(i[1]),:int(i[1])]

    masked_data = cv2.bitwise_and(gray, gray, mask=mask)
    _,thresh = cv2.threshold(mask,1,255,cv2.THRESH_BINARY)
    contours = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
    x,y,w,h = cv2.boundingRect(contours[0][0])
    crop = masked_data[y:y+h,x:x+w]
    r = i[2]
    crop_dim =cv2.cvtColor(crop, cv2.COLOR_RGB2BGR)

plt.imshow(bgr)
plt.show()
plt.imshow(crop_dim)
plt.savefig('Hough Transform')
plt.show()

but after i tried it a month later and got the result like this

error                                     Traceback (most recent call last)
<ipython-input-10-74f81f85c0bc> in <module>()
      6 mask = np.zeros((height,width), np.uint8)
      7 for i in circles[0,:]:
----> 8     cv2.circle(bgr,(i[0],i[1]),i[2],(0,255,0),3)
      9     cv2.circle(mask,(i[0],i[1]),i[2],(255,255,255),thickness=-1)
     10     blank_image = bgr[:int(i[1]),:int(i[1])]

error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'circle'
> Overload resolution failed:
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

0 Answers0