Skip to content
Advertisement

OpenCV/Hough Circles: How to apply a condition if circles is None

I have the following code:

JavaScript

(this is the variable red_circles)

JavaScript

Currently when i try use (if red_circles is None) this does not work.. i’m guessing the program throws an error if circles is none however i put the code inside a try, except commands. Any help will be very much appreciated. EDIT: I have added the full code to the post

Advertisement

Answer

You didn’t show FULL error message in question so I don’t know which line makes problem.

But if red_circles can be None then you should check it at first – before you use red_circles in np.uint16(np.around(red_circles)) and for i in red_circles[0, :]: and if (len(red_circles[0, :]) == 7)

JavaScript

And if you use red_circles in other functions then you should also check it at first:

JavaScript

If you don’t want to print text then use not None

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement