/**
  * 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;
 }
Esempio n. 2
0
<?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;