Commit c5bbc035 authored by Aleksandar Atanasov's avatar Aleksandar Atanasov Committed by GitHub

Added small fix when circles are not detected

I noticed that I missed the fact that `cimg` is used in the second `imshow()` call. Changed the scope of the second function call to be within the if-statement. Otherwise in cases where have not been detected the second `imshow()` will attempt to use `cimg` which will be empty leading to an error.
parent 25e2e8aa
...@@ -35,7 +35,8 @@ if __name__ == '__main__': ...@@ -35,7 +35,8 @@ if __name__ == '__main__':
for i in range(b): for i in range(b):
cv2.circle(cimg, (circles[0][i][0], circles[0][i][1]), circles[0][i][2], (0, 0, 255), 3, cv2.LINE_AA) cv2.circle(cimg, (circles[0][i][0], circles[0][i][1]), circles[0][i][2], (0, 0, 255), 3, cv2.LINE_AA)
cv2.circle(cimg, (circles[0][i][0], circles[0][i][1]), 2, (0, 255, 0), 3, cv2.LINE_AA) # draw center of circle cv2.circle(cimg, (circles[0][i][0], circles[0][i][1]), 2, (0, 255, 0), 3, cv2.LINE_AA) # draw center of circle
cv2.imshow("detected circles", cimg)
cv2.imshow("source", src) cv2.imshow("source", src)
cv2.imshow("detected circles", cimg)
cv2.waitKey(0) cv2.waitKey(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment