/** * Takes parameters from a form submission and modifies an existing image record * in the database. */ public function addImageOccurrence($postArr) { $status = true; //Load occurrence record if ($this->addOccurrence($postArr)) { //Load images if ($this->addImage($postArr)) { if ($this->activeImgId) { //Load OCR $rawStr = ''; $ocrSource = ''; if ($postArr['ocrblock']) { $rawStr = trim($postArr['ocrblock']); if ($postArr['ocrsource']) { $ocrSource = $postArr['ocrsource']; } else { $ocrSource = 'User submitted'; } } elseif (isset($postArr['tessocr']) && $postArr['tessocr']) { $ocrManager = new SpecProcessorOcr(); $rawStr = $ocrManager->ocrImageById($this->activeImgId); $ocrSource = 'Tesseract'; } if ($rawStr) { if ($ocrSource) { $ocrSource .= ': ' . date('Y-m-d'); } $sql = 'INSERT INTO specprocessorrawlabels(imgid, rawstr, source) ' . 'VALUES(' . $this->activeImgId . ',"' . $this->cleanInStr($rawStr) . '","' . $this->cleanInStr($ocrSource) . '")'; if (!$this->conn->query($sql)) { $this->errorStr = 'ERROR loading OCR text block: ' . $this->conn->error; } } } } } else { $status = false; } return $status; }
$imageProcessor->setCollid($collid); $imageProcessor->processiDigBioOutput($specManager->getSpecKeyPattern()); echo '</ul>'; } elseif ($action == 'Run Batch OCR') { $ocrManager = new SpecProcessorOcr(); $ocrManager->setVerbose(2); $batchLimit = 100; if (array_key_exists('batchlimit', $_POST)) { $batchLimit = $_POST['batchlimit']; } echo '<ul>'; $ocrManager->batchOcrUnprocessed($collid, $procStatus, $batchLimit, 0); echo '</ul>'; } elseif ($action == 'Load OCR Files') { $specManager->addProject($_POST); $ocrManager = new SpecProcessorOcr(); $ocrManager->setVerbose(2); echo '<ul>'; $ocrManager->harvestOcrText($_POST); echo '</ul>'; } elseif ($action == 'dlnoimg') { $specManager->downloadReportData($action); exit; } elseif ($action == 'unprocnoimg') { $specManager->downloadReportData($action); exit; } elseif ($action == 'noskel') { $specManager->downloadReportData($action); exit; } if ($statusStr) {
<?php include_once '../../../config/symbini.php'; include_once $serverRoot . '/classes/SpecProcessorOcr.php'; $imgid = $_REQUEST['imgid']; $x = array_key_exists('x', $_REQUEST) ? $_REQUEST['x'] : 0; $y = array_key_exists('y', $_REQUEST) ? $_REQUEST['y'] : 0; $w = array_key_exists('w', $_REQUEST) ? $_REQUEST['w'] : 1; $h = array_key_exists('h', $_REQUEST) ? $_REQUEST['h'] : 1; $ocrBest = array_key_exists('ocrbest', $_REQUEST) ? $_REQUEST['ocrbest'] : 0; $rawStr = ''; $ocrManager = new SpecProcessorOcr(); $ocrManager->setCropX($x); $ocrManager->setCropY($y); $ocrManager->setCropW($w); $ocrManager->setCropH($h); $rawStr = $ocrManager->ocrImageById($imgid, $ocrBest); echo $rawStr;
<?php //This file can be triggered by a CRON job for automatci OCR of unprocessed images //Following example OCR collection ids 1,4, and 5. Script will also out to log file //php ocr_handler.php '1,4,5' 0 include_once '../../config/symbini.php'; include_once $serverRoot . '/classes/SpecProcessorOcr.php'; $silent = 1; $collStr = ''; if (array_key_exists(1, $argv)) { $collStr = $argv[1]; } if (array_key_exists(2, $argv)) { $silect = $argv[2]; } $ocrManager = new SpecProcessorOcr(); $ocrManager->setSilent($silent); //Turn on logging $ocrManager->batchOcrUnprocessed($collStr);