Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect a specific shape using OpenCV

I'm still a beginner in OpenCV.

Currently, I'm trying to detect a specific shape as in the image in the link below using OpenCV.

enter image description here

I've read many blogs and articles about detecting shapes using OpenCV but I've not found anything related to what I'm working on.

Also, I can't use methods like cvHistogram, because I don't want to find matches in two almost identical pictures, but instead, I want to detect a specific shape, and not some geometric shapes like rectangles, circles, etc.

Do you know a way to do it?

Thank you in advance.

like image 659
firewall Avatar asked Dec 09 '12 15:12

firewall


People also ask

How do you find the shape of an image in Python?

When working with OpenCV Python, images are stored in numpy ndarray. To get the image shape or size, use ndarray. shape to get the dimensions of the image. Then, you can use index on the dimensions variable to get width, height and number of channels for each pixel.

How do you find triangles in OpenCV?

Python - OpenCV & PyQT5 together To detect a triangle in an image, we first detect all the contours in the image. Then we loop over all the contours. Find the approximate contour for each of the contours. If the number of vertex points in the approximate contour is 3, then draw the contour and set it as a triangle.

How does OpenCV detect squares?

Compute the aspect ratio of the contour cnt. Set a range of aspect ratios to detect the square. We set it [0.9, 1.1]. If the ratio is between 0.9 and 1.1, the detected contour is a square else it is a rectangle.


1 Answers

It's hard to say how to detect this shape. You should specify some criterions about shape that you want to detect. For example in your case:

  1. should this always be inside another contour?
  2. should it has that big black blob?

And so on.

And after this it will be easier to find good detection algorithm.

By the way reading these docs will be useful:

  1. Finding contours in your image
  2. Structural Analysis and Shape Descriptors
like image 133
ArtemStorozhuk Avatar answered Sep 25 '22 01:09

ArtemStorozhuk