add option -S, --ascii-art-segments

This options prints the recognized segments, i.e. the display as
seen by ssocr, to standard error. This can be used as a quick check
what went wrong if the recognition does not work. Additionally,
it can be used to get the raw segment data to use a separate
program to interpret set segments as digits or characters.
This commit is contained in:
Erik Auerswald
2017-10-22 17:19:16 +02:00
parent 60614d467e
commit 719ca823a1
4 changed files with 16 additions and 2 deletions
+1
View File
@@ -111,6 +111,7 @@
#define PRINT_INFO (1<<5)
#define ADJUST_GRAY (1<<6)
#define DEBUG_OUTPUT (1<<7)
#define ASCII_ART_SEGMENTS (1<<8)
/* colors used by ssocr */
#define SSOCR_BLACK 0
+1
View File
@@ -103,6 +103,7 @@ void usage(char *name, FILE *f)
fprintf(f, " -g, --adjust-gray use T1 and T2 as percentages of used values\n");
fprintf(f, " -l, --luminance=KEYWORD compute luminance using formula KEYWORD\n");
fprintf(f, " use -l help for list of KEYWORDS\n");
fprintf(f, " -S, --ascii-art-segments print recognized segments a ASCII art\n");
fprintf(f, "\nCommands: dilation dilation algorithm (with mask of 1 pixel)\n");
fprintf(f, " erosion erosion algorithm (with mask of 9 pixels)\n");
fprintf(f, " closing [N] closing algorithm\n");
+4
View File
@@ -142,6 +142,10 @@ the used formula.
The default of
.I Rec709
should work well in most cases.
.SS -S, --ascii-art-segments
Prints the recognized segments, i.e. the display as seen by
.BR ssocr ,
as ASCII art to standard error.
.SH COMMANDS
.SS dilation
Filter image using dilation algorithm.
+10 -2
View File
@@ -178,9 +178,10 @@ int main(int argc, char **argv)
{"print-info", 0, 0, 'I'}, /* print image info */
{"adjust-gray", 0, 0, 'g'}, /* use T1 and T2 as perecntages of used vals*/
{"luminance", 1, 0, 'l'}, /* luminance formula */
{"ascii-art-segments", 0, 0, 'S'}, /* print found segments in ASCII art */
{0, 0, 0, 0} /* terminate long options */
};
c = getopt_long (argc, argv, "hVt:vaTn:i:d:r:m:o:O:D::pPf:b:Igl:",
c = getopt_long (argc, argv, "hVt:vaTn:i:d:r:m:o:O:D::pPf:b:Igl:S",
long_options, &option_index);
if (c == -1) break; /* leaves while (1) loop */
switch (c) {
@@ -333,6 +334,13 @@ int main(int argc, char **argv)
lt = parse_lum(optarg);
}
break;
case 'S':
flags |= ASCII_ART_SEGMENTS;
if(flags & DEBUG_OUTPUT) {
fprintf(stderr, "flags & ASCII_ART_SEGMENTS=%d\n",
flags & ASCII_ART_SEGMENTS);
}
break;
case '?': /* missing argument or character not in optstring */
usage(argv[0],stderr);
exit (2);
@@ -1222,7 +1230,7 @@ int main(int argc, char **argv)
* | | | _| _| |_| |_ |_ | | | |_| |_|
* |_| | |_ _| | _| |_| | | |_| _|
*/
if(flags & DEBUG_OUTPUT) {
if(flags & (DEBUG_OUTPUT | ASCII_ART_SEGMENTS)) {
fputs("Display as seen by ssocr:\n", stderr);
/* top row */
for(i=0; i<number_of_digits; i++) {