changes to run ocr on windows

This commit is contained in:
Anshul Maheshwari
2014-06-11 17:32:40 +05:30
parent dc8a05d76a
commit 5f454ecedc
4 changed files with 56 additions and 4 deletions

View File

@@ -53,3 +53,44 @@ Compile CCextractor passing flags like following
-------------------------------------------------
make ENABLE_OCR=yes
How to compile ccextractor on Windows with OCR
=============================================
Download prebuild library of leptonica from following link
http://www.leptonica.com/source/leptonica-1.68-win32-lib-include-dirs.zip
Download prebuild library of tesseract from following tesseract official link
https://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-3.02.02-win32-lib-include-dirs.zip
put the path of libs/include of leptonica and tesseract in library paths.
step 1) In visual studio 2013 right click <Project> and select property.
step 2) Select Configuration properties in left panel(column) of property.
step 3) Select VC++ Directory.
step 4) In the right pane, in the right-hand column of the VC++ Directory property,
open the drop-down menu and choose Edit.
Step 5) Add path of Directory where you have kept uncompressed library of leptonica
and tesseract.
Set preprocessor flag ENABLE_OCR=1
Step 1)In visual studio 2013 right click <Project> and select property.
Step 2)In the left panel, select Configuration Properties, C/C++, Preprocessor.
Step 3)In the right panel, in the right-hand column of the Preprocessor Definitions property, open the drop-down menu and choose Edit.
Step 4)In the Preprocessor Definitions dialog box, add ENABLE_OCR=1. Choose OK to save your changes.
Add library in linker
step 1)Open property of project
Step 2)Select Configuration properties
Step 3)Select Linker in left panel(column)
Step 4)Select Input
Step 5)Select Additional dependencies in right panel
Step 6)Add libtesseract302.lib in new line
Step 7)Add liblept168.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 extract the tar file and put
tessdata folder where you have kept ccextractor executable
Copy the tesseract and leptonica dll in the folder of executable or in system32.

View File

@@ -423,7 +423,7 @@ static int save_spupng(const char *filename, uint8_t *bitmap, int w, int h,
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
png_bytep* row_pointer = NULL;
int i, j, ret;
int i, j, ret = 0;
int k = 0;
if(!h)
h = 1;

View File

@@ -1,5 +1,6 @@
#include "png.h"
#ifdef ENABLE_OCR
#include "platform.h"
#include "capi.h"
#include "allheaders.h"
@@ -20,7 +21,9 @@ char* ocr_bitmap(png_color *palette,png_byte *alpha, unsigned char* indata,int w
}
wpl = pixGetWpl(pix);
data = pixGetData(pix);
#if LEPTONICA_VERSION > 69
pixSetSpp(pix, 4);
#endif
for (i = 0; i < h; i++)
{
ppixel = data + i * wpl;

View File

@@ -1,18 +1,26 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ccextractor", "ccextractor.vcproj", "{0F0063C4-BCBC-4379-A6D5-84A5669C940A}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ccextractor", "ccextractor.vcxproj", "{0F0063C4-BCBC-4379-A6D5-84A5669C940A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug|Win32.ActiveCfg = Debug|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug|Win32.Build.0 = Debug|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug|x64.ActiveCfg = Debug|x64
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug|x64.Build.0 = Debug|x64
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release|Win32.ActiveCfg = Release|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release|Win32.Build.0 = Release|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release|x64.ActiveCfg = Release|x64
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE