From c5bbc0353c1daadae8d953baf2940b146cd87185 Mon Sep 17 00:00:00 2001 From: Aleksandar Atanasov Date: Sun, 12 Jun 2016 12:54:16 +0200 Subject: [PATCH] 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. --- samples/python/houghcircles.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/python/houghcircles.py b/samples/python/houghcircles.py index 477dac00d..0bfee4293 100755 --- a/samples/python/houghcircles.py +++ b/samples/python/houghcircles.py @@ -35,7 +35,8 @@ if __name__ == '__main__': 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]), 2, (0, 255, 0), 3, cv2.LINE_AA) # draw center of circle + + cv2.imshow("detected circles", cimg) cv2.imshow("source", src) - cv2.imshow("detected circles", cimg) cv2.waitKey(0)