forked from SergiyStoyan/PdfDocumentParser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Template.preprocessing.cs
77 lines (69 loc) · 2.42 KB
/
Template.preprocessing.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//********************************************************************************************
//Author: Sergey Stoyan
// sergey.stoyan@gmail.com
// http://www.cliversoft.com
//********************************************************************************************
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace Cliver.PdfDocumentParser
{
/// <summary>
/// parsing rules corresponding to certain pdf document layout
/// </summary>
public partial class Template
{
public Tesseract.PageSegMode TesseractPageSegMode = Tesseract.PageSegMode.SingleBlock;
public PageRotations PageRotation = PageRotations.NONE;
public enum PageRotations
{
NONE,
Clockwise90,
Clockwise180,
Clockwise270,
AutoDetection
}
public bool Deskew = false;
public int DeskewBlockMaxHeight = 3000;
public int DeskewBlockMinSpan = 30;
//public int DeskewThreshold = 1;
public int CvImageScalePyramidStep = 2;
public int ScalingAnchorId = -1;
public Anchor.CvImage GetScalingAnchor()
{
return (Anchor.CvImage)Anchors.FirstOrDefault(a => a.Id == ScalingAnchorId);
}
public List<CvImage> SubtractingImages;
public class CvImage
{
public PdfDocumentParser.CvImage Image;
public float Threshold = 0.70f;
public float ScaleDeviation = 0.05f;
}
public string BitmapPreprocessorClassDefinition = null;
public bool PreprocessBitmap = false;
internal BitmapPreprocessor BitmapPreprocessor
{
get
{
if (bitmapPreprocessor == null)
{
if (string.IsNullOrWhiteSpace(BitmapPreprocessorClassDefinition) || !PreprocessBitmap)
bitmapPreprocessor = new EmptyBitmapPreprocessor();
else
bitmapPreprocessor = BitmapPreprocessor.CompileBitmapPreprocessor(this);
}
return bitmapPreprocessor;
}
}
BitmapPreprocessor bitmapPreprocessor;
internal class EmptyBitmapPreprocessor : BitmapPreprocessor
{
public override Bitmap GetProcessed(Bitmap bitmap)
{
return bitmap;
}
}
}
}