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 : 8 years ago
Paul Rayman

Rank: Administration

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

Thanks: 7 times
Was thanked: 130 time(s) in 127 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
Guest
Similar Topics
Is there a way to detect page rotation (Common Questions)
by Stefan 9 years ago
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.