# calculate blob angle

Hello there,

Is it possible to detect the blob angle ? I am currently working on a project to detect letters out of a picture. My letters are on a conveyor belt and a camera takes a picture. In this picture i use blob detection to search for my letter. Because the camera detects lots of other things and since i am only interested in the letter i can easy filter then with filterbyarea. So i get this result

Now assume the letter on the conveyor belt is on an angle greater then 20 degrees. If i use the same program is impossible to detect the letter H. This comes because OCR can only detect letters with an angle of max 20 degrees.

With Quaternion calculation i should be able to calculate this angle, but i can't find any information about this. Is this even possible ?

To make a long story short i want to search the angle X in order to use OCR.

All help is welcome Thanks in advance

Best Regards,

Kenny

edit retag close merge delete

Sort by ยป oldest newest most voted

Two ideas came to my mind.

1. The more difficult one: You could compute the two main axes by principal component analysis (pca) and from these the angle. A more complete answer to achieve this is given in this post: http://stackoverflow.com/questions/1532168/what-are-the-second-moments-of-a-region

2. The easier solution: Apply findContours to the filtered letter, then search for the minimal rotated Rectangle using cv::minAreaRect(<the_contour>) which returns a RotatedRect from which you can get the angle.

more

thanks for the respond i will look into both solutions

( 2013-02-17 11:53:29 -0500 )edit

Official site

GitHub

Wiki

Documentation

## Stats

Seen: 2,744 times

Last updated: Feb 17 '13