Pregunta

I managed to detect regular shapes using OpenCV by detecting the contours of all found shapes and analysing those.

Now I need a way to find the colour of these found shapes. I have no idea where to start, and web search isn't helping much.

Any help is much appreciated!

¿Fue útil?

Solución

When you detect contours in openCV, they are stored as a sequence of Points where each point has its x and y coordinate.

so, your contour for one object will be something like this {Point1, Point2, Point3...so on}. Where x1 = Point1.x; y1 = Point1.y and so on.

So, for each contour, try to find the minimum value of x, maximum value of x, minimum value of y and maximum value of y. So, by using this values, you get the maximum coverage of the given contour (create a Bounding Rect using this information).

After doing that, just try to find the color of the Bouding Rect for each contour.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top