Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding an OCR test, that should be 0%
- Loading branch information
Showing
4 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
demo/out.jpg | ||
demo/*.jpg | ||
demo/*.pgm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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 = 1000; | ||
$passed = 0; | ||
|
||
shell_exec('rm passed*.jpg'); | ||
|
||
for ($i=0; $i<$tests; $i++) { | ||
echo "Captcha $i/$tests... "; | ||
|
||
$captcha = new CaptchaBuilder; | ||
|
||
$captcha | ||
->build() | ||
->save('out.jpg', 20) | ||
; | ||
|
||
shell_exec('convert out.jpg out.pgm'); | ||
$result = trim(shell_exec('ocrad out.pgm')); | ||
|
||
if ($result == $captcha->getPhrase()) { | ||
echo "passed at ocr\n"; | ||
shell_exec("cp out.jpg passed$passed.jpg"); | ||
$passed++; | ||
} else { | ||
echo "failed\n"; | ||
} | ||
} | ||
|
||
echo "\n"; | ||
echo "Over, $passed/$tests readed with OCR\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
header('Content-type: image/jpeg'); | ||
|
||
CaptchaBuilder::create() | ||
->build(300, 70) | ||
->build() | ||
->output(20) | ||
; |