initial import

This commit is contained in:
Mo Elzubeir
2022-12-13 09:18:00 -06:00
commit d2d561810c
322 changed files with 1147261 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
/************************************************************************
* $Id: Coordinates.cpp 587 2010-05-28 22:34:52Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2010-05-29 02:34:52 +0400 (Sat, 29 May 2010) $
* $Author: elzubeir $
* $Revision: 587 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/Coordinates.cpp $
*
************************************************************************/
#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;
}
+76
View File
@@ -0,0 +1,76 @@
/************************************************************************
* $Id: Coordinates.h 587 2010-05-28 22:34:52Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2010-05-29 02:34:52 +0400 (Sat, 29 May 2010) $
* $Author: elzubeir $
* $Revision: 587 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/Coordinates.h $
*
************************************************************************/
#pragma once
#include <iostream>
using namespace std;
//! \class Coordinates
//! a coordinates class to hold coordinates in format of (top/left) (bottom/right)
class Coordinates
{
public:
//! \fn Coordinates()
//! default constructor
//! \param[in] top: top value of coordinate
//! \param[in] left: left value of coordinate
//! \param[in] bottom: bottom value of coordinate
//! \param[in] right: right value of coordinate
//! \author elzubeir
Coordinates(int top, int left, int bottom, int right);
bool operator == (Coordinates const & coor);
//! \fn top()
//! return the top of the coordinates
//! \author elzubeir
int top();
//! \fn left()
//! return the left of the coordinates
//! \author elzubeir
int left();
//! \fn bottom()
//! return the bottom of the coordinates
//! \author elzubeir
int bottom();
//! \fn right()
//! return the right of the coordinates
//! \author elzubeir
int right();
private:
//! int of top value of coordinate
int m_top;
//! int of left value of coordinate
int m_left;
//! int of bottom value of coordinate
int m_bottom;
//! int of right value of coordinate
int m_right;
};
+261
View File
@@ -0,0 +1,261 @@
<?xml version="1.0" encoding="windows-1256"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="emsOCR"
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"
PreprocessorDefinitions="_WINDOWS;WIN32;UNICODE;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 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="2"
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=".\emsocr.cpp"
>
</File>
<File
RelativePath=".\emsocrdialog.cpp"
>
</File>
<File
RelativePath=".\idrs_config.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\moc_emsocrdialog.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=".\emsocr.h"
>
</File>
<File
RelativePath=".\emsocrdialog.h"
>
</File>
<File
RelativePath=".\idrs_config.h"
>
</File>
<File
RelativePath=".\Tag.h"
>
</File>
<File
RelativePath=".\ui_emsocrdialog.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>
+51
View File
@@ -0,0 +1,51 @@
/************************************************************************
* $Id: Tag.cpp 618 2010-12-21 01:16:45Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2010-12-21 05:16:45 +0400 (Tue, 21 Dec 2010) $
* $Author: elzubeir $
* $Revision: 618 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/Tag.cpp $
*
************************************************************************/
#include "Tag.h"
Tag::Tag(int id, QString coordinates, QString tag): m_id(id), m_coordinates(coordinates), m_tag(tag)
{
}
int Tag::id()
{
return m_id;
}
QString Tag::tag()
{
return m_tag;
}
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);
}
+66
View File
@@ -0,0 +1,66 @@
/************************************************************************
* $Id: Tag.h 618 2010-12-21 01:16:45Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2010-12-21 05:16:45 +0400 (Tue, 21 Dec 2010) $
* $Author: elzubeir $
* $Revision: 618 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/Tag.h $
*
************************************************************************/
#pragma once
#include <QtCore/QtCore>
//! \class Tag
//! a Tag class to hold the tag id and its coordinates
class Tag
{
public:
//! \fn Tag()
//! default constructor
//! \param[in] id: id of the tag
//! \param[in] coordinates: string to hold the coordinates of the tag
//! \author elzubeir
Tag(int id, QString coordinates, QString tag);
//! \fn AddTag()
//! add tag to lit of tags
//! \param[in] list of tags
//! \param[in] tag to be added to the list
//! \author elzubeir
static void AddTag(QList<Tag> &tags, Tag t);
//! \fn id()
//! returns the tag id
//! \author elzubeir
int id();
QString tag();
//! \fn coordinates()
//! returns the coordinates
//! \author elzubeir
QString coordinates();
private:
//! the tag id
int m_id;
QString m_tag;
//! the tag coordinates
QString m_coordinates;
};
+113
View File
@@ -0,0 +1,113 @@
/************************************************************************
* $Id: Word.cpp 578 2010-05-11 23:57:28Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2010-05-12 03:57:28 +0400 (Wed, 12 May 2010) $
* $Author: elzubeir $
* $Revision: 578 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/Word.cpp $
*
************************************************************************/
#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);
m_wordOriginal = m_word;
AddCoordinates(top, left, bottom, right);
m_word.remove("");
m_word.remove("");
//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;
}
QString Word::wordOriginal()
{
return m_wordOriginal;
}
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);
}
+112
View File
@@ -0,0 +1,112 @@
/************************************************************************
* $Id: Word.h 587 2010-05-28 22:34:52Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2010-05-29 02:34:52 +0400 (Sat, 29 May 2010) $
* $Author: elzubeir $
* $Revision: 587 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/Word.h $
*
************************************************************************/
#pragma once
#include <QtCore/QtCore>
#include "Coordinates.h"
//! \class Word
//! a word class to hold words of the page and their coordinates
class Word
{
public:
//! \fn Word()
//! default constructor
//! \param[in] word: the word to be added
//! \param[in] top: top value of word
//! \param[in] left: left value of word
//! \param[in] bottom: bottom value of word
//! \param[in] right: right value of word
//! \author elzubeir
Word(wstring &str, int top, int left, int bottom, int right);
//! \fn AddCoordinates()
//! add coordinates to the word
//! \param[in] top: top value of word
//! \param[in] left: left value of word
//! \param[in] bottom: bottom value of word
//! \param[in] right: right value of word
//! \author elzubeir
void AddCoordinates(int top, int left, int bottom, int right);
//! \fn AddCoordinates()
//! add list of coorindates to the word
//! \param[in] list of coorindates to be added to the word
//! \author elzubeir
void AddCoordinates(QList<Coordinates> cList);
//! \fn coordinates()
//! returns the list of coordinates that belong to this word
//! \author elzubeir
QList<Coordinates> coordinates();
//! \fn FormatCoordinatesToExport()
//! format the coordinates to be exported in the form of top,left,bottom,right:.....
//! \returns a formatted string
//! \author elzubeir
QString FormatCoordinatesToExport();
//! \fn word()
//! returns the word without any extra characters
//! \author elzubeir
QString word();
//! \fn wordOriginal()
//! returns the word without any modifications or deletion of extra characters
//! \author elzubeir
QString wordOriginal();
//! \fn appendToWord()
//! appened the string to the current word
//! \param[in] appened: the part to be added to the current word
//! \param[in] removeLastcharacter: bool if we want to remove the last character
//! \author elzubeir
void appendToWord(QString &append, bool removeLastCharacter);
private:
//! \fn RemoveFirstCharacter()
//! remove the charset from the beginning of the word
//! \param[in] charset: list of characters to be removed if they are at the beginning of the word
//! \author elzubeir
void RemoveFirstCharacter(QString charset);
//! \fn RemoveLastCharacter()
//! remove the charset from the end of the word
//! \param[in] charset: list of characters to be removed if they are at the end of the word
//! \author elzubeir
void RemoveLastCharacter(QString charset);
//! \fn RemoveLastCharacter()
//! remove the 's character from the word
//! \author elzubeir
void RemoveThirdPersonsCharacter();
private:
//! stripped word
QString m_word;
//! original word with all extra characters
QString m_wordOriginal;
//! list of coordinates for the word
QList<Coordinates> m_coordinates;
};
+41
View File
@@ -0,0 +1,41 @@
[ocr]
id=1
[database]
server=localhost ;url for the database
port=3306
database=socialhose
uid=root
pwd=aq19911
[ocr database]
server=localhost ;url for the database
port=3306
database=socialhose
uid=root
pwd=aq19911
[page settings]
processing=5
[debug mode]
debug=on ;on/off
[sleep time]
sleep=100 ;sleep time in seconds
[process arabic] ;on/off
process=on
[preprocessing mode] ;on/off
preprocessing=on
darkborder=on
binarization=on
lineremoval=on
despecklevlaue=10
[processing mode]
skew=on
binarization=on
despeckle=on
despecklevlaue=10
+18
View File
@@ -0,0 +1,18 @@
# -------------------------------------------------
# Project created by QtCreator 2010-03-07T17:36:45
# -------------------------------------------------
QT += sql
TARGET = emsOCR
TEMPLATE = app
SOURCES += main.cpp \
emsocrdialog.cpp \
word.cpp \
emsocr.cpp \
coordinates.cpp \
tag.cpp
HEADERS += emsocrdialog.h \
word.h \
emsocr.h \
coordinates.h \
tag.h
FORMS += emsocrdialog.ui
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OurOCREngine", "..\emsOCR\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
+1572
View File
File diff suppressed because it is too large Load Diff
+368
View File
@@ -0,0 +1,368 @@
/************************************************************************
* $Id: emsocr.h 642 2011-03-02 21:30:33Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2011-03-03 01:30:33 +0400 (Thu, 03 Mar 2011) $
* $Author: elzubeir $
* $Revision: 642 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/emsocr.h $
*
************************************************************************/
#ifndef _emsOCR_H_
#define _emsOCR_H_
#include <idrs.h>
#include <string>
#include <vector>
#include <QtSql/QtSql>
#include <QtCore/QMutex>
#include <QtCore/QThread>
#include "word.h"
#include "tag.h"
using std::string;
using std::vector;
struct PageInfo
{
//! page id
int m_pageName;
//! id of the section pages entry
int m_sectionPagesId;
//! id for the publication
int m_publicationId;
//! type of the publication
int m_publicationType;
//! date of the issue
QString m_publicationDate;
//! publication issue
int m_publicationIssue;
//! country
int m_country;
//! remote path of the page
QString m_remotePath;
//! local path of the page
QString m_localPath;
//! custom name of the page
QString m_customName;
//! is this page arabic
bool m_isArabic;
//! has this page copied
bool m_isCopied;
//! is this page prcessed
bool m_isProcessed;
//! count of keywords found in this page
int m_keywordsCount;
//! processing time of this page
double m_processingTime;
};
//! struct to hold info of tag
struct TagInfo
{
//! id of the tag
int m_id;
//! name of the tag
QString m_name;
};
class emsOCRDialog;
class emsOCR : public QThread
{
public:
//! \fn emsOCR()
//! default constructor of the ocr thread
//! \author elzubeir
emsOCR();
//! \fn ~emsOCR()
//! destructor
//! \author elzubeir
~emsOCR();
//! \fn Initalize()
//! initalizes the thread to work
//! \author elzubeir
bool Initalize();
//! \fn Process()
//! start processing of the pages
//! \author elzubeir
void Process();
//! \fn Stop()
//! stop processing of the pages
//! \author elzubeir
void Stop();
//! \fn SetOCRDialog()
//! set the dialog to work with this thread
//! \param[in] dialog object to set
//! \author elzubeir
void SetOCRDialog(emsOCRDialog *dlg);
private:
//! \fn ReadSettings()
//! This function reads the settings for the application from a config.ini file
//! and populate the member variables with the values read from the ini file
//! \return bool
//! - true if all the values are populated
//! - false otherwise
//! \author elzubeir
bool ReadSettings();
//! \fn ConnectToDatabase()
//! Connect to master and slave databases based on the valuess read from "config.ini" file for the connection strings
//! \return bool
//! - true if the two connections are established correctly
//! - false if error occurs
//! \author elzubeir
bool ConnectToDatabase();
//! \fn GetIssuePath()
//! get the issue path, and drive letter from configuration table in db
//! \author elzubeir
void GetIssuePath();
//! \fn ConstructPagesPath()
//! construct the full paths for the pages in the queue to be processed and getting their values from the db
//! \author elzubeir
void ConstructPagesPath();
//! \fn SectionName()
//! This functions returns the section name for the passed section id
//! \param[in] section integer id of the section to query for its name
//! \return QString the name of the section passed
//! \author elzubeir
QString SectionName(int id);
//! \fn ProcessPage()
//! send ths page to be processed by the ocr
//! \param[in] path of the page to be processed
//! \param[in] is this page arabic page or not
//! \return bool
//! - true if page processed successfully
//! - false if error occurs
//! \author elzubeir
bool ProcessPage(QString &pagePath, bool isArabic);
//! \fn GetPagesToProcess()
//! get the list of pages to be processed by the ocr from the database and add them to the queue
//! \author elzubeir
void GetPagesToProcess();
//! \fn UpdateStatus()
//! update the status of the processed pages to be set to 3 (prcessed)
//! \param[in] page id of the pages to be updated
//! \author elzubeir
void UpdateStatus(int sectionPagesId);
//! \fn ResetUnprocessedPages()
//! reset the status of unprocessed pages
//! \author elzubeir
void ResetUnprocessedPages();
//! \fn SearchTags()
//! search for tags in the processed pages, and return a list of the found tags
//! \param[in] is the page arabic
//! \returns a list of the tags found in the page
//! \author elzubeir
QList<Tag> SearchTags(bool isArabic);
//! \fn GetTagCoordinates()
//! returns a list of the tag's coordinates
//! \param[in] the tag to be searched for
//! \param[in] is this word a multi-word
//! \returns a list of the tags coordinates
//! \author elzubeir
QStringList GetTagCoordinates(QString tag, bool ismultiword);
//! \fn DeleteFromDatabase()
//! deletes pages text, word corrdinats, and tag coordinates from the database
//! \param[in] the tag to be searched for
//! \param[in] is this word a multi-word
//! \returns a list of the tags coordinates
//! \author elzubeir
void DeleteFromDatabase(int id_section_pages);
//! \fn AddToDatabase()
//! adds the tags, words, and coordinates of them to the the database s
//! \param[in] the page to which we should insert the info to
//! \param[in] the list of tags to insert ot db
//! \author elzubeir
void AddToDatabase(PageInfo pi, QList<Tag> &tags);
//! \fn ConvertToSingleBox()
//! converts the mutli-word tag (on the same line) from multiple coordinates to a single coordinate.
//! \param[out] the string holding the coordinates of the multi-word seperated by :, and converted to a single coordinates on the same line
//! \param[in] is this word arabic word
//! \author elzubeir
void ConvertToSingleBox(QString &str, bool isArabic);
//! \fn RemoveDashAndTheFollowingSpace()
//! remove the '- ' from the text, this is used on the english words
//! \param[out] the text with its dashes removed
//! \author elzubeir
void RemoveDashAndTheFollowingSpace(QString &text);
//! \fn GetTagsFromDatabase()
//! get the full list of tags from the database, and saves them in tag list
//! \param[in] are the tags arabic or not
//! \author elzubeir
void GetTagsFromDatabase(bool isArabic);
//! \fn CurrentDateTime()
//! returns the current date and time
//! \author elzubeir
QString CurrentDateTime();
//! \fn ShowException ()
//! show the exception for the IDRS.
//! \param[in] the exception occuring
//! \author elzubeir
void ShowException ( IDRS::IDRSException & theIDRSException );
//! \fn SetPagesInView()
//! set the pages info in the view of the dialog
//! \author elzubeir
void SetPagesInView();
//! \fn ClearPagesInView()
//! clear the pages info from the view of the dialog
//! \author elzubeir
void ClearPagesInView();
//! \fn AddPageToProcessedTable()
//! add the processed page to the list of processed pages in the view
//! \param[in] is this a successful page
//! \param[in] the date to add
//! \param[in] the page name
//! \param[in] the time of processing
//! \param[in] the number of keywords
//! \author elzubeir
void AddPageToProcessedTable(bool successful, QString date, QString page, double time, int keywordCount);
//! \fn IncrementTotalProcssedPages()
//! increment the number of processed pages by 1
//! \author elzubeir
void IncrementTotalProcssedPages();
void UpdateOCRStatus(int id_publication, int id_publication_issue, int latest_page_number);
protected:
//! \fn run()
//! start the thread
//! \author elzubeir
void run();
private:
//! the idrs reader
IDRS::CReader m_reader;
//! list of the pages to be processed
QList<PageInfo> m_pagesToProcess;
//! list of words of the page
QList<Word> m_words;
//! list of tags from the page
QList<TagInfo> m_databaseTags;
//! is the ocr engin ready to be processed
bool m_isReady;
//! database instance
QSqlDatabase m_database;
//! ocr database instance
QSqlDatabase m_ocrdatabase;
//! current page text
QString m_pageText;
//! issues path
QString m_issuePath;
//! database connection values
QString m_databaseName;
QString m_server;
QString m_user;
QString m_password;
int m_port;
//! ocr database connetion values
QString m_ocrdatabaseName;
QString m_ocrserver;
QString m_ocruser;
QString m_ocrpassword;
int m_ocrport;
//! current index of processed pages
int m_currentIndex;
//! start or stop the thread
bool m_start;
//! the dialog to show the results at
emsOCRDialog* m_ocrDialog;
//! debug mode on/off
bool m_debug;
//! sleep time
int m_sleep;
bool m_isAdvancedPreprocessingLoaded;
bool m_processArabic;
bool m_useAPPreprocessing;
bool m_useAPDarkBorderRemoval;
bool m_useAPBinarization;
bool m_useAPLineRemoval;
bool m_useAPDespeckle;
int m_useAPDespeckleValue;
bool m_useSkew;
bool m_useBinarization;
bool m_useLineRemoval;
bool m_useDespeckle;
int m_useDespeckleValue;
int m_id;
};
#endif //_emsOCR_H_
+79
View File
@@ -0,0 +1,79 @@
/************************************************************************
* $Id: emsocrdialog.cpp 648 2011-03-10 03:42:39Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2011-03-10 07:42:39 +0400 (Thu, 10 Mar 2011) $
* $Author: elzubeir $
* $Revision: 648 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/emsocrdialog.cpp $
*
************************************************************************/
#include "emsocrdialog.h"
#include "ui_emsocrdialog.h"
#include <QtGui/QMessageBox>
emsOCRDialog::emsOCRDialog(bool autoStart, QWidget *parent)
: QDialog(parent), ui(new Ui::emsOCRDialog)
{
ui->setupUi(this);
Qt::WindowFlags flags;
flags = Qt::Window | Qt::WindowMinimizeButtonHint;
setWindowFlags( flags );
//m_timer = new QTimer(); //create a timer and connect it's timeout signal to the update slot
//connect(m_timer, SIGNAL(timeout()), this, SLOT(update()));
if (!m_emsOCR.Initalize())
{
QMessageBox::information(this, "Error intializing application", "Error happened in Inializing application, please see the log file for more information on the error happened");
exit(0);
}
m_emsOCR.SetOCRDialog(this);
m_isStarted = false;
connect(&m_emsOCR, SIGNAL(terminated()), this, SLOT(threadTerminated()) );
m_totalNumberOfProcessedPages = 0;
if(autoStart)
on_startButton_clicked();
}
emsOCRDialog::~emsOCRDialog()
{
delete ui;
}
void emsOCRDialog::on_startButton_clicked()
{
if(!m_isStarted)
{
ui->startButton->setText(tr("Stop"));
m_isStarted = true;
m_emsOCR.start();
//QTimer::singleShot( 100, this, SLOT(start()) );
}
else
{
m_emsOCR.Stop();
m_isStarted = false;
ui->startButton->setText(tr("Stopping"));
}
}
void emsOCRDialog::threadTerminated()
{
ui->startButton->setText(tr("Start"));
m_isStarted = false;
}
+79
View File
@@ -0,0 +1,79 @@
/************************************************************************
* $Id: emsocrdialog.h 648 2011-03-10 03:42:39Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2011-03-10 07:42:39 +0400 (Thu, 10 Mar 2011) $
* $Author: elzubeir $
* $Revision: 648 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/emsocrdialog.h $
*
************************************************************************/
#ifndef EMSOCRDIALOG_H
#define EMSOCRDIALOG_H
#include <QtGui/QDialog>
#include "emsocr.h"
namespace Ui
{
class emsOCRDialog;
}
class emsOCRDialog : public QDialog
{
Q_OBJECT
public:
//! \fn emsOCRDialog()
//! default constructor
//! \param[in] parent widget
//! \author elzubeir
emsOCRDialog(bool autoStart = false, QWidget *parent = 0);
//! \fn ~emsOCRDialog()
//! destructor
//! \author elzubeir
~emsOCRDialog();
//! instance to the widget UI class
Ui::emsOCRDialog *ui;
//! total number of processed pages
int m_totalNumberOfProcessedPages;
private:
//! the ocr engine instance
emsOCR m_emsOCR;
//! the timer to run the ocr
QTimer *m_timer;
//! has the thread started
bool m_isStarted;
private slots:
//! \fn on_startButton_clicked()
//! this function starts/stops the ocr engine thread
//! \author elzubeir
void on_startButton_clicked();
//! \fn threadTerminated()
//! this function is called when the ocr engin thread is terminated
//! \author elzubeir
void threadTerminated();
};
#endif // EMSOCRDIALOG_H
+223
View File
@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>emsOCRDialog</class>
<widget class="QDialog" name="emsOCRDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>717</height>
</rect>
</property>
<property name="windowTitle">
<string>socialhose OCR Engine</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="startButton">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Current Page</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="currentLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Pages in Queue:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="queueWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Pages Processed</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="processedTableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text">
<string>Date/Time</string>
</property>
</column>
<column>
<property name="text">
<string>Page</string>
</property>
</column>
<column>
<property name="text">
<string>Time of processing</string>
</property>
</column>
<column>
<property name="text">
<string># of keywords</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>15</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="totalPagesLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Total Pages Processed</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
+822
View File
@@ -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" );
if( out.is_open() ) out << "Loading Preprocessor: " << 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:
out << " Please check your software keys." << endl;
break;
default:
out << " 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;
}
+76
View File
@@ -0,0 +1,76 @@
/*
* 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 );
}
extern ofstream out;
#endif /* _idrs_config_h_ */
+112
View File
@@ -0,0 +1,112 @@
/************************************************************************
* $Id: main.cpp 648 2011-03-10 03:42:39Z elzubeir $
*
* ------------
* Description:
* ------------
*
* (C) Copyright 2009,2010 ALLCONTENT. All rights reserved.
*
* -----------------
* Revision Details: (Updated by Revision Control System)
* -----------------
* $Date: 2011-03-10 07:42:39 +0400 (Thu, 10 Mar 2011) $
* $Author: elzubeir $
* $Revision: 648 $
* $HeadURL: file:///opt/svn/socialhose/trunk/app/emsOCR/main.cpp $
*
************************************************************************/
#include <QtGui/QApplication>
#include "emsocrdialog.h"
#include <windows.h>
#include <tchar.h>
#include <dbghelp.h>
#include <stdio.h>
// Directives
// Link with DbgHelp.lib
#pragma comment ( lib, "dbghelp.lib" )
LONG __stdcall MyCustomFilter( EXCEPTION_POINTERS* pep );
void CreateMiniDump( EXCEPTION_POINTERS* pep );
int main(int argc, char *argv[])
{
SetUnhandledExceptionFilter( MyCustomFilter );
bool autoStart = false;
if(argc >=2)
{
//if(stricmp(argv[1], "autoStart") == 0)
autoStart = true;
}
QApplication a(argc, argv);
emsOCRDialog w(autoStart);
w.show();
//SetErrorMode(SEM_NOGPFAULTERRORBOX);
return a.exec();
}
LONG __stdcall MyCustomFilter( EXCEPTION_POINTERS* pep )
{
CreateMiniDump( pep );
return EXCEPTION_EXECUTE_HANDLER;
}
////////////////////////////////////////////////////////////////////////////////
// CreateMiniDump() function
//
void CreateMiniDump( EXCEPTION_POINTERS* pep )
{
// Open the file
HANDLE hFile = CreateFile( _T("MiniDump.dmp"), GENERIC_READ | GENERIC_WRITE,
0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( ( hFile != NULL ) && ( hFile != INVALID_HANDLE_VALUE ) )
{
// Create the minidump
MINIDUMP_EXCEPTION_INFORMATION mdei;
mdei.ThreadId = GetCurrentThreadId();
mdei.ExceptionPointers = pep;
mdei.ClientPointers = FALSE;
MINIDUMP_TYPE mdt = MiniDumpNormal;
BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),
hFile, mdt, (pep != 0) ? &mdei : 0, 0, 0 );
/*if( !rv )
_tprintf( _T("MiniDumpWriteDump failed. Error: %u \n"), GetLastError() );
else
_tprintf( _T("Minidump created.\n") );*/
// Close the file
CloseHandle( hFile );
}
else
{
//_tprintf( _T("CreateFile failed. Error: %u \n"), GetLastError() );
}
// Re-run emsOCR, and automatically start processing.
QProcess prcess;
QStringList list;
QString appName = QApplication::applicationFilePath();
list.append("autoStart");
prcess.startDetached(appName, list);
}
+76
View File
@@ -0,0 +1,76 @@
/****************************************************************************
** Meta object code from reading C++ file 'emsocrdialog.h'
**
** Created: Mon 8. Mar 12:01:43 2010
** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "./emsocrdialog.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'emsocrdialog.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 61
#error "This file was generated using the moc from 4.5.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_emsOCRDialog[] = {
// content:
2, // revision
0, // classname
0, 0, // classinfo
2, 12, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
// slots: signature, parameters, type, tag, flags
14, 13, 13, 13, 0x08,
39, 13, 13, 13, 0x08,
0 // eod
};
static const char qt_meta_stringdata_emsOCRDialog[] = {
"emsOCRDialog\0\0on_startButton_clicked()\0"
"threadTerminated()\0"
};
const QMetaObject emsOCRDialog::staticMetaObject = {
{ &QDialog::staticMetaObject, qt_meta_stringdata_emsOCRDialog,
qt_meta_data_emsOCRDialog, 0 }
};
const QMetaObject *emsOCRDialog::metaObject() const
{
return &staticMetaObject;
}
void *emsOCRDialog::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_emsOCRDialog))
return static_cast<void*>(const_cast< emsOCRDialog*>(this));
return QDialog::qt_metacast(_clname);
}
int emsOCRDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDialog::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: on_startButton_clicked(); break;
case 1: threadTerminated(); break;
default: ;
}
_id -= 2;
}
return _id;
}
QT_END_MOC_NAMESPACE
+228
View File
@@ -0,0 +1,228 @@
/********************************************************************************
** Form generated from reading ui file 'emsocrdialog.ui'
**
** Created: Mon 8. Mar 12:01:37 2010
** by: Qt User Interface Compiler version 4.5.2
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef UI_EMSOCRDIALOG_H
#define UI_EMSOCRDIALOG_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QSplitter>
#include <QtGui/QTableWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_emsOCRDialog
{
public:
QGridLayout *gridLayout;
QHBoxLayout *horizontalLayout;
QPushButton *startButton;
QSpacerItem *horizontalSpacer;
QVBoxLayout *verticalLayout_3;
QSpacerItem *verticalSpacer_2;
QHBoxLayout *horizontalLayout_2;
QLabel *label_2;
QLineEdit *currentLineEdit;
QSpacerItem *verticalSpacer_3;
QSplitter *splitter;
QWidget *layoutWidget;
QVBoxLayout *verticalLayout;
QLabel *label_4;
QListWidget *queueWidget;
QSpacerItem *horizontalSpacer_2;
QWidget *layoutWidget1;
QVBoxLayout *verticalLayout_2;
QLabel *label_3;
QTableWidget *processedTableWidget;
QSpacerItem *verticalSpacer_4;
QLabel *totalPagesLabel;
void setupUi(QDialog *emsOCRDialog)
{
if (emsOCRDialog->objectName().isEmpty())
emsOCRDialog->setObjectName(QString::fromUtf8("emsOCRDialog"));
emsOCRDialog->setWindowModality(Qt::WindowModal);
emsOCRDialog->resize(541, 717);
gridLayout = new QGridLayout(emsOCRDialog);
gridLayout->setSpacing(6);
gridLayout->setMargin(11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
horizontalLayout = new QHBoxLayout();
horizontalLayout->setSpacing(6);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
startButton = new QPushButton(emsOCRDialog);
startButton->setObjectName(QString::fromUtf8("startButton"));
horizontalLayout->addWidget(startButton);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout->addItem(horizontalSpacer);
gridLayout->addLayout(horizontalLayout, 0, 0, 1, 1);
verticalLayout_3 = new QVBoxLayout();
verticalLayout_3->setSpacing(6);
verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
verticalSpacer_2 = new QSpacerItem(20, 13, QSizePolicy::Minimum, QSizePolicy::Minimum);
verticalLayout_3->addItem(verticalSpacer_2);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
label_2 = new QLabel(emsOCRDialog);
label_2->setObjectName(QString::fromUtf8("label_2"));
horizontalLayout_2->addWidget(label_2);
currentLineEdit = new QLineEdit(emsOCRDialog);
currentLineEdit->setObjectName(QString::fromUtf8("currentLineEdit"));
currentLineEdit->setReadOnly(true);
horizontalLayout_2->addWidget(currentLineEdit);
verticalLayout_3->addLayout(horizontalLayout_2);
verticalSpacer_3 = new QSpacerItem(17, 6, QSizePolicy::Minimum, QSizePolicy::Minimum);
verticalLayout_3->addItem(verticalSpacer_3);
gridLayout->addLayout(verticalLayout_3, 1, 0, 1, 1);
splitter = new QSplitter(emsOCRDialog);
splitter->setObjectName(QString::fromUtf8("splitter"));
splitter->setOrientation(Qt::Vertical);
layoutWidget = new QWidget(splitter);
layoutWidget->setObjectName(QString::fromUtf8("layoutWidget"));
verticalLayout = new QVBoxLayout(layoutWidget);
verticalLayout->setSpacing(6);
verticalLayout->setMargin(11);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
label_4 = new QLabel(layoutWidget);
label_4->setObjectName(QString::fromUtf8("label_4"));
QFont font;
font.setPointSize(10);
label_4->setFont(font);
verticalLayout->addWidget(label_4);
queueWidget = new QListWidget(layoutWidget);
queueWidget->setObjectName(QString::fromUtf8("queueWidget"));
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(queueWidget->sizePolicy().hasHeightForWidth());
queueWidget->setSizePolicy(sizePolicy);
verticalLayout->addWidget(queueWidget);
horizontalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
verticalLayout->addItem(horizontalSpacer_2);
splitter->addWidget(layoutWidget);
layoutWidget1 = new QWidget(splitter);
layoutWidget1->setObjectName(QString::fromUtf8("layoutWidget1"));
verticalLayout_2 = new QVBoxLayout(layoutWidget1);
verticalLayout_2->setSpacing(6);
verticalLayout_2->setMargin(11);
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
verticalLayout_2->setContentsMargins(0, 0, 0, 0);
label_3 = new QLabel(layoutWidget1);
label_3->setObjectName(QString::fromUtf8("label_3"));
label_3->setFont(font);
verticalLayout_2->addWidget(label_3);
processedTableWidget = new QTableWidget(layoutWidget1);
if (processedTableWidget->columnCount() < 4)
processedTableWidget->setColumnCount(4);
QTableWidgetItem *__qtablewidgetitem = new QTableWidgetItem();
processedTableWidget->setHorizontalHeaderItem(0, __qtablewidgetitem);
QTableWidgetItem *__qtablewidgetitem1 = new QTableWidgetItem();
processedTableWidget->setHorizontalHeaderItem(1, __qtablewidgetitem1);
QTableWidgetItem *__qtablewidgetitem2 = new QTableWidgetItem();
processedTableWidget->setHorizontalHeaderItem(2, __qtablewidgetitem2);
QTableWidgetItem *__qtablewidgetitem3 = new QTableWidgetItem();
processedTableWidget->setHorizontalHeaderItem(3, __qtablewidgetitem3);
processedTableWidget->setObjectName(QString::fromUtf8("processedTableWidget"));
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(processedTableWidget->sizePolicy().hasHeightForWidth());
processedTableWidget->setSizePolicy(sizePolicy1);
verticalLayout_2->addWidget(processedTableWidget);
splitter->addWidget(layoutWidget1);
gridLayout->addWidget(splitter, 2, 0, 1, 1);
verticalSpacer_4 = new QSpacerItem(20, 15, QSizePolicy::Minimum, QSizePolicy::Minimum);
gridLayout->addItem(verticalSpacer_4, 3, 0, 1, 1);
totalPagesLabel = new QLabel(emsOCRDialog);
totalPagesLabel->setObjectName(QString::fromUtf8("totalPagesLabel"));
totalPagesLabel->setFont(font);
gridLayout->addWidget(totalPagesLabel, 4, 0, 1, 1);
retranslateUi(emsOCRDialog);
QMetaObject::connectSlotsByName(emsOCRDialog);
} // setupUi
void retranslateUi(QDialog *emsOCRDialog)
{
emsOCRDialog->setWindowTitle(QApplication::translate("emsOCRDialog", "socialhose OCR Engine", 0, QApplication::UnicodeUTF8));
startButton->setText(QApplication::translate("emsOCRDialog", "Start", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("emsOCRDialog", "Current Page", 0, QApplication::UnicodeUTF8));
label_4->setText(QApplication::translate("emsOCRDialog", "Pages in Queue:", 0, QApplication::UnicodeUTF8));
label_3->setText(QApplication::translate("emsOCRDialog", "Pages Processed", 0, QApplication::UnicodeUTF8));
QTableWidgetItem *___qtablewidgetitem = processedTableWidget->horizontalHeaderItem(0);
___qtablewidgetitem->setText(QApplication::translate("emsOCRDialog", "Date/Time", 0, QApplication::UnicodeUTF8));
QTableWidgetItem *___qtablewidgetitem1 = processedTableWidget->horizontalHeaderItem(1);
___qtablewidgetitem1->setText(QApplication::translate("emsOCRDialog", "Page", 0, QApplication::UnicodeUTF8));
QTableWidgetItem *___qtablewidgetitem2 = processedTableWidget->horizontalHeaderItem(2);
___qtablewidgetitem2->setText(QApplication::translate("emsOCRDialog", "Time of processing", 0, QApplication::UnicodeUTF8));
QTableWidgetItem *___qtablewidgetitem3 = processedTableWidget->horizontalHeaderItem(3);
___qtablewidgetitem3->setText(QApplication::translate("emsOCRDialog", "# of keywords", 0, QApplication::UnicodeUTF8));
totalPagesLabel->setText(QApplication::translate("emsOCRDialog", "Total Pages Processed", 0, QApplication::UnicodeUTF8));
Q_UNUSED(emsOCRDialog);
} // retranslateUi
};
namespace Ui {
class emsOCRDialog: public Ui_emsOCRDialog {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_EMSOCRDIALOG_H