static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) { FILE *f; char buf[128]; char cmd[512]; int cmdres; const char *const tmpfname = tmpnam(NULL); sprintf(buf, "subtitle-%d-%d.pgm", spudec->start_pts / 90, spudec->end_pts / 90); f = fopen(buf, "w"); output_pgm(f, w, h, src, srca, stride); fclose(f); /* see <URL:http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/subtitleripper/subtitleripper/src/README.gocr?rev=HEAD&content-type=text/vnd.viewcvs-markup> */ sprintf(cmd, GOCR_PROGRAM" -v 1 -s 7 -d 0 -m 130 -m 256 -m 32 -i %s -o %s", buf, tmpfname); cmdres = system(cmd); if (cmdres < 0) { perror("system failed"); exit(EXIT_FAILURE); } else if (cmdres) { fprintf(stderr, GOCR_PROGRAM" returned %d\n", cmdres); exit(cmdres); } process_gocr_output(tmpfname, spudec->start_pts, spudec->end_pts); unlink(buf); unlink(tmpfname); }
static void run_ocr(int region, unsigned long long pts) { FILE *f; char inbuf[128]; char outbuf[128]; char cmd[512]; int cmdres; //const char *const tmpfname = tmpnam(NULL); sprintf(inbuf, "subtitle-%llu-%d.pgm", pts / 90, region); sprintf(outbuf, "tmp.txt"); f = fopen(inbuf, "w"); output_pgm(f, region); fclose(f); //sprintf(cmd, GOCR_PROGRAM" -v 1 -s 7 -d 0 -m 130 -m 256 -m 32 -i %s -o %s", inbuf, outbuf); sprintf(cmd, GOCR_PROGRAM" -s 8 -d 0 -m 130 -i %s -o %s", inbuf, outbuf); cmdres = system(cmd); if (cmdres < 0) { perror("system failed"); exit(EXIT_FAILURE); } else if (cmdres) { fprintf(stderr, GOCR_PROGRAM" returned %d\n", cmdres); exit(cmdres); } process_gocr_output(outbuf,region); unlink(inbuf); unlink(outbuf); }
int main( int argc, char *argv[]){ int *buf, w, l; double x1, x2, y1, y2, nthreads; if(argc!=9){ printf("Usage: %s l w x1 y1 x2 y2 filename\n nthreads", argv[0]); exit(1); } w = atoi(argv[1]); l = atoi(argv[2]); buf = malloc(w*l*sizeof(int)); x1 = atof(argv[3]); y1 = atof(argv[4]); x2 = atof(argv[5]); y2 = atof(argv[6]); nthreads = atoi(argv[8]); omp_set_num_threads( nthreads ); compute( buf, w, l, x1, x2, y1, y2); output_pgm( argv[7], buf, w, l, 255 ); return 0; }