logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Paul Rayman  
#1 Posted : Friday, October 14, 2016 6:34:54 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,011

Thanks: 5 times
Was thanked: 121 time(s) in 118 post(s)
Question
Hey,
I was wondering, if there is an automated way to detect the rotation of a scanned page?

Answer
Please make sure that you have the osd.traindata data file in your output tessdata folder.

Code:

var api = OcrApi.Create();

api.Init();
api.PageSegmentationMode = Patagames.Ocr.Enums.PageSegMode.PSM_AUTO_OSD;
api.SetImage(bmp);
api.Recognize();

var iterator = api.AnalyseLayout();
var orientation = iterator.Orientations;
switch(iterator.Orientations)
{
	case Patagames.Ocr.Enums.Orientation.ORIENTATION_PAGE_DOWN:
		//the image is rotated to 180 
		break;
	case Patagames.Ocr.Enums.Orientation.ORIENTATION_PAGE_LEFT:
		//the image is rotated to 270 clockwise
		break;
	case Patagames.Ocr.Enums.Orientation.ORIENTATION_PAGE_RIGHT:
		//the image is rotated to 90 clockwise
		break;
	case Patagames.Ocr.Enums.Orientation.ORIENTATION_PAGE_UP:
		//the image is rotated to 0
		break;
}
Users browsing this topic
Similar Topics
Is there a way to detect page rotation (Common Questions)
by Stefan 4/4/2016 9:23:07 AM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.