예제 #1
0
파일: TestOCR.php 프로젝트: acgrid/adbot
 public function run(array $context = [])
 {
     $ocr = Number::instance($this->manager, $this->app);
     $align = Manager::readConfig($context, 'align', 'L');
     $mode = Manager::readConfig($context, 'scan', Number::SCAN_FIXED);
     $rule = Manager::readConfig($context, 'rule', 'Test');
     $color = Manager::readConfig($context, 'color', '000000');
     $rect = $align == 'L' ? Position::makeRectangle(0, 0, 1.0, 1.0) : Position::makeRectangle(1.0, 1.0, 0, 0);
     $result = $ocr->ocr($rule, $rect, [Number::CFG_COLOR => $color, Number::CFG_SCAN_MODE => $mode, Number::CFG_WIDTH => 0.25, Number::CFG_MARGIN => 0]);
     $this->logger->info('OCR Result %s', [$result]);
     return Manager::RET_LOOP;
 }
예제 #2
0
 public function run(array $context = [])
 {
     $ocr = Number::instance($this->manager, $this->app);
     $point = Manager::readConfig($context, 'point');
     Position::assertPoint($point);
     $this->logger->info('Test for X=%.4f, Y=%.4f', $point[Position::X], $point[Position::Y]);
     $ocr->setRules(['Test' => ['J' => [$point], 'T' => 1, 'F' => 0]]);
     $rect = Position::makeRectangle(0, 0, 1, 1);
     for ($i = 0; $i <= 9; $i++) {
         $this->screen->load(sprintf('tests/digits/%u.png', $i), Screen::PORTRAIT);
         $this->logger->info('OCR Result for digit %u is %s', [$i, $ocr->ocr('Test', $rect, [Number::CFG_COLOR => '000000', Number::CFG_WIDTH => 1, Number::CFG_MARGIN => 0])]);
     }
     return Manager::RET_LOOP;
 }