elliottbolzan
elliottbolzan

Reputation: 1077

Detect Corners of Triangle in Image on iPhone

Hey guys, I'm having a slight problem when finalizing my app; indeed, up until now, at some point, the user had to select the three vertices of a triangle with some draggable objects. Now, even though this isn't a problem, I thought it could be interesting to have close to zero user-interaction, and have my app pick out the vertices of the triangle in an image, and automatically place the markers on the correct spots.

After doing some research, and thinking about stuff lile OpenCV, ImageMagick, etc, I'm not really certain as to how one would recognize and find the location of the vertices of a triangle in an image. Any ideas?

Thanks in advance!

EDIT: If someone has a solution that doesn't involve amy external libraries, I'd still be quite glad to hear it!

Upvotes: 1

Views: 4741

Answers (2)

AndyL
AndyL

Reputation: 14683

It is possible to detect shapes in images and then detect the corners of those shapes using a variety of different image processing techniques. See for example this SO question about detecting corners of polygons and my answer there.

Whether this will actually be a simple or difficult task depends greatly on how much information you can safely assume about the image of your triangle.

For example, if your images are computer generated and have only a triangle in them and nothing else and if the triangle contrasts sharply with the background, as below, than you could write something in a few lines of code using OpenCV that would find your vertices.
triangle from wikipedia

In that case, you would convert your image to a grayscale image, apply a threshold to to create a binary image, use a built in function find the boundary of the image, and then use any of the methods in the SO question to find the corners.

If on the other hand you are dealing with a photograph of a triangle, your problem becomes much more difficult, because it will not be as simple to acquire a binary image of your triangle. You will have to deal with unknown lighting and background conditions. You may not be able to use a simple threshold, and you won't know what value threshold to use. You will likely need to do some kind of edge detection on your image, and you will be looking at a time consuming project. For a start, see the O'Reilly book, Learning OpenCV.

enter image description here

Upvotes: 3

MusiGenesis
MusiGenesis

Reputation: 75366

Feature-detection is complicated stuff, so unless you want to write your own from scratch, you're stuck with using a third-party library. Here's one that looks promising:

http://code.google.com/p/simple-iphone-image-processing/

Upvotes: 0

Related Questions