Skip to content
Advertisement

Filter contour area with smaller area

I would like to filter out cnts with small area. But I got the an error. What is the proper way to use filter?

code

JavaScript
JavaScript

error

JavaScript

Advertisement

Answer

The filter function returns a generator but the drawContours function expects a list. To fix this, use the list command.

JavaScript

Another solution is to use a list comprehension to build the list, like this:

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