Logo Search packages:      
Sourcecode: zebra version File versions  Download package

int zebra_scan_image ( zebra_image_scanner_t scanner,
zebra_image_t image 
)

scan for symbols in provided image.

Returns:
>0 if symbols were successfully decoded from the image, 0 if no symbols were found or -1 if an error occurs

Definition at line 324 of file img_scanner.c.

References zebra_image_convert(), zebra_image_destroy(), zebra_image_get_data(), zebra_image_get_height(), zebra_image_get_width(), zebra_scan_image(), zebra_scan_y(), and zebra_scanner_new_scan().

Referenced by zebra::ImageScanner::scan(), and zebra_scan_image().

{
    recycle_syms(iscn, img);

    /* get grayscale image, convert if necessary */
    img = zebra_image_convert(img, fourcc('Y','8','0','0'));
    if(!img)
        return(-1);

    unsigned w = zebra_image_get_width(img);
    unsigned h = zebra_image_get_height(img);
    const uint8_t *data = zebra_image_get_data(img);
    const uint8_t *p = data;
    int x = 0, y = 0;
#ifdef DEBUG_IMG_SCANNER
    movedelta(0, (h + 1) / 2);
#else
    movedelta(0, 8);
#endif

    if(zebra_scanner_new_scan(iscn->scn))
        symbol_handler(iscn, x, y);

    /* FIXME add density config api */
    /* FIXME less arbitrary lead-out default */
    int quiet = w / 32;
    if(quiet < 8)
        quiet = 8;

    while(y < h) {
        zprintf(32, "img_x+: %03x,%03x @%p\n", x, y, p);
        while(x < w) {
            ASSERT_POS;
            if(zebra_scan_y(iscn->scn, *p))
                symbol_handler(iscn, x, y);
            movedelta(1, 0);
        }
        quiet_border(iscn, quiet, x, y);

        movedelta(-1, 16);
        if(y >= h)
            break;

        zprintf(32, "img_x-: %03x,%03x @%p\n", x, y, p);
        while(x > 0) {
            ASSERT_POS;
            if(zebra_scan_y(iscn->scn, *p))
                symbol_handler(iscn, x, y);
            movedelta(-1, 0);
        }
        quiet_border(iscn, quiet, x, y);

        movedelta(1, 16);
#ifdef DEBUG_IMG_SCANNER
        break;
#endif
    }

#ifndef DEBUG_IMG_SCANNER
    x = y = 0;
    p = data;
    movedelta(8, 0);

    while(x < w) {
        zprintf(32, "img_y+: %03x,%03x @%p\n", x, y, p);
        while(y < h) {
            ASSERT_POS;
            if(zebra_scan_y(iscn->scn, *p))
                symbol_handler(iscn, x, y);
            movedelta(0, 1);
        }
        quiet_border(iscn, quiet, x, y);

        movedelta(16, -1);
        if(x >= w)
            break;

        zprintf(32, "img_y-: %03x,%03x @%p\n", x, y, p);
        while(y >= 0) {
            ASSERT_POS;
            if(zebra_scan_y(iscn->scn, *p))
                symbol_handler(iscn, x, y);
            movedelta(0, -1);
        }
        quiet_border(iscn, quiet, x, y);

        movedelta(16, 1);
    }
#endif

    /* flush scanner pipe */
    if(zebra_scanner_new_scan(iscn->scn))
        symbol_handler(iscn, x, y);

    /* release reference */
    zebra_image_destroy(img);
    return(iscn->img->nsyms);
}


Generated by  Doxygen 1.6.0   Back to index