Ask Your Question
1

How to detect rotation angle 0 , -90 ,+90 or 180

asked 2016-11-01 14:10:39 -0600

essamzaky gravatar image

updated 2016-11-02 11:32:57 -0600

I would like to detect the rotation angle of scanned ID card here there are the sample images

[C:\fakepath\+90 Degree.jpg](/upfiles/147810224236179.jpg)

C:\fakepath\0 Degree.jpg C:\fakepath-90 Degree.jpg C:\fakepath\180 Degree.jpg

The first method Use Template matching , the idea is as follow

 1-Select the Template object which is the area not changed in the card  printing  i used the following area to be a template, it's the card logo

image description

2-Use the following tutorial Features2D + Homography to find a known object

3-The result will be as follow image description

The drawbacks of the method are

1-Detection for one type of ID's and i have a lot of card types.
2-it seems this method is slow

Thanks for help any idea is appreciated to find Generic method for different ID cards

edit retag flag offensive close merge delete

Comments

3

It took me 5 seconds to come up with around four ideas and you really have none? Where is your own work?

FooBar gravatar imageFooBar ( 2016-11-01 14:42:02 -0600 )edit

If you are only interested to the angles (-90, +90, 180), an ID card is pretty standardized so you should be able to use for example the photo location with respect to ID card for your task.

Or you can use features matching, estimate the affine transformation and extract the rotation angle.

Eduardo gravatar imageEduardo ( 2016-11-02 11:45:07 -0600 )edit

Thanks @FooBar i had added one method to solve the problem, i'm working on finding other methods such as

1-Detect face orientation
2-Use connected components and find contour to find Text Lines  , use baselines and horizontal Histograms to correct the 180 if exist.
3-Use Hough Transform to find lines of card area , you can use the previouse tip to correct 180 angle
4-The implemented one in the question.

These these are the four methods come in my mind , do you have another ideas ?

essamzaky gravatar imageessamzaky ( 2016-11-02 11:50:42 -0600 )edit

Thanks @Eduarado the cards are only standard in size only , the image location and the text data inside are changing from type to type so how to use affine transformation to detect the angle.

essamzaky gravatar imageessamzaky ( 2016-11-02 12:01:12 -0600 )edit
1

Hey! These are possible approaches, have you also thought about template matching without features: cv::matchTemplate I also thought about detecting (or reading the barcode. e.g. using zbar). OpenCV has also some OCR capabilities: OCRTesseract

FooBar gravatar imageFooBar ( 2016-11-02 12:13:54 -0600 )edit

@FooBar , matchTemplate very time consuming , i have nearly 40 card type so i must prepare 4 templates for every type(0.-90,+90,180), finally i will have 4*40 = 160 template , if i have new scanned card i will do 160 matchtemplate to detect the orintation , it's very expensive in time , regarding the bardcode it's a good idea but it will not succeed in the cards which does not have bardcode . i will check if tesseract contain automatic rotation correction for ID , tesseract use library called leptonica to do image processing

essamzaky gravatar imageessamzaky ( 2016-11-02 12:36:30 -0600 )edit

If you have additional requirements (e.g. cards without barcode) it would be helpful to integrate this information into the question. How do you expect someone to guess this?

FooBar gravatar imageFooBar ( 2016-11-02 12:44:56 -0600 )edit

OK i will do , thanks

essamzaky gravatar imageessamzaky ( 2016-11-02 13:04:56 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-11-01 21:18:13 -0600

unxnut gravatar image

You may want to check getAffineTransform.

edit flag offensive delete link more

Comments

Thanks @unxnut , i will read about getAffineTransform

essamzaky gravatar imageessamzaky ( 2016-11-03 07:15:13 -0600 )edit

HI @unxnut i read about getAffineTranseform but i'm not able to detect the rotation angle using this function , the function need 3 point in Image1 and their equivalent in Image2 , if i know these point in Image2 i can find the angle without this function.

essamzaky gravatar imageessamzaky ( 2016-11-03 09:30:41 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-01 14:10:39 -0600

Seen: 7,892 times

Last updated: Nov 02 '16