V
V
vvafree2016-11-15 18:34:24
C++ / C#
vvafree, 2016-11-15 18:34:24

Methods for recognizing multiple objects in an image (triangles)?

Good evening. Faced with his own ignorance.
The program recognizes a triangle. On the forehead, so to speak. I sort through the image until I find a pixel of the desired color, then I determine the borders with a beetle and calculate the triangle.
How to organize the same thing for several triangles, so as not to count the same triangle n times?
The condition is that the number of triangles is not known 0_0.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
tsarevfs, 2016-11-15
@tsarevfs

The simplest thing: when you find one, you define its boundaries and do not look further inside those found. triangles.
You can try something like the Hough Transform. Find all the lines and then make triangles out of them. But if the color of the triangles is set, it seems too complicated.

X
xmoonlight, 2016-11-15
@xmoonlight

why beetle?
1. We segment the image into separate objects: "island zones" in order to identify the types of objects. In our case: a triangle or not a triangle.
2. On each "island": found an angle - subtract from 180 and immediately look for the opposite side, then determine the intersection of the straight line segment of the opposite side with the sides of the angle.
3. Once found - delete this triangle from the "canvas".

A
Arthur, 2016-11-17
@Carver182

Several options:
1) If the triangles are different, make a BW picture, you can do a threshold transformation and feed the result to the findContours function, at the output you get the contours of more or less selected objects (several triangles, several contours). Further, each contour is checked for the fact that it is a triangle or not.
2) If the triangles are all the same in shape and size, calculate the first one and thus get a search sample and, using the templateMatching function, look for matches of this sample in the desired image.
3) If the triangles are all the same only in shape, but not in area, also find the first triangle and calculate it, the so-called moment of inertia (it is unique for each figure), normalize this moment, and compare with the rest of the moments of other objects. PS. figures, among which you will look for a triangle, you can get in the form of contours, as described in the first option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question