Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Smart Straighten Function #236
Create a function that looks at the longest and strongest lines and sets them to be horizontal and vertical images. A good example would be scanning a business card at an arbitrary angle and the function would rotate it so the edges are horizontal and vertical.
So I gave the bins idea a shot. The problem was if there are many small ( insignificant ) lines at an orientaion they will fill the bin more.
Instead of incrementing the bin by 1 for each line at that angle, I am incrementing by the length of the line, so that I can get length into consideration . I then pick the biggest bin and rotate to the average of angles of the lines in that bin. The problem still persists. Too many smaller lines tend to influence the rotation.
See the results here. I am drawing all the lines in the seected bins.
I am thinking of setting a threshold, like consider only the 'k' longest lines(taken from user).
@kscottz I added the feature you said, the code now tries to decide how to rotate ( vertical or horizontal ). I couldn't find any literature/projects that do exactly the same thing. I found some work on rotating documents and rotating knowing the original object. Also a few regarding rotating at right angles ( 90,180,270 ).
Let me know how you find this.
Best of the lot
It couldn't rotate all, it threw warnings on the images in which both sides are identical, since it couldn't find lines.