Beispiel #1
0
 public function testGenerateTemplateChar()
 {
     $img = Recognizer::openImg(__DIR__ . '/../template/test_img/olx1.png');
     $width = imagesx($img);
     $height = imagesy($img);
     $template = Recognizer::generateTemplateChar($img, $width, $height);
     $this->assertEquals(preg_match_all('%[01]%', $template), $width * $height);
 }
Beispiel #2
0
    $allChar = [];
    foreach ($chars as $lines) {
        foreach ($lines as $words) {
            foreach ($words as $charValue) {
                $allChar[] = $charValue;
            }
        }
    }
    $chars = Recognizer::findUniqueChar($allChar);
    ?>
    <form method="POST" action="">
        <?php 
    foreach ($chars as $key => $fileName) {
        $name = './tmp/' . rand() . microtime(true) . '.png';
        imagepng($fileName, $name);
        $tmp = Recognizer::generateTemplateChar($fileName);
        ?>
            <img src="<?php 
        echo $name;
        ?>
"/><label>
                <input type='text' name="template_<?php 
        echo $key;
        ?>
" value=''/>
            </label><br/>
            <input type="hidden" name="pattern_<?php 
        echo $key;
        ?>
" value="<?php 
        echo $tmp;