File: OCR.md

package info (click to toggle)
ccextractor 0.87+ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 10,064 kB
  • sloc: ansic: 172,772; makefile: 777; sh: 622; python: 319
file content (102 lines) | stat: -rw-r--r-- 4,017 bytes parent folder | download
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

Overview
========
OCR (Optical Character Recognition) is a technique used to 
extract text from images. In the World of Subtitle, subtitle stored 
in bitmap format are common and even necessary for converting subtitle 
in bitmap format to subtitle in text format OCR is used.

Dependency
==========
1. Tesseract (OCR library by Google)
2. Leptonica (Image processing library)

Ubuntu install Dependency using package manager
===============================================
```
sudo apt-get install libleptonica-dev libtesseract-dev tesseract-ocr-eng
```

How to compile CCExtractor on Linux with OCR
=============================================

Download and Install Leptonnica.
-------------------------------
This package is available in your distro, you need liblept-devel library.

If Leptonica isn't available for your distribution, or you want to use a newer version
 than they offer, you can compile your own.

you can download lib leptonica from  http://www.leptonica.com/download.html

Download and Install Tesseract.
-------------------------------
Tesseract is available directly from many Linux distributions. The package is generally
 called 'tesseract' or 'tesseract-ocr' - search your distribution's repositories to
 find it. Packages are also generally available for language training data (search the
 repositories,) but if not you will need to download the appropriate training data,
 unpack it, and copy the .traineddata file into the 'tessdata' directory, probably
 /usr/share/tesseract-ocr/tessdata or /usr/share/tessdata.

If Tesseract isn't available for your distribution, or you want to use a newer version
 than they offer, you can compile your own.

If you compile Tesseract then following command in its source code are enough
```
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
```

Note: 
1. CCExtractor is tested with Tesseract 3.04 version but it works with older versions. 
2. Useful Download links:
    1. *Tesseract*  https://github.com/tesseract-ocr/tesseract/archive/3.04.00.tar.gz
    2. *Tesseract training data* https://github.com/tesseract-ocr/tessdata/archive/3.04.00.tar.gz



Compile CCExtractor passing flags like following
-------------------------------------------------
```
make ENABLE_OCR=yes
```


How to compile CCExtractor on Windows with OCR
===============================================

Download prebuild library of leptonica and tesseract from following link  
https://drive.google.com/file/d/0B2ou7ZfB-2nZOTRtc3hJMHBtUFk/view?usp=sharing  

put the path of libs/include of leptonica and tesseract in library paths.  
1. In visual studio 2013 right click <Project> and select property. 
2. Select Configuration properties in left panel(column) of property.
3. Select VC++ Directory.
4. In the right pane, in the right-hand column of the VC++ Directory property, open the drop-down menu and choose Edit.
5. Add path of Directory where you have kept uncompressed library of leptonica and tesseract.


Set preprocessor flag ENABLE_OCR=1  
1. In visual studio 2013 right click <Project> and select property.
2. In the left panel, select Configuration Properties, C/C++, Preprocessor.
3. In the right panel, in the right-hand column of the Preprocessor Definitions property, open the drop-down menu and choose Edit.
4. In the Preprocessor Definitions dialog box, add ENABLE_OCR=1. Choose OK to save your changes.

Add library in linker
1. Open property of project
2. Select Configuration properties
3. Select Linker in left panel(column)
4. Select Input
5. Select Additional dependencies in right panel
6. Add libtesseract304d.lib in new line
7. Add liblept172.lib in new line

Download language data from following link  
https://code.google.com/p/tesseract-ocr/downloads/list  
after downloading the tesseract-ocr-3.02.eng.tar.gz extract the tar file and put  
tessdata folder where you have kept CCExtractor executable  

Copy the tesseract and leptonica dll from lib folder downloaded from above link to folder of executable or in system32.