AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Rotation angle of scanned document

The forum is to discuss topics related to different areas of image processing and computer vision.

Rotation angle of scanned document

Postby gghazaryan » Sat Sep 17, 2011 4:27 pm

Hi guys,

Here is the problem:
My document(image) has 4 solid black rectangles with fixed sizes (20 X 20 pixels).
After scanning the document I need to calculate the angle of rotation ? (using these small rectangles at the corners..)

I thing there should be very elegant way in AFORGE.NET.

P.S.
I know about DocumentSkewChecker, but this is not helpful in my case.
gghazaryan
 
Posts: 7
Joined: Sat Sep 17, 2011 4:18 pm

Re: Rotation angle of scanned document

Postby andrew.kirillov » Sun Sep 18, 2011 7:55 am

Hello,

gghazaryan wrote:My document(image) has 4 solid black rectangles with fixed sizes (20 X 20 pixels).

Show it then. Descriptions like this tend to be vague.

gghazaryan wrote:After scanning the document I need to calculate the angle of rotation ? (using these small rectangles at the corners..)

You may find those rectangles with Blob Counter routine. Then get coordinates of 4 corners using Quadrilateral Finder. When it is done it becomes quite simple geometry to calculate rotation of rectangle when its corners are known.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2568
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Rotation angle of scanned document

Postby gghazaryan » Sun Sep 25, 2011 8:10 am

Thanks Andrew.
gghazaryan
 
Posts: 7
Joined: Sat Sep 17, 2011 4:18 pm

Re: Rotation angle of scanned document

Postby BombosColombos » Sun Sep 25, 2011 6:35 pm

I did it like that:
Code: Select all
//Rotating orginal image
            sourceImage = AForge.Imaging.Image.Clone((Bitmap)Orginal, PixelFormat.Format24bppRgb);
            double dx = centers[1].X - centers[0].X;  //centers - a collection of 2 centers of an Image no.0 is the top left center of cube, no.1 is  the top right
            double dy = centers[0].Y - centers[1].Y;   
            double ang = Math.Atan2(dx,dy) * (180 / Math.PI);
            RotateBicubic filter = new RotateBicubic(ang-90, false);
//Apply the filter on your Image


And it worked like a charm...
BombosColombos
 
Posts: 7
Joined: Mon Aug 08, 2011 5:52 pm
Location: Promised land




Return to Image Processing and Computer Vision