Sleds/slocr-mp/MultiProcessOCR/main.cpp

74 lines
1.7 KiB
C++
Raw Normal View History

2025-03-13 21:28:38 +00:00
#include <getopt.h>
#include <iostream>
#include <stdlib.h>
#include "OCRManager.h"
using namespace sequencelogic;
void writeHelp()
{
std::cout << "Usage: sequencelogic-ocr [OPTIONS] [FILE_OR_FOLDER_NAME]" << std::endl
<< "Option Meaning" << std::endl
<< "-----------------------------" << std::endl
<< "-h Show the help message." << std::endl
<< "-i The given input is a file to be OCR'd." << std::endl
<< "-p 'Pretty print' the output file." << std::endl
<< "-e {xx} Stop OCR after XX pages cannot be recognized." << std::endl
<< "-v Verifies that the license is configured correctly." << std::endl
<< "-s Saves every page as a separate .PNG file." << std::endl
<< "-m {xx} Runs the multi threaded version of Nuance usig XX threads (2 by default)." << std::endl;
}
int main(int argc, char *argv[])
{
std::string opts = "f:i:e:m:hvps";
char opt;
bool prettyPrint = false;
bool ran;
bool singlePageOutput = false;
bool validate = false;
int threadCount = 2;
int numPagesInErrorOk = 0;
std::string inputFile;
OCRManager ocr;
while ((opt = static_cast<char>(getopt(argc, argv, opts.c_str()))) != EOF)
{
switch (opt)
{
case 'i':
inputFile = optarg;
case 'v':
validate = true;
break;
case 's':
singlePageOutput = true;
break;
case 'e':
numPagesInErrorOk = atoi(optarg);
break;
case 'h':
case '?':
default:
writeHelp();
break;
case 'p':
prettyPrint = true;
break;
case 'm':
threadCount = atoi(optarg);
break;
}
}
//run the ocr
ocr.RunOCR(inputFile, prettyPrint, numPagesInErrorOk, threadCount, singlePageOutput);
}