Added small fix when circles are not detected
authorAleksandar Atanasov <redbaronqueen@gmail.com>
Sun, 12 Jun 2016 10:54:16 +0000 (12:54 +0200)
committerGitHub <noreply@github.com>
Sun, 12 Jun 2016 10:54:16 +0000 (12:54 +0200)
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

index 477dac0..0bfee42 100755 (executable)
@@ -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)