tools/roi-visualize: upd

This commit is contained in:
Evgeny Zinoviev 2022-06-07 19:57:12 +03:00
parent 49106dd29d
commit 70a622e04b

View File

@ -16,7 +16,7 @@ function parse_roi_input(string $file): array {
$lines = array_map(fn($line) => array_map('intval', explode(' ', $line)), $lines);
foreach ($lines as $points) {
if (count($points) != 4)
throw new Exception("invalid line: ".implode(' ', $points));
throw new Exception(__METHOD__.": invalid line: ".implode(' ', $points));
}
return $lines;
@ -57,6 +57,7 @@ $colors = [
if ($argc < 2)
fatal("usage: {$argv[0]} --roi FILE --input PATH --output PATH\n");
try {
array_shift($argv);
while (count($argv) > 0) {
switch ($argv[0]) {
@ -76,7 +77,7 @@ while (count($argv) > 0) {
break;
default:
fatal('unsupported argument: '.$argv[0]);
throw new Exception("unsupported argument: {$argv[0]}");
}
}
@ -112,3 +113,6 @@ foreach ($regions as $i => $region) {
imagejpeg($img, $output, 97);
echo "saved to $output\n";
} catch (Exception $e) {
fatal($e->getMessage()."\n");
}