Example #1
4
 /**
  * Comare charObjects to congruous
  *
  * @param string $str
  * @param boolean $print
  * @return boolean
  */
 private function checkCharObject($str, $print = true)
 {
     $m = 1;
     $char = unserialize($str);
     if ($print) {
         echo "Check '" . $char->getName() . "'<br/>";
     }
     $curr_imgs_info = $char->getImageInfo();
     $imageInfo = $this->charObject->getImageInfo();
     if (count($imageInfo)) {
         $m = 0;
         foreach ($imageInfo as $key => $value) {
             if (isset($curr_imgs_info[$key]['type']) && ($curr_imgs_info[$key]['type'] != $value['type'] && $curr_imgs_info[$key]['type'] != OCR::getNegative($value['type']))) {
                 $m++;
             }
         }
     }
     if ($print) {
         echo "We have " . $m . " errors <br/>";
     }
     if ($m == 0) {
         if ($print) {
             echo "It is '" . $char->getName() . "'<br/>";
         }
         return true;
     } else {
         if ($print) {
             echo "It is not '" . $char->getName() . "'<br/>";
         }
         return false;
     }
 }
Example #2
1
 private static function init()
 {
     if (self::$installed_ocr_programs === null) {
         self::$installed_ocr_programs = array();
         foreach (self::$known_ocr_programs as $program) {
             if ($program == 'ocrad') {
                 exec('which convert', $output);
                 //ocrad needs convert to run, part of imagemagick
                 if (empty($output)) {
                     continue;
                 }
                 unset($output);
             }
             exec("which {$program}", $output);
             if (!empty($output)) {
                 self::$installed_ocr_programs[] = $program;
             }
             unset($output);
         }
     }
 }
Example #3
1
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$OCR = new OCR('API KEY');
$result = $OCR->get_text('test.png');
if ($result !== FALSE) {
    echo $result;
} else {
    echo 'Could not get text.';
}
echo PHP_EOL;
Example #4
1
<?php

require '../OCR.php';
if (isset($_POST['get_available_programs'])) {
    echo json_encode(OCR::getInstalledPrograms());
} elseif (isset($_POST['data'])) {
    $program = isset($_POST['program']) && $_POST['program'] != 'all' ? $_POST['program'] : null;
    echo json_encode(OCR::run($_POST['data'], $program));
}
Example #5
1
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
$reports = array(array('text' => 'Definiții nemoderate', 'url' => 'admin/viewPendingDefinitions', 'count' => Model::factory('Definition')->where('status', ST_PENDING)->count(), 'privilege' => PRIV_EDIT), array('text' => 'Definiții cu greșeli de tipar', 'url' => 'admin/viewTypos', 'count' => Model::factory('Typo')->select('definitionId')->distinct()->count(), 'privilege' => PRIV_EDIT), array('text' => 'Definiții cu abrevieri ambigue', 'url' => 'admin/randomAbbrevReview', 'count' => Definition::countAmbiguousAbbrevs(), 'privilege' => PRIV_EDIT), array('text' => 'Definiții OCR neverificate', 'url' => 'admin/definitionEdit', 'count' => sprintf("%d (disponibile: %d)", Model::factory('OCR')->where('status', 'raw')->count(), OCR::countAvailable(session_getUserId())), 'privilege' => PRIV_EDIT), array('text' => 'Definiții neasociate cu niciun lexem', 'url' => 'admin/viewUnassociatedDefinitions', 'count' => Definition::countUnassociated(), 'privilege' => PRIV_EDIT), array('text' => 'Lexeme neasociate cu nicio definiție', 'url' => 'admin/viewUnassociatedLexems', 'count' => Lexem::countUnassociated(), 'privilege' => PRIV_EDIT), array('text' => 'Lexeme cu comentarii', 'url' => 'admin/viewLexemsWithComments', 'count' => Model::factory('Lexem')->where_not_null('comment')->count(), 'privilege' => PRIV_EDIT), array('text' => 'Lexeme fără accent', 'url' => 'admin/viewLexemsWithoutAccents', 'count' => Model::factory('Lexem')->where('consistentAccent', 0)->count(), 'privilege' => PRIV_EDIT), array('text' => 'Lexeme ambigue', 'url' => 'admin/viewAmbiguousLexems', 'count' => 'numărătoare dezactivată', 'privilege' => PRIV_EDIT), array('text' => 'Lexeme fără paradigme', 'url' => 'admin/viewTemporaryLexems', 'count' => Model::factory('LexemModel')->where('modelType', 'T')->count(), 'privilege' => PRIV_EDIT));
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::assign("allStatuses", util_getAllStatuses());
SmartyWrap::assign('structStatusNames', Lexem::$STRUCT_STATUS_NAMES);
SmartyWrap::assign('reports', $reports);
SmartyWrap::assign('sectionTitle', 'Pagina moderatorului');
SmartyWrap::addCss('jqueryui', 'select2');
SmartyWrap::addJs('jquery', 'jqueryui', 'select2', 'select2Dev', 'modelDropdown');
SmartyWrap::displayAdminPage('admin/index.ihtml');
Example #6
0
<?php

/**
 * Example, check images from file
 *
 * @author Andrey Kucherenko <*****@*****.**>
 * @package phpOCR
 */
include_once "config.php";
include_once "OCR.class.php";
//make new OCR object
$char = new OCR();
//Recognition process, check images from files
echo "<hr/><img src='M.png'/><br/>";
$res = $char->Recognition('M.png');
if ($res !== false) {
    echo "<b>" . $res->getName() . "</b>";
} else {
    echo "Not yet recognised.<br/>";
}
echo "<hr/><img src='M1.png'/><br/>";
$res = $char->Recognition('M1.png');
if ($res !== false) {
    echo "<b>" . $res->getName() . "</b>";
} else {
    echo "Not yet recognised.<br/>";
}
echo "<hr/><img src='z11.png'/><br/>";
$res = $char->Recognition('z11.png');
if ($res !== false) {
    echo "<b>" . $res->getName() . "</b>";
Example #7
0
<?php

require_once 'OCR.php';
$loginUrl = "http://210.32.33.91:8080/reader/redr_verify.php";
// 登录页面
$captchaUrl = "http://210.32.33.91:8080/reader/captcha.php";
// 验证码页面
$ocr = new OCR('./captcha/1.gif');
$captcha = $ocr->getCaptcha();
echo $captcha;
Example #8
0
<?php

/**
 * Example, learn OCR to recognition letters
 *
 * @author Andrey Kucherenko <*****@*****.**>
 * @package phpOCR
 */
include_once "config.php";
include_once "OCR.class.php";
//make new OCR object
$char = new OCR();
//method draw letter & learn system
$char->Learn("W");
//save sarialized object to file
$char->saveResult();
echo 'Save information about "W"<br>';
//method draw letter & learn system
$char->Learn("z");
//save sarialized object to file
$char->saveResult();
echo 'Save information about "z"<br>';
//method draw letter & learn system
$char->Learn("Z");
//save sarialized object to file
$char->saveResult();
echo 'Save information about "Z"<br>';
//method draw letter & learn system
$char->Learn("M");
//save sarialized object to file
$char->saveResult();