The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.   The best answers are voted up and moderated by our team

# Circles is unsubscriptable

1
Vote
0

Hi!!

I’m trying to run the code for the cpstone_solution where a function is used to differentiate coins in an image.
Even when I just opened the file and didn’t make any modifications of any kind, two problems appear (well, one in two lines):
– Value ‘circle’ is unsubscriptable
This appears for line 29 and 56. I looked up and found that this means that two values are expected and only one is introduced. However, I don’t understand why this happens.

the code is like this:

def av_pix(img,circles,size):
av_value = []
for coords in circles[0,:]:
col = np.mean(img[coords-size:coords+size,coords-size:coords+size])
#print(img[coords-size:coords+size,coords-size:coords+size])
av_value.append(col)
return av_value

for coords in circles[0,:]:

img = cv2.GaussianBlur(img, (5,5), 0)

print(circles)

circles = np.uint16(np.around(circles))
count = 1
for i in circles[0,:]:

# draw the outer circle
cv2.circle(original_image,(i,i),i,(0,255,0),2)
# draw the center of the circle
cv2.circle(original_image,(i,i),2,(0,0,255),3)
#cv2.putText(original_image, str(count),(i,i), cv2.FONT_HERSHEY_SIMPLEX, 2, (0,0,0), 2)
count += 1

bright_values = av_pix(img,circles,20)
print(bright_values)

values = []
if a > 150 and b > 110:
values.append(10)
elif a > 150 and b <= 110:
values.append(5)
elif a < 150 and b > 110:
values.append(2)
elif a < 150 and b < 110:
values.append(1)
print(values)
count_2 = 0
for i in circles[0,:]: