Arrow shape detection using OpenCV
I'm currently trying to detect an arrow and its orientation using OpenCV. I've done the contour detection process that work fine but my problem is on the shape-matching side.
I tried to use matchShapes function in OpenCV but my results seems really bad. I use a simple template image and a processed image (usually a photo but for the test I used a simple image)
Using these two, matchShapes tells me that the square on the left looks more like the template that the arrow on the image. I don't know where does this comes from.
Is matchShapes a bad function for this use? Someone told me to use SIFT algorithm but isn't it a little bit overkill for such a simple shape?
I would try to work with Image moment to find the shape. For that you have to find different propertys of the image region. And the best is would like to binarize the image. First I tell you some techniques to describe a shape they don't have to do something with the image moment.
First there would be the circumference/perimeter of the shape. Computing the perimeter you need to sum the length of all contur elements of the shape. Next the area of the shape can be computed, you can count the pixels or take the shoelace distance like in this post. With the perimeter and the area, it is possible to calculate the circularity of the object/shape. More detailed you are able to create an bounding box and convex hull of it. Last not but not least the shape has a center of gravity. This are some propertys with taht you can build your own feature vectors, but you have to be a bit creative. Or you can use image moment.
Iam not sure if Image moment exists in OpenCV, the best and robust moment are the hu moment. I found some explenation here in stackoverflow: Meaning of the seven Hu invariant moments function from OpenCV. Hu moment er robust against rotation, translation and scale. So perfect for your problem.