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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
Stefan  
#1 Posted : Monday, April 4, 2016 9:23:07 AM(UTC)
Quote
Stefan

Rank: Newbie

Groups: Registered
Joined: 4/4/2016(UTC)
Posts: 4
Germany
Location: Munic

Hey,
I am currently searching for an alternative for our current rasterizing SDK and found Pdfium. I was wondering, if there is an automated way to detect the rotation of a pdf file?
Lets say I have a document that is scanned upide down and sent to Pdfium as PDF file. Is it possible to detect the rotation of the content?

EDIT:
Is it possible to output a deskewed and correctly oriented version of the page, maybe in combination with your tesseract SDK? I know that tesseract has OSD, so can you tell the renderer to rotate the output pdf accordingly?

Edited by user Tuesday, April 5, 2016 4:55:45 AM(UTC)  | Reason: Not specified

Guest  
#2 Posted : Tuesday, April 5, 2016 6:47:30 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 158

Was thanked: 4 time(s) in 4 post(s)
well ... you can try to recognize the image four times at different angles, and choose the one of them where the most good result. To evaluate the result you can use the TextConfidences property.

Edited by user Tuesday, April 5, 2016 6:55:59 AM(UTC)  | Reason: Not specified

Paul Rayman  
#3 Posted : Tuesday, April 5, 2016 10:20:53 PM(UTC)
Quote
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)
There is a another way to determine the page orientation.
The following code works perfect for me.
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;
}
Quick Reply Show Quick Reply
Users browsing this topic
Similar Topics
Is there a way to detect page rotation (F.A.Q.)
by Paul Rayman 10/14/2016 6:34:54 PM(UTC)
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.