initial import
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "Coordinates.h"
|
||||
|
||||
|
||||
Coordinates::Coordinates(int top, int left, int bottom, int right)
|
||||
{
|
||||
m_top = top;
|
||||
m_left = left;
|
||||
m_bottom= bottom;
|
||||
m_right = right;
|
||||
}
|
||||
|
||||
bool Coordinates::operator == (Coordinates const & coor)
|
||||
{
|
||||
return (
|
||||
(m_top == coor.m_top) &&
|
||||
(m_left == coor.m_left) &&
|
||||
(m_bottom == coor.m_bottom) &&
|
||||
(m_right == coor.m_right)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int Coordinates::top()
|
||||
{
|
||||
return m_top;
|
||||
}
|
||||
|
||||
int Coordinates::left()
|
||||
{
|
||||
return m_left;
|
||||
}
|
||||
|
||||
int Coordinates::bottom()
|
||||
{
|
||||
return m_bottom;
|
||||
}
|
||||
|
||||
int Coordinates::right()
|
||||
{
|
||||
return m_right;
|
||||
}
|
||||
|
||||
|
||||
ostream & operator<<( std::ostream & out, Coordinates const & coor)
|
||||
{
|
||||
out << "(" << coor.m_top << "," << coor.m_left << ")<->(" << coor.m_bottom << "," << coor.m_right << ")" << endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Coordinates
|
||||
{
|
||||
|
||||
public:
|
||||
Coordinates(int top, int left, int bottom, int right);
|
||||
|
||||
bool operator == (Coordinates const & coor);
|
||||
|
||||
int top();
|
||||
int left();
|
||||
int bottom();
|
||||
int right();
|
||||
|
||||
friend ostream & operator<<( std::ostream & out, Coordinates const & coor);
|
||||
|
||||
private:
|
||||
|
||||
int m_top;
|
||||
int m_left;
|
||||
int m_bottom;
|
||||
int m_right;
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
#include "OCREngineService.h"
|
||||
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
extern void Start(OurOCREngine &engine);
|
||||
extern ofstream out;
|
||||
OCREngineService::OCREngineService(int argc, char **argv)
|
||||
: QtService<QCoreApplication>(argc, argv, "OCR Engine Serivce")
|
||||
{
|
||||
setServiceDescription("socialhose.com's OCR Engine using Qt");
|
||||
}
|
||||
|
||||
OCREngineService::~OCREngineService(void)
|
||||
{
|
||||
}
|
||||
|
||||
void OCREngineService::start()
|
||||
{
|
||||
out << "Start of the service" << endl;
|
||||
//logMessage("Starting OCR Engine Service");
|
||||
|
||||
QCoreApplication *app = application();
|
||||
if(!m_ocrEngine.Initalize())
|
||||
{
|
||||
//logMessage("Failed to start OCR Engine Service");
|
||||
out << "Failed to start OCR Engine Service" << endl;
|
||||
app->quit();
|
||||
return;
|
||||
}
|
||||
|
||||
m_future = QtConcurrent::run( Start, m_ocrEngine);
|
||||
|
||||
//logMessage("OCR Engine Service started");
|
||||
|
||||
out << "Service started" << endl;
|
||||
}
|
||||
/*
|
||||
void OCREngineService::pause()
|
||||
{
|
||||
m_ocrEngine.Pause();
|
||||
}
|
||||
*/
|
||||
void OCREngineService::stop()
|
||||
{
|
||||
out << "************************ stopping the service ************************" << endl;
|
||||
//logMessage("Stopping OCR Engine Service");
|
||||
m_ocrEngine.Stop();
|
||||
m_future.waitForFinished();
|
||||
//logMessage("OCR Engine Service stopped");
|
||||
|
||||
out << "************************ service stopped ****************************" << endl;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "qtservice.h"
|
||||
|
||||
#include "OurOCREngine.h"
|
||||
|
||||
class OCREngineService :
|
||||
public QtService<QCoreApplication>
|
||||
{
|
||||
public:
|
||||
OCREngineService(int argc, char **argv);
|
||||
~OCREngineService(void);
|
||||
|
||||
protected:
|
||||
void start();
|
||||
// void pause();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
OurOCREngine m_ocrEngine;
|
||||
QFuture<void> m_future;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,110 @@
|
||||
|
||||
#ifndef _OUROCRENGINE_H_
|
||||
#define _OUROCRENGINE_H_
|
||||
|
||||
#include <idrs.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <QtSql/QtSql>
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
#include "Word.h"
|
||||
#include "Tag.h"
|
||||
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
//using namespace mysqlpp;
|
||||
|
||||
|
||||
struct PageInfo
|
||||
{
|
||||
int m_sectionPagesId;
|
||||
QString m_remotePath;
|
||||
QString m_localPath;
|
||||
bool m_isArabic;
|
||||
bool m_isCopied;
|
||||
bool m_isProcessed;
|
||||
};
|
||||
|
||||
struct TagInfo
|
||||
{
|
||||
int m_id;
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
|
||||
class OurOCREngine
|
||||
{
|
||||
public:
|
||||
OurOCREngine();
|
||||
~OurOCREngine();
|
||||
bool Initalize();
|
||||
|
||||
friend void Start(OurOCREngine &engine);
|
||||
//void Pause();
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
bool ReadSettings();
|
||||
bool ConnectToDatabase();
|
||||
void GetIssuePath();
|
||||
void ConstructPagesPath();
|
||||
|
||||
void Process();
|
||||
bool ProcessPage(QString &pagePath, bool isArabic);
|
||||
|
||||
void GetPagesToProcess();
|
||||
void ResetUnprocessedPages();
|
||||
|
||||
|
||||
QList<Tag> SearchTags(bool isArabic);
|
||||
QStringList GetTagCoordinates(QString tag, bool ismultiword);
|
||||
|
||||
void DeleteFromDatabase(int id_section_pages);
|
||||
void AddToDatabase(int id_section_pages, QList<Tag> &tags);
|
||||
|
||||
void ConvertToSingleBox(QString &str);
|
||||
|
||||
void RemoveDashAndTheFollowingSpace(QString &text);
|
||||
|
||||
void GetTagsFromDatabase(bool isArabic);
|
||||
|
||||
QString CurrentDateTime();
|
||||
|
||||
void CopyFiles();
|
||||
void DeleteFiles();
|
||||
|
||||
void ShowException ( IDRS::IDRSException & theIDRSException );
|
||||
|
||||
private:
|
||||
IDRS::CReader m_reader;
|
||||
|
||||
QList<PageInfo> m_pagesToProcess;
|
||||
QList<Word> m_words;
|
||||
QList<TagInfo> m_databaseTags;
|
||||
|
||||
bool m_isReady;
|
||||
|
||||
QSqlDatabase m_database;
|
||||
|
||||
//current page text
|
||||
QString m_pageText;
|
||||
|
||||
//issues path
|
||||
QString m_issuePath;
|
||||
//database connection
|
||||
QString m_databaseName;
|
||||
QString m_server;
|
||||
QString m_user;
|
||||
QString m_password;
|
||||
int m_port;
|
||||
|
||||
int m_currentIndex;
|
||||
};
|
||||
|
||||
#endif //_OUROCRENGINE_H_
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OurOCREngine", "OurOCREngine.vcproj", "{D9DE3749-D63E-4595-BE7E-C1DCB853FD3D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D9DE3749-D63E-4595-BE7E-C1DCB853FD3D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D9DE3749-D63E-4595-BE7E-C1DCB853FD3D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D9DE3749-D63E-4595-BE7E-C1DCB853FD3D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D9DE3749-D63E-4595-BE7E-C1DCB853FD3D}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Binary file not shown.
@@ -0,0 +1,245 @@
|
||||
<?xml version="1.0" encoding="windows-1256"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="OurOCREngine"
|
||||
ProjectGUID="{D9DE3749-D63E-4595-BE7E-C1DCB853FD3D}"
|
||||
RootNamespace="OurOCREngine"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="./bin"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="-Zm200 -w34100 -w34189 -w34100 -w34189"
|
||||
Optimization="4"
|
||||
AdditionalIncludeDirectories="C:\iDRS_14.0.12.0\include;C:\Qt\2009.03\qt\service\src"
|
||||
PreprocessorDefinitions="_WINDOWS;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="3"
|
||||
BufferSecurityCheck="false"
|
||||
TreatWChar_tAsBuiltInType="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="qtmaind.lib QtGuid4.lib QtCored4.lib QtSqld4.lib QtSolutions_Service-2.6d.lib idrskrn14.lib"
|
||||
OutputFile="./bin\$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="c:\Qt\2009.03\qt\lib;C:\Qt\2009.03\qt\service\lib;C:\Qt\2009.03\lib;C:\iDRS_14.0.12.0\lib"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="./bin"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="C:\iDRS_14.0.12.0\include;C:\Qt\2009.03\qt\service\src"
|
||||
PreprocessorDefinitions="_WINDOWS;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
TreatWChar_tAsBuiltInType="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="qtmain.lib QtGui4.lib QtCore4.lib QtSql4.lib QtSolutions_Service-2.6.lib idrskrn14.lib"
|
||||
OutputFile="./bin\$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="c:\Qt\2009.03\qt\lib;C:\Qt\2009.03\qt\service\lib;C:\Qt\2009.03\lib;C:\iDRS_14.0.12.0\lib"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Coordinates.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\idrs_config.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OurOCREngine.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tag.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Word.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Coordinates.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\idrs_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OurOCREngine.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tag.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Word.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "Tag.h"
|
||||
|
||||
Tag::Tag(int id, QString coordinates): m_id(id), m_coordinates(coordinates)
|
||||
{
|
||||
}
|
||||
|
||||
int Tag::id()
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QString Tag::coordinates()
|
||||
{
|
||||
return m_coordinates;
|
||||
}
|
||||
|
||||
void Tag::AddTag(QList<Tag> &tags, Tag t)
|
||||
{
|
||||
for(int i=0; i< tags.count(); i++)
|
||||
{
|
||||
if(t.id() == tags[i].id() &&
|
||||
t.coordinates() == tags[i].coordinates() )
|
||||
return;
|
||||
}
|
||||
|
||||
tags.append(t);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QtCore>
|
||||
|
||||
class Tag
|
||||
{
|
||||
public:
|
||||
Tag(int id, QString coordinates);
|
||||
|
||||
static void AddTag(QList<Tag> &tags, Tag t);
|
||||
|
||||
int id();
|
||||
QString coordinates();
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
QString m_coordinates;
|
||||
};
|
||||
@@ -0,0 +1,85 @@
|
||||
#include "Word.h"
|
||||
#include "Coordinates.h"
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
QString charset = "`'!,().,\"";
|
||||
|
||||
|
||||
Word::Word(wstring &str, int top, int left, int bottom, int right)
|
||||
{
|
||||
m_word = QString::fromStdWString(str);
|
||||
AddCoordinates(top, left, bottom, right);
|
||||
|
||||
//remove third persons character
|
||||
m_word = m_word.replace("'s", "");
|
||||
|
||||
RemoveLastCharacter(charset);
|
||||
RemoveFirstCharacter(charset);
|
||||
}
|
||||
|
||||
void Word::AddCoordinates(int top, int left, int bottom, int right)
|
||||
{
|
||||
Coordinates c(top, left, bottom, right);
|
||||
m_coordinates.append(c);
|
||||
}
|
||||
|
||||
void Word::AddCoordinates(QList<Coordinates> cList)
|
||||
{
|
||||
for(int i=0; i< cList.count(); i++)
|
||||
m_coordinates.append(cList[i]);
|
||||
}
|
||||
|
||||
QString Word::word()
|
||||
{
|
||||
return m_word;
|
||||
}
|
||||
|
||||
void Word::appendToWord(QString &append, bool removeLastCharacter)
|
||||
{
|
||||
if(removeLastCharacter)
|
||||
m_word = m_word.left(m_word.length() -1) + append;
|
||||
else
|
||||
m_word += append;
|
||||
}
|
||||
|
||||
QList<Coordinates> Word::coordinates()
|
||||
{
|
||||
return m_coordinates;
|
||||
}
|
||||
|
||||
|
||||
QString Word::FormatCoordinatesToExport()
|
||||
{
|
||||
QString coord;
|
||||
for(int i=0; i< m_coordinates.count(); i++)
|
||||
{
|
||||
QString str = QString("%1,%2,%3,%4")
|
||||
.arg( m_coordinates[i].top () )
|
||||
.arg( m_coordinates[i].left () )
|
||||
.arg( m_coordinates[i].bottom () )
|
||||
.arg( m_coordinates[i].right () );
|
||||
|
||||
coord += str;
|
||||
if (i != m_coordinates.count() -1 )
|
||||
coord += ":";
|
||||
}
|
||||
return coord;
|
||||
}
|
||||
|
||||
|
||||
//utilitiy functions
|
||||
void Word::RemoveFirstCharacter(QString charset)
|
||||
{
|
||||
QChar c = m_word[0];
|
||||
if(charset.indexOf(c) > -1)
|
||||
m_word = m_word.right(m_word.length() - 1);
|
||||
}
|
||||
|
||||
void Word::RemoveLastCharacter(QString charset)
|
||||
{
|
||||
QChar c = m_word[m_word.length() -1];
|
||||
if(charset.indexOf(c) > -1)
|
||||
m_word = m_word.left(m_word.length() - 1);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QtCore>
|
||||
|
||||
#include "Coordinates.h"
|
||||
|
||||
class Word
|
||||
{
|
||||
public:
|
||||
Word(wstring &str, int top, int left, int bottom, int right);
|
||||
|
||||
void AddCoordinates(int top, int left, int bottom, int right);
|
||||
void AddCoordinates(QList<Coordinates> cList);
|
||||
QList<Coordinates> coordinates();
|
||||
|
||||
QString FormatCoordinatesToExport();
|
||||
|
||||
QString word();
|
||||
void appendToWord(QString &append, bool removeLastCharacter);
|
||||
|
||||
private:
|
||||
void RemoveFirstCharacter(QString charset);
|
||||
void RemoveLastCharacter(QString charset);
|
||||
void RemoveThirdPersonsCharacter();
|
||||
|
||||
private:
|
||||
QString m_word;
|
||||
QList<Coordinates> m_coordinates;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[database]
|
||||
server=localhost ;url for the database
|
||||
port=3306
|
||||
database=socialhose
|
||||
uid=root
|
||||
pwd=aq19911
|
||||
|
||||
[page settings]
|
||||
processing=5
|
||||
@@ -0,0 +1,822 @@
|
||||
/*
|
||||
* This sample code is a part of the IRIS iDRS library.
|
||||
* Copyright (C) 2006-2009 Image Recognition Integrated Systems
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is merely intended as a supplement to the iDRS reference and the electronic documentation provided with the library.
|
||||
*
|
||||
*/
|
||||
#include "idrs_config.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int ReadFileSetupInfo ( const char * strFileName, IDRS_FILE_SETUP_INFO & theFileSetupInfo )
|
||||
{
|
||||
FILE * hFile;
|
||||
size_t sz;
|
||||
char c;
|
||||
|
||||
hFile = fopen ( strFileName, "rb" );
|
||||
if ( hFile == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
sz = fread ( & theFileSetupInfo, sizeof ( IDRS_FILE_SETUP_INFO ), 1, hFile );
|
||||
fread ( & c, sizeof ( char ), 1, hFile );
|
||||
|
||||
if (( sz == 1 ) && ( feof ( hFile ) != 0 ))
|
||||
{
|
||||
fclose ( hFile );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose ( hFile );
|
||||
memset ( & theFileSetupInfo, 0, sizeof ( IDRS_FILE_SETUP_INFO ));
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int WriteFileSetupInfo ( const char * strFileName, const IDRS_FILE_SETUP_INFO & theFileSetupInfo )
|
||||
{
|
||||
FILE * hFile;
|
||||
|
||||
hFile = fopen ( strFileName, "wb" );
|
||||
if ( hFile == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwrite ( & theFileSetupInfo, sizeof ( IDRS_FILE_SETUP_INFO ), 1, hFile );
|
||||
fclose ( hFile );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int CallSetup ( IDRS_FILE_SETUP_INFO & theFileSetupInfo )
|
||||
{
|
||||
IDRS_CHAR strModuleName [ IDRS_MAX_PATH ];
|
||||
|
||||
try
|
||||
{
|
||||
if ( theFileSetupInfo.bLoadDRS )
|
||||
{
|
||||
sprintf ( strModuleName, "IDRS_MODULE_DRS" );
|
||||
cout << "Loading " << strModuleName << endl;
|
||||
CIDRS::SetupModule ( IDRS_MODULE_DRS, & theFileSetupInfo.aLicenseDRS, sizeof ( IDRS_LICENSE_DRS ));
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.bLoadPrepro )
|
||||
{
|
||||
sprintf ( strModuleName, "IDRS_MODULE_PREPRO" );
|
||||
cout << "Loading " << strModuleName << endl;
|
||||
CIDRS::SetupModule ( IDRS_MODULE_PREPRO, & theFileSetupInfo.aLicensePrepro, sizeof ( IDRS_LICENSE_PREPRO ));
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.bLoadImageFile )
|
||||
{
|
||||
sprintf ( strModuleName, "IDRS_MODULE_IMAGE_FILE" );
|
||||
cout << "Loading " << strModuleName << endl;
|
||||
CIDRS::SetupModule ( IDRS_MODULE_IMAGE_FILE, & theFileSetupInfo.aLicenseImageFile, sizeof ( IDRS_LICENSE_IMAGE_FILE ));
|
||||
}
|
||||
}
|
||||
catch ( IDRSException & aIDRSException )
|
||||
{
|
||||
cout << "\tAn error occured in the iDRS." << endl;
|
||||
cout << "\tCode " << aIDRSException.m_code << endl;
|
||||
cout << "\tFile " << aIDRSException.m_strSrcFile << endl;
|
||||
cout << "\tLine " << aIDRSException.m_uiSrcLine << endl;
|
||||
|
||||
cout << "\tERROR - Setting up "<< strModuleName << " failed.";
|
||||
switch ( aIDRSException.m_code )
|
||||
{
|
||||
case IDRS_ERROR_DRS_INVALID_KEY:
|
||||
case IDRS_ERROR_BARCODE_INVALID_KEY:
|
||||
case IDRS_ERROR_PREPRO_INVALID_KEY:
|
||||
case IDRS_ERROR_FMT_INVALID_KEY:
|
||||
case IDRS_ERROR_IMAGE_FILE_INVALID_KEY:
|
||||
cout << " Please check your software keys." << endl;
|
||||
break;
|
||||
|
||||
default:
|
||||
cout << " Please check your settings and the license'type." << endl;
|
||||
break;
|
||||
}
|
||||
CIDRS::Unload ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int SetupIDRS ( IDRS_FILE_SETUP_INFO & theFileSetupInfo )
|
||||
{
|
||||
IDRS_CHAR
|
||||
c, str [ IDRS_MAX_PATH ], strExtensionName [ IDRS_MAX_PATH ];
|
||||
IDRS_BOOL bSetupFromSoftwareKeysFile;
|
||||
IDRS_UINT uiExtensionId;
|
||||
int iRet;
|
||||
#ifdef IDRS_OS_WIN32
|
||||
IDRS_CHAR strDrive [ IDRS_MAX_PATH ], strDir [ IDRS_MAX_PATH ], strCurrentDir [ IDRS_MAX_PATH ];
|
||||
IDRS_CHAR strSoftwareKeysFile [] = ".//idrs_software_keys_14.inf";
|
||||
|
||||
//Temporary change the current directory so strSoftwareKeysFile relative path is computed the expected way
|
||||
GetModuleFileNameA ( ::GetModuleHandle ( NULL ), str, IDRS_MAX_PATH );
|
||||
_splitpath_s ( str, strDrive, IDRS_MAX_PATH, strDir, IDRS_MAX_PATH, 0, 0, 0, 0 );
|
||||
_makepath_s ( str, IDRS_MAX_PATH, strDrive, strDir, 0, 0);
|
||||
|
||||
GetCurrentDirectoryA ( IDRS_MAX_PATH, strCurrentDir );
|
||||
SetCurrentDirectoryA ( str );
|
||||
#else /* IDRS_OS_WIN32 */
|
||||
IDRS_CHAR strSoftwareKeysFile [] = "idrs_software_keys14.inf";
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
|
||||
/*
|
||||
cout << "The SetupIDRS function illustrates how to setup the iDRS." << endl;
|
||||
cout << "Its full source code is available in the idrs_config.cpp file of the samples." << endl;
|
||||
cout << endl;
|
||||
cout << "iDRS is composed of many different modules, modular to your project requirements." << endl;
|
||||
cout << "During this step of the sample application, you will be asked all the information needed to setup the iDRS:" << endl;
|
||||
cout << "- your license type" << endl;
|
||||
cout << "- the modules and the extensions you want to load" << endl;
|
||||
cout << "- the corresponding software keys";
|
||||
cout << endl;
|
||||
cout << "At the end of the application, if SetupIDRS succeeds, the application will propose you to save the settings to the " << strSoftwareKeysFile;
|
||||
cout << " file. So the next time you run a sample you won't have to re-enter these information." << endl;
|
||||
cout << endl;
|
||||
*/
|
||||
|
||||
//*
|
||||
bSetupFromSoftwareKeysFile = IDRS_FALSE;
|
||||
|
||||
if ( ReadFileSetupInfo ( strSoftwareKeysFile, theFileSetupInfo ) == 0 )
|
||||
{
|
||||
/*
|
||||
cout << "SetupIDRS has detected an existing " << strSoftwareKeysFile << " file.";
|
||||
cout << "Do you want to setup iDRS with the information contained in this file (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');*/
|
||||
c = 'y';
|
||||
|
||||
bSetupFromSoftwareKeysFile = ( c == 'y' || c == 'Y' );
|
||||
}
|
||||
//*/
|
||||
if ( ! bSetupFromSoftwareKeysFile )
|
||||
{
|
||||
memset ( & theFileSetupInfo, 0, sizeof ( IDRS_FILE_SETUP_INFO ));
|
||||
|
||||
/*
|
||||
* Getting the information from the user
|
||||
*/
|
||||
cout << "License type selection" << endl;
|
||||
cout << "2 - IDRS_LICENSE_CUSTOM_SOFTWARE - Custom software" << endl;
|
||||
cout << "4 - IDRS_LICENSE_SOFTWARE - Software key protection" << endl;
|
||||
cout << "Please enter your iDRS license type:" << endl;
|
||||
do
|
||||
{
|
||||
cin >> str;
|
||||
cout << endl;
|
||||
} while(strcmp(str, "2") != 0 && strcmp(str, "4") != 0);
|
||||
cout << endl;
|
||||
theFileSetupInfo.ltLicenseType = ( IDRS_LICENSE_TYPE ) atoi ( str );
|
||||
|
||||
switch ( theFileSetupInfo.ltLicenseType )
|
||||
{
|
||||
case IDRS_LICENSE_CUSTOM_SOFTWARE:
|
||||
case IDRS_LICENSE_SOFTWARE:
|
||||
cout << "SetupIDRS will ask you for your software keys." << endl;
|
||||
break;
|
||||
|
||||
default:
|
||||
cout << "\tERROR - Unknown license type." << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* IDRS_MODULE_DRS
|
||||
*/
|
||||
|
||||
cout << "IDRS_MODULE_DRS" << endl;
|
||||
|
||||
cout << "IDRS_MODULE_DRS is the ocr/icr engine." << endl;
|
||||
cout << "Do you have a license for the IDRS_MODULE_DRS module (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadDRS = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadDRS )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_DRS module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicenseDRS, 0, sizeof ( IDRS_LICENSE_DRS ));
|
||||
theFileSetupInfo.aLicenseDRS.ltLicenseType = theFileSetupInfo.ltLicenseType;
|
||||
|
||||
cout << "Please enter IDRS_MODULE_DRS software key:" << endl;
|
||||
|
||||
cin.ignore ();
|
||||
|
||||
cin.getline ( theFileSetupInfo.aLicenseDRS.strDRSSoftwareKey, IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
|
||||
for ( uiExtensionId = 0; uiExtensionId < IDRS_DRS_EXTENSION_COUNT; uiExtensionId ++ )
|
||||
{
|
||||
switch ( uiExtensionId )
|
||||
{
|
||||
case IDRS_DRS_EXTENSION_ASIAN:
|
||||
cout << "IDRS_DRS_EXTENSION_ASIAN extends the OCR languages with for 4 additional languages:" << endl;
|
||||
cout << "- Traditional Chinese" << endl;
|
||||
cout << "- Simplified Chinese" << endl;
|
||||
cout << "- Japanese" << endl;
|
||||
cout << "- Korean" << endl;
|
||||
sprintf ( strExtensionName, "IDRS_DRS_EXTENSION_ASIAN" );
|
||||
break;
|
||||
|
||||
case IDRS_DRS_EXTENSION_HEBREW:
|
||||
cout << "IDRS_DRS_EXTENSION_HEBREW extends the OCR languages with the Hebrew language." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_DRS_EXTENSION_HEBREW" );
|
||||
break;
|
||||
|
||||
#ifndef IDRS_OS_MACINTOSH
|
||||
case IDRS_DRS_EXTENSION_BANKING_FONTS:
|
||||
cout << "IDRS_DRS_EXTENSION_BANKING_FONTS allows to recognize the following banking fonts:" << endl;
|
||||
cout << "- OCR-A" << endl;
|
||||
cout << "- OCR-B" << endl;
|
||||
cout << "- E13B" << endl;
|
||||
cout << "- CMC-7" << endl;
|
||||
sprintf ( strExtensionName, "IDRS_DRS_EXTENSION_BANKING_FONTS" );
|
||||
break;
|
||||
#endif /* ifndef IDRS_OS_MACINTOSH */
|
||||
|
||||
case IDRS_DRS_EXTENSION_ICR:
|
||||
cout << "IDRS_DRS_EXTENSION_ICR is the standard ICR extension." << endl;
|
||||
cout << "The IRIS Intelligent Character Recognition (ICR) engine allows you to recognize all handwritten characters based on the Latin";
|
||||
cout << " alphabet." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_DRS_EXTENSION_ICR" );
|
||||
break;
|
||||
|
||||
#ifndef IDRS_OS_MACINTOSH
|
||||
case IDRS_DRS_EXTENSION_ARABIC:
|
||||
cout << "IDRS_DRS_EXTENSION_ARABIC extends the OCR languages with the Arabic and Farsi languages." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_DRS_EXTENSION_ARABIC" );
|
||||
break;
|
||||
#endif /* ifndef IDRS_OS_MACINTOSH */
|
||||
|
||||
default:
|
||||
strExtensionName [ 0 ] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( strExtensionName [ 0 ] == 0 )
|
||||
{
|
||||
theFileSetupInfo.aLicenseDRS.xbExtensionFlags [ uiExtensionId ] = IDRS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Do you have a license for the " << strExtensionName << " extension (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.aLicenseDRS.xbExtensionFlags [ uiExtensionId ] = ( c == 'y' || c == 'Y' );
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.aLicenseDRS.xbExtensionFlags [ uiExtensionId ] )
|
||||
{
|
||||
cout << "Please enter " << strExtensionName << " software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseDRS.xstrExtensionSoftwareKey [ uiExtensionId ], IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
#ifdef IDRS_OS_WIN32
|
||||
do
|
||||
{
|
||||
cout << "Please enter the path to the OCR resource directory (the directory containing the .ytr files)" << endl;
|
||||
cout << "(Just enter '#' for C:\\Program Files\\I.R.I.S. SA\\iDRS\\resources)" << endl;
|
||||
fflush ( stdin );
|
||||
gets ( theFileSetupInfo.aLicenseDRS.strOCRResourcesPath );
|
||||
|
||||
if ( strcmp ( theFileSetupInfo.aLicenseDRS.strOCRResourcesPath, "#" ) == 0 )
|
||||
{
|
||||
sprintf ( theFileSetupInfo.aLicenseDRS.strOCRResourcesPath, "C:\\Program Files\\I.R.I.S. SA\\iDRS\\resources" );
|
||||
}
|
||||
|
||||
if ( strlen ( theFileSetupInfo.aLicenseDRS.strOCRResourcesPath ))
|
||||
{
|
||||
sprintf ( str, "%s\\eng.ytr", theFileSetupInfo.aLicenseDRS.strOCRResourcesPath );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf ( str, "eng.ytr" );
|
||||
}
|
||||
|
||||
if ( _access ( str, 0 ) != 0 )
|
||||
{
|
||||
cout << "\tWARNING - The english lexicon file " << str << " does not exist." << endl;
|
||||
cout << "Maybe you made a mistake when typing the path to the OCR resource directory." << endl;
|
||||
cout << "Double check the path to the OCR resource directory." << endl;
|
||||
cout << "Do you want to continue anyway or do you want to re-enter the path to the OCR resource directory (c/r)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'c' && c != 'C' && c != 'r' && c != 'R');
|
||||
}
|
||||
else
|
||||
{
|
||||
c = 'c';
|
||||
}
|
||||
}
|
||||
while ( c != 'c' && c != 'C' );
|
||||
#else /* IDRS_OS_WIN32 */
|
||||
theFileSetupInfo.aLicenseDRS.strOCRResourcesPath [ 0 ] = 0;
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
}
|
||||
|
||||
#ifdef IDRS_OS_WIN32
|
||||
/*
|
||||
* IDRS_MODULE_BCODE
|
||||
*/
|
||||
|
||||
cout << "IDRS_MODULE_BCODE" << endl;
|
||||
|
||||
cout << "IDRS_MODULE_BCODE is the bar code recognition engine." << endl;
|
||||
cout << "The bar code module will identify barcodes located anywhere on the page." << endl;
|
||||
cout << "The barcodes can be used as separators and their content can be used for renaming files for example." << endl;
|
||||
cout << "Do you have a license for the IDRS_MODULE_BCODE module (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadBCode = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadBCode )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_BCODE module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicenseBCode, 0, sizeof ( IDRS_LICENSE_BCODE ));
|
||||
theFileSetupInfo.aLicenseBCode.ltLicenseType = theFileSetupInfo.ltLicenseType;
|
||||
|
||||
cout << "Please enter IDRS_MODULE_BCODE software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseBCode.strBCodeSoftwareKey, IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
|
||||
for ( uiExtensionId = 0; uiExtensionId < IDRS_BCODE_EXTENSION_COUNT; uiExtensionId ++ )
|
||||
{
|
||||
switch ( uiExtensionId )
|
||||
{
|
||||
case IDRS_BCODE_EXTENSION_PDF417:
|
||||
cout << "The IDRS_BCODE_EXTENSION_PDF417 extension offers the recognition of the PDF 417 barcodes." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_BCODE_EXTENSION_PDF417" );
|
||||
break;
|
||||
|
||||
case IDRS_BCODE_EXTENSION_QRCODE:
|
||||
cout << "The IDRS_BCODE_EXTENSION_QRCODE extension offers the recognition of the QR barcodes." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_BCODE_EXTENSION_QRCODE" );
|
||||
break;
|
||||
|
||||
case IDRS_BCODE_EXTENSION_ENGINE_EVO_I:
|
||||
cout << "The IDRS_BCODE_EXTENSION_ENGINE_EVO_I extension offers the possibility of using an addditional barcode" << endl;
|
||||
cout << "engine, for better performances." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_BCODE_EXTENSION_ENGINE_EVO_I" );
|
||||
break;
|
||||
|
||||
case IDRS_BCODE_EXTENSION_DATAMATRIX:
|
||||
cout << "The IDRS_BCODE_EXTENSION_DATAMATRIX extension offers the recognition of the DataMatrix barcodes." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_BCODE_EXTENSION_DATAMATRIX" );
|
||||
break;
|
||||
|
||||
default:
|
||||
strExtensionName [ 0 ] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( strExtensionName [ 0 ] == 0 )
|
||||
{
|
||||
theFileSetupInfo.aLicenseBCode.xbExtensionFlags [ uiExtensionId ] = IDRS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Do you have a license for the " << strExtensionName << " extension (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.aLicenseBCode.xbExtensionFlags [ uiExtensionId ] = ( c == 'y' || c == 'Y' );
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.aLicenseBCode.xbExtensionFlags [ uiExtensionId ] )
|
||||
{
|
||||
cout << "Please enter " << strExtensionName << " software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseBCode.xstrExtensionSoftwareKey [ uiExtensionId ], IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
|
||||
|
||||
/*
|
||||
* IDRS_MODULE_PREPRO
|
||||
*/
|
||||
|
||||
cout << "IDRS_MODULE_PREPRO" << endl;
|
||||
|
||||
cout << "IDRS_MODULE_PREPRO is the standard image pre-processing module." << endl;
|
||||
cout << "Before doing the OCR, the images may need to be optimized for the OCR process. This is done by different pre-processing functions." << endl;
|
||||
cout << "The IDRS_MODULE_PREPRO module allows you to clean-up the images for optimized OCR such as deskew, despeckle, binarize, etc." << endl;
|
||||
cout << "Do you have a license for the IDRS_MODULE_PREPRO module (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadPrepro = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadPrepro )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_PREPRO module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicensePrepro, 0, sizeof ( IDRS_LICENSE_PREPRO ));
|
||||
theFileSetupInfo.aLicensePrepro.ltLicenseType = theFileSetupInfo.ltLicenseType;
|
||||
|
||||
cout << "Please enter IDRS_MODULE_PREPRO software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicensePrepro.strPreproSoftwareKey, IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
|
||||
for ( uiExtensionId = 0; uiExtensionId < IDRS_PREPRO_EXTENSION_COUNT; uiExtensionId ++ )
|
||||
{
|
||||
switch ( uiExtensionId )
|
||||
{
|
||||
#ifndef IDRS_OS_MACINTOSH
|
||||
case IDRS_PREPRO_EXTENSION_ADVANCED_PREPRO:
|
||||
cout << "IDRS_PREPRO_EXTENSION_ADVANCED_PREPRO is the advanced pre-processing extension." << endl;
|
||||
cout << "This extension allows to do black border removal, line removal, advanced despeckling, color conversion, etc." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_PREPRO_EXTENSION_ADVANCED_PREPRO" );
|
||||
break;
|
||||
#endif /* ifndef IDRS_OS_MACINTOSH */
|
||||
|
||||
default:
|
||||
strExtensionName [ 0 ] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( strExtensionName [ 0 ] == 0 )
|
||||
{
|
||||
theFileSetupInfo.aLicensePrepro.xbExtensionFlags [ uiExtensionId ] = IDRS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Do you have a license for the " << strExtensionName << " extension (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.aLicensePrepro.xbExtensionFlags [ uiExtensionId ] = ( c == 'y' || c == 'Y' );
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.aLicensePrepro.xbExtensionFlags [ uiExtensionId ] )
|
||||
{
|
||||
cout << "Please enter " << strExtensionName << " software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicensePrepro.xstrExtensionSoftwareKey [ uiExtensionId ], IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IDRS_OS_WIN32
|
||||
/*
|
||||
* IDRS_MODULE_FMT
|
||||
*/
|
||||
|
||||
cout << "IDRS_MODULE_FMT" << endl;
|
||||
|
||||
cout << "IDRS_MODULE_FMT is the formatting module." << endl;
|
||||
cout << "Once the recognition of the document has been done, you might still need to generate an output file." << endl;
|
||||
cout << "This is done by the formatting module." << endl;
|
||||
cout << "Do you have a license for the IDRS_MODULE_FMT module (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadFmt = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadFmt )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_FMT module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicenseFmt, 0, sizeof ( IDRS_LICENSE_FMT ));
|
||||
theFileSetupInfo.aLicenseFmt.ltLicenseType = theFileSetupInfo.ltLicenseType;
|
||||
|
||||
cout << "Please enter IDRS_MODULE_FMT software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseFmt.strFmtSoftwareKey, IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
|
||||
for ( uiExtensionId = 0; uiExtensionId < IDRS_FMT_EXTENSION_COUNT; uiExtensionId ++ )
|
||||
{
|
||||
switch ( uiExtensionId )
|
||||
{
|
||||
case IDRS_FMT_IHQC_EXTENSION:
|
||||
cout << "IDRS_FMT_IHQC_EXTENSION is the intelligent High Quality compression extension." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_FMT_IHQC_EXTENSION" );
|
||||
break;
|
||||
|
||||
default:
|
||||
strExtensionName [ 0 ] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( strExtensionName [ 0 ] == 0 )
|
||||
{
|
||||
theFileSetupInfo.aLicenseFmt.xbExtensionFlags [ uiExtensionId ] = IDRS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Do you have a license for the " << strExtensionName << " extension (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.aLicenseFmt.xbExtensionFlags [ uiExtensionId ] = ( c == 'y' || c == 'Y' );
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.aLicenseFmt.xbExtensionFlags [ uiExtensionId ] )
|
||||
{
|
||||
cout << "Please enter " << strExtensionName << " software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseFmt.xstrExtensionSoftwareKey [ uiExtensionId ], IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
|
||||
/*
|
||||
* IDRS_MODULE_IMAGE_FILE
|
||||
*/
|
||||
|
||||
cout << "IDRS_MODULE_IMAGE_FILE" << endl;
|
||||
|
||||
cout << "IDRS_MODULE_IMAGE_FILE is the iDRS imaging module." << endl;
|
||||
cout << "This module allows you to open the most known input formats including TIFF G4 and BMP." << endl;
|
||||
cout << "Do you have a license for the IDRS_MODULE_IMAGE_FILE module (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadImageFile = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadImageFile )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_IMAGE_FILE module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicenseImageFile, 0, sizeof ( IDRS_LICENSE_IMAGE_FILE ));
|
||||
theFileSetupInfo.aLicenseImageFile.ltLicenseType = theFileSetupInfo.ltLicenseType;
|
||||
|
||||
cout << "Please enter IDRS_MODULE_IMAGE_FILE software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseImageFile.strImageFileSoftwareKey, IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
|
||||
for ( uiExtensionId = 0; uiExtensionId < IDRS_IMAGE_FILE_EXTENSION_COUNT; uiExtensionId ++ )
|
||||
{
|
||||
switch ( uiExtensionId )
|
||||
{
|
||||
case IDRS_FILE_EXTENSION_JPEG:
|
||||
cout << "IDRS_FILE_EXTENSION_JPEG is the JPEG extension." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_FILE_EXTENSION_JPEG" );
|
||||
break;
|
||||
|
||||
default:
|
||||
strExtensionName [ 0 ] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( strExtensionName [ 0 ] == 0 )
|
||||
{
|
||||
theFileSetupInfo.aLicenseImageFile.xbExtensionFlags [ uiExtensionId ] = IDRS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Do you have a license for the " << strExtensionName << " extension (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.aLicenseImageFile.xbExtensionFlags [ uiExtensionId ] = ( c == 'y' || c == 'Y' );
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.aLicenseImageFile.xbExtensionFlags [ uiExtensionId ] )
|
||||
{
|
||||
cout << "Please enter " << strExtensionName << " software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseImageFile.xstrExtensionSoftwareKey [ uiExtensionId ], IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IDRS_OS_WIN32
|
||||
/*
|
||||
* LEADTOOLS
|
||||
*/
|
||||
|
||||
cout << "LEADTOOLS" << endl;
|
||||
cout << "LEADTOOLS is an external imaging SDK." << endl;
|
||||
cout << "The iDRS can use the raster imaging features of leadtools to extend its imaging functionalities." << endl;
|
||||
cout << "Do you have a license for Leadtools raster imaging (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadLeadtools = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadLeadtools )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_LEADTOOLS module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicenseLeadtools, 0, sizeof ( IDRS_LICENSE_LEADTOOLS ));
|
||||
|
||||
cout << endl;
|
||||
|
||||
theFileSetupInfo.aLicenseLeadtools.uiMajorVersionIdentifier = 15;
|
||||
theFileSetupInfo.aLicenseLeadtools.uiMinorVersionIdentifier = 0;
|
||||
|
||||
for ( uiExtensionId = 0; uiExtensionId < IDRS_LEADTOOLS_EXTENSION_COUNT; uiExtensionId ++ )
|
||||
{
|
||||
switch ( uiExtensionId )
|
||||
{
|
||||
case IDRS_LEADTOOLS_EXTENSION_JPEG2000:
|
||||
cout << "IDRS_LEADTOOLS_EXTENSION_JPEG2000 is the JPEG 2000 extension." << endl;
|
||||
sprintf ( strExtensionName, "IDRS_LEADTOOLS_EXTENSION_JPEG2000" );
|
||||
break;
|
||||
|
||||
default:
|
||||
strExtensionName [ 0 ] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( strExtensionName [ 0 ] == 0 )
|
||||
{
|
||||
theFileSetupInfo.aLicenseLeadtools.xbExtensionFlags [ uiExtensionId ] = IDRS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Do you have a license for the " << strExtensionName << " extension (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.aLicenseLeadtools.xbExtensionFlags [ uiExtensionId ] = ( c == 'y' || c == 'Y' );
|
||||
}
|
||||
|
||||
if ( theFileSetupInfo.aLicenseLeadtools.xbExtensionFlags [ uiExtensionId ] )
|
||||
{
|
||||
cout << "Please enter " << strExtensionName << " software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseLeadtools.xstrExtensionSoftwareKey [ uiExtensionId ], IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
|
||||
#ifdef IDRS_OS_WIN32
|
||||
/*
|
||||
* IDRS_MODULE_FINGERPRINT
|
||||
*/
|
||||
|
||||
cout << "IDRS_MODULE_FINGERPRINT" << endl;
|
||||
|
||||
cout << "IDRS_MODULE_FINGERPRINT is the fingerprint module." << endl;
|
||||
cout << "Do you have a license for the IDRS_MODULE_FINGERPRINT module (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadFingerprint = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadFingerprint )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_FINGERPRINT module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicenseFingerprint, 0, sizeof ( IDRS_LICENSE_FINGERPRINT ));
|
||||
theFileSetupInfo.aLicenseFingerprint.ltLicenseType = theFileSetupInfo.ltLicenseType;
|
||||
|
||||
cout << "Please enter IDRS_MODULE_FINGERPRINT software key:" << endl;
|
||||
cin.ignore ();
|
||||
cin.getline ( theFileSetupInfo.aLicenseFingerprint.strFingerprintSoftwareKey, IDRS_LICENSE_MAX_SIZE );
|
||||
cout << endl;
|
||||
}
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
|
||||
#ifdef IDRS_OS_WIN32
|
||||
/*
|
||||
* Snowbound
|
||||
*/
|
||||
|
||||
cout << "Snowbound" << endl;
|
||||
cout << "Snowbound is an external imaging SDK." << endl;
|
||||
cout << "The iDRS can use the imaging features of Snowbound to extend its imaging functionalities." << endl;
|
||||
cout << "Do you have a license for Snowbound SDK (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
theFileSetupInfo.bLoadSnowbound = ( c == 'y' || c == 'Y' );
|
||||
|
||||
if ( theFileSetupInfo.bLoadSnowbound )
|
||||
{
|
||||
cout << "Getting information for the IDRS_MODULE_SNOWBOUND module." << endl;
|
||||
|
||||
memset ( & theFileSetupInfo.aLicenseSnowbound, 0, sizeof ( IDRS_MODULE_SNOWBOUND ));
|
||||
|
||||
cout << endl;
|
||||
|
||||
theFileSetupInfo.aLicenseSnowbound.uiMajorVersionIdentifier = 1;
|
||||
theFileSetupInfo.aLicenseSnowbound.uiMinorVersionIdentifier = 0;
|
||||
}
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
|
||||
|
||||
}
|
||||
iRet = CallSetup ( theFileSetupInfo );
|
||||
|
||||
if ( iRet == 0 && ! bSetupFromSoftwareKeysFile )
|
||||
{
|
||||
/*
|
||||
* Save the information to a file.
|
||||
*/
|
||||
|
||||
cout << "The setup was successfull." << endl;
|
||||
cout << "This sample can save the information you enter to the " << strSoftwareKeysFile;
|
||||
cout << " file, so you won't have to re-enter the information next time you'll run this application." << endl;
|
||||
cout << "Do you want to save the information you entered to the " << strSoftwareKeysFile << " file (y/n)?" << endl;
|
||||
do
|
||||
{
|
||||
cin >> c;
|
||||
cout << endl;
|
||||
} while(c != 'y' && c != 'Y' && c != 'n' && c != 'N');
|
||||
|
||||
if ( c == 'y' || c == 'Y' )
|
||||
{
|
||||
WriteFileSetupInfo ( strSoftwareKeysFile, theFileSetupInfo );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IDRS_OS_WIN32
|
||||
//Restore the current directory
|
||||
SetCurrentDirectoryA ( strCurrentDir );
|
||||
#endif /* IDRS_OS_WIN32 */
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This sample code is a part of the IRIS iDRS library.
|
||||
* Copyright (C) 2006-2009 Image Recognition Integrated Systems
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is merely intended as a supplement to the iDRS reference and the electronic documentation provided with the library.
|
||||
*
|
||||
*/
|
||||
#ifndef _idrs_config_h_
|
||||
#define _idrs_config_h_
|
||||
|
||||
#ifndef __FUNCTION__
|
||||
#define __FUNCTION__ __FILE__ /* If it is not supported by the compiler, uses the file name */
|
||||
#endif /* __FUNCTION__ */
|
||||
|
||||
#ifdef WIN32
|
||||
#if _MSC_VER < 1300
|
||||
#include <windows.h>
|
||||
#include <fstream.h>
|
||||
#else /* _MSC_VER < 1300 */
|
||||
#if _MSC_VER >= 1400
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
#endif /* _MSC_VER < 1300 */
|
||||
#include "io.h"
|
||||
#else /* WIN32 */
|
||||
#if defined(macintosh) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
#else /* defined(macintosh) || (defined(__APPLE__) && defined(__MACH__)) */
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
#endif /* defined(macintosh) || (defined(__APPLE__) && defined(__MACH__)) */
|
||||
#endif /* WIN32 */
|
||||
|
||||
|
||||
#include <idrs.h>
|
||||
using namespace IDRS;
|
||||
|
||||
|
||||
/**
|
||||
* A structure containing the information needed to setup iDRS in the sample application.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
IDRS_LICENSE_TYPE ltLicenseType;
|
||||
IDRS_BOOL bLoadDRS;
|
||||
IDRS_LICENSE_DRS aLicenseDRS;
|
||||
IDRS_BOOL bLoadBCode;
|
||||
IDRS_LICENSE_BCODE aLicenseBCode;
|
||||
IDRS_BOOL bLoadPrepro;
|
||||
IDRS_LICENSE_PREPRO aLicensePrepro;
|
||||
IDRS_BOOL bLoadFmt;
|
||||
IDRS_LICENSE_FMT aLicenseFmt;
|
||||
IDRS_BOOL bLoadImageFile;
|
||||
IDRS_LICENSE_IMAGE_FILE aLicenseImageFile;
|
||||
IDRS_BOOL bLoadLeadtools;
|
||||
IDRS_LICENSE_LEADTOOLS aLicenseLeadtools;
|
||||
IDRS_BOOL bLoadFingerprint;
|
||||
IDRS_LICENSE_FINGERPRINT aLicenseFingerprint;
|
||||
IDRS_BOOL bLoadSnowbound;
|
||||
IDRS_LICENSE_SNOWBOUND aLicenseSnowbound;
|
||||
} IDRS_FILE_SETUP_INFO;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int SetupIDRS ( IDRS_FILE_SETUP_INFO & theFileSetupInfo );
|
||||
}
|
||||
|
||||
|
||||
#endif /* _idrs_config_h_ */
|
||||
@@ -0,0 +1,19 @@
|
||||
//#include "OCREngineService.h"
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
#include "OurOCREngine.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8") );
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
//OCREngineService service(argc, argv);
|
||||
OurOCREngine m_ocrEngine;
|
||||
|
||||
m_ocrEngine.Initalize();
|
||||
Start(m_ocrEngine);
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user