예제 #1
0
파일: ocr.php 프로젝트: im286er/ent
<?php

include '../CaptchaBuilderInterface.php';
include '../PhraseBuilderInterface.php';
include '../CaptchaBuilder.php';
include '../PhraseBuilder.php';
use Gregwar\Captcha\CaptchaBuilder;
/**
 * Generates 1000 captchas and try to read their code with the
 * ocrad OCR
 */
$tests = 10000;
$passed = 0;
shell_exec('rm passed*.jpg');
for ($i = 0; $i < $tests; $i++) {
    echo "Captcha {$i}/{$tests}... ";
    $captcha = new CaptchaBuilder();
    $captcha->setDistortion(false)->build();
    if ($captcha->isOCRReadable()) {
        $passed++;
        $captcha->save("passed{$passed}.jpg");
        echo "passed at ocr... ";
    } else {
        echo "failed... ";
    }
    echo "pass rate: " . round(100 * $passed / ($i + 1), 2) . "%\n";
}
echo "\n";
echo "Over, {$passed}/{$tests} readed with OCR\n";
예제 #2
0
 /**
  * Saves the captcha into a jpeg in the $filename, with the given quality
  *
  * @access  public
  * @param   string  $filename  Target filename
  * @param   string  $quality   Image quality
  * @return  void
  */
 public function save($filename, $quality = 90)
 {
     $this->builder->save($filename, $quality);
 }