Exemple #1
0
int main(int argc, char **argv) {
    wmfAPI *API = NULL;
    wmfD_Rect bbox;
    wmf_svg_t *ddata;
    float width, height;

    if (argc != 2) {
        fprintf(stderr, "Usage: wmf file\n");
        return 1;
    }
    if (!create_api(&API)) {
        fprintf(stderr, "Failed to create WMF API\n");
        return 1;
    }
    ddata = WMF_SVG_GetData(API);

    if (!load_image(API, argv[1])) {
        fprintf(stderr, "Failed to load image: %s\n", argv[1]);
        return 1;
    }
    if (!scan_image(API, &bbox)) {
        fprintf(stderr, "Failed to scan image: %s\n", argv[1]);
        return 1;
    }


    wmf_file_close(API);
    get_image_size(&bbox, &width, &height);
    printf("Image size: %f x %f\n", width, height);

    return 0;
}
int main (int argc, const char *argv[])
{
  // option pre-scan
  int quiet = 0;
  int display = 1;
  
  MagickWandGenesis();
  
  processor = zbar_processor_create(0);
  assert(processor);
  if(zbar_processor_init(processor, NULL, display)) 
  {
    zbar_processor_error_spew(processor, 0);
    return(1);
  }
  
  if(display)
    zbar_processor_set_visible(processor, 1);    
  
  IplImage * image = cvLoadImage(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
  
  if(scan_image(image))
    return (exit_code);
  
  if(num_images && !quiet && xmllvl <= 0) 
  {
    fprintf(stderr, "scanned %d barcode symbols from %d images",
            num_symbols, num_images);
#ifdef HAVE_SYS_TIMES_H
#ifdef HAVE_UNISTD_H
    long clk_tck = sysconf(_SC_CLK_TCK);
    struct tms tms;
    if(clk_tck > 0 && times(&tms) >= 0) 
    {
      double secs = tms.tms_utime + tms.tms_stime;
      secs /= clk_tck;
      fprintf(stderr, " in %.2g seconds\n", secs);
    }
#endif
#endif
    fprintf(stderr, "\n");
    if(notfound)
      fprintf(stderr, "%s", warning_not_found);
  }
  if(num_images && notfound && !exit_code)
    exit_code = 4;
  
  zbar_processor_destroy(processor);
  MagickWandTerminus();
  return(exit_code);
}
Exemple #3
0
int main() {
  init_sdl();

  SDL_Surface* image = load_image("dataset/group2.jpg");
  scan_image(image);
  display_image(image);

  //print_features();

  //test_features(81554);

  //test_strong_classifier();
  return 0;
}
Exemple #4
0
int main (int argc, const char *argv[])
{
    // option pre-scan
    int quiet = 0;
    int display = 0;
    int i, j;
    for(i = 1; i < argc; i++) {
        const char *arg = argv[i];
        if(arg[0] != '-' || !arg[1])
            // first pass, skip images
            num_images++;
        else if(arg[1] != '-')
            for(j = 1; arg[j]; j++) {
                if(arg[j] == 'S') {
                    if(!arg[++j] && ++i >= argc)
                        /* FIXME parse check */
                        return(parse_config("", "-S"));
                    break;
                }
                switch(arg[j]) {
                case 'h': return(usage(0, NULL, NULL));
                case 'q': quiet = 1; break;
                case 'v': zbar_increase_verbosity(); break;
                case 'd': display = 1; break;
                case 'D': break;
                default:
                    return(usage(1, "ERROR: unknown bundled option: -",
                                 arg + j));
                }
            }
        else if(!strcmp(arg, "--help"))
            return(usage(0, NULL, NULL));
        else if(!strcmp(arg, "--version")) {
            printf("%s\n", PACKAGE_VERSION);
            return(0);
        }
        else if(!strcmp(arg, "--quiet")) {
            quiet = 1;
            argv[i] = NULL;
        }
        else if(!strcmp(arg, "--verbose"))
            zbar_increase_verbosity();
        else if(!strncmp(arg, "--verbose=", 10))
            zbar_set_verbosity(strtol(argv[i] + 10, NULL, 0));
        else if(!strcmp(arg, "--display"))
            display++;
        else if(!strcmp(arg, "--nodisplay") ||
                !strcmp(arg, "--set") ||
                !strcmp(arg, "--xml") ||
                !strcmp(arg, "--noxml") ||
                !strcmp(arg, "--raw") ||
                !strncmp(arg, "--set=", 6))
            continue;
        else if(!strcmp(arg, "--")) {
            num_images += argc - i - 1;
            break;
        }
        else
            return(usage(1, "ERROR: unknown option: ", arg));
    }

    if(!num_images)
        return(usage(1, "ERROR: specify image file(s) to scan", NULL));
    num_images = 0;

    MagickWandGenesis();

    processor = zbar_processor_create(0);
    assert(processor);
    if(zbar_processor_init(processor, NULL, display)) {
        zbar_processor_error_spew(processor, 0);
        return(1);
    }

    for(i = 1; i < argc; i++) {
        const char *arg = argv[i];
        if(!arg)
            continue;

        if(arg[0] != '-' || !arg[1]) {
            if(scan_image(arg))
                return(exit_code);
        }
        else if(arg[1] != '-')
            for(j = 1; arg[j]; j++) {
                if(arg[j] == 'S') {
                    if((arg[++j])
                       ? parse_config(arg + j, "-S")
                       : parse_config(argv[++i], "-S"))
                        return(1);
                    break;
                }
                switch(arg[j]) {
                case 'd': zbar_processor_set_visible(processor, 1);  break;
                case 'D': zbar_processor_set_visible(processor, 0);  break;
                }
            }
        else if(!strcmp(arg, "--display"))
            zbar_processor_set_visible(processor, 1);
        else if(!strcmp(arg, "--nodisplay"))
            zbar_processor_set_visible(processor, 0);
        else if(!strcmp(arg, "--xml")) {
            if(xmllvl < 1) {
                xmllvl = 1;
#ifdef _WIN32
                fflush(stdout);
                _setmode(_fileno(stdout), _O_BINARY);
#endif
                printf("%s", xml_head);
            }
        }
        else if(!strcmp(arg, "--noxml") || !strcmp(arg, "--raw")) {
            if(xmllvl > 0) {
                xmllvl = 0;
                printf("%s", xml_foot);
                fflush(stdout);
#ifdef _WIN32
                _setmode(_fileno(stdout), _O_TEXT);
#endif
            }
            if(!strcmp(arg, "--raw")) {
                xmllvl = -1;
#ifdef _WIN32
                fflush(stdout);
                _setmode(_fileno(stdout), _O_BINARY);
#endif
            }
        }
        else if(!strcmp(arg, "--set")) {
            if(parse_config(argv[++i], "--set"))
                return(1);
        }
        else if(!strncmp(arg, "--set=", 6)) {
            if(parse_config(arg + 6, "--set="))
                return(1);
        }
        else if(!strcmp(arg, "--"))
            break;
    }
    for(i++; i < argc; i++)
        if(scan_image(argv[i]))
            return(exit_code);

    /* ignore quit during last image */
    if(exit_code == 3)
        exit_code = 0;

    if(xmllvl > 0) {
        xmllvl = -1;
        printf("%s", xml_foot);
        fflush(stdout);
    }

    if(xmlbuf)
        free(xmlbuf);

    if(num_images && !quiet && xmllvl <= 0) {
        fprintf(stderr, "scanned %d barcode symbols from %d images",
                num_symbols, num_images);
#ifdef HAVE_SYS_TIMES_H
#ifdef HAVE_UNISTD_H
        long clk_tck = sysconf(_SC_CLK_TCK);
        struct tms tms;
        if(clk_tck > 0 && times(&tms) >= 0) {
            double secs = tms.tms_utime + tms.tms_stime;
            secs /= clk_tck;
            fprintf(stderr, " in %.2g seconds\n", secs);
        }
#endif
#endif
        fprintf(stderr, "\n");
        if(notfound)
            fprintf(stderr, "%s", warning_not_found);
    }
    if(num_images && notfound && !exit_code)
        exit_code = 4;

    zbar_processor_destroy(processor);
    MagickWandTerminus();
    return(exit_code);
}