zbar库中的zbar_scan_y函数

简介: zbar库中的zbar_scan_y函数
zbar_symbol_type_t zbar_scan_y (zbar_scanner_t *scn,
                                int y)
{
    /* FIXME calc and clip to max y range... */
    /* retrieve short value history */
    register int x = scn->x;
    register int y0_1 = scn->y0[(x - 1) & 3];
    register int y0_0 = y0_1;
    if(x) {
        /* update weighted moving average */
        y0_0 += ((int)((y - y0_1) * EWMA_WEIGHT)) >> ZBAR_FIXED;
        scn->y0[x & 3] = y0_0;
    }
    else
        y0_0 = y0_1 = scn->y0[0] = scn->y0[1] = scn->y0[2] = scn->y0[3] = y;
    register int y0_2 = scn->y0[(x - 2) & 3];
    register int y0_3 = scn->y0[(x - 3) & 3];
    /* 1st differential @ x-1 */
    register int y1_1 = y0_1 - y0_2;
    {
        register int y1_2 = y0_2 - y0_3;
        if((abs(y1_1) < abs(y1_2)) &&
           ((y1_1 >= 0) == (y1_2 >= 0)))
            y1_1 = y1_2;
    }
    /* 2nd differentials @ x-1 & x-2 */
    register int y2_1 = y0_0 - (y0_1 * 2) + y0_2;
    register int y2_2 = y0_1 - (y0_2 * 2) + y0_3;
    dprintf(1, "scan: x=%d y=%d y0=%d y1=%d y2=%d",
            x, y, y0_1, y1_1, y2_1);
    zbar_symbol_type_t edge = ZBAR_NONE;
    /* 2nd zero-crossing is 1st local min/max - could be edge */
    if((!y2_1 ||
        ((y2_1 > 0) ? y2_2 < 0 : y2_2 > 0)) &&
       (calc_thresh(scn) <= abs(y1_1)))
    {
        /* check for 1st sign change */
        char y1_rev = (scn->y1_sign > 0) ? y1_1 < 0 : y1_1 > 0;
        if(y1_rev)
            /* intensity change reversal - finalize previous edge */
            edge = process_edge(scn, y1_1);
        if(y1_rev || (abs(scn->y1_sign) < abs(y1_1))) {
            scn->y1_sign = y1_1;
            /* adaptive thresholding */
            /* start at multiple of new min/max */
            scn->y1_thresh = (abs(y1_1) * THRESH_INIT + ROUND) >> ZBAR_FIXED;
            dprintf(1, "\tthr=%d", scn->y1_thresh);
            if(scn->y1_thresh < scn->y1_min_thresh)
                scn->y1_thresh = scn->y1_min_thresh;
            /* update current edge */
            int d = y2_1 - y2_2;
            scn->cur_edge = 1 << ZBAR_FIXED;
            if(!d)
                scn->cur_edge >>= 1;
            else if(y2_1)
                /* interpolate zero crossing */
                scn->cur_edge -= ((y2_1 << ZBAR_FIXED) + 1) / d;
            scn->cur_edge += x << ZBAR_FIXED;
            dprintf(1, "\n");
        }
    }
    else
        dprintf(1, "\n");
    /* FIXME add fall-thru pass to decoder after heuristic "idle" period
       (eg, 6-8 * last width) */
    scn->x = x + 1;
    return(edge);
}
目录
相关文章
|
C语言 Android开发 Windows
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: &lt;stdio.h&gt;”错误的方法
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: &lt;stdio.h&gt;”错误的方法
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: &lt;stdio.h&gt;”错误的方法
用IAR打开STM8时,出现“Unable to create configuration 'Debug' using tool chain ‘STM8’
用IAR打开STM8时,出现“Unable to create configuration 'Debug' using tool chain ‘STM8’
445 0
|
开发工具 数据库 C++
Revit 2019 LookUp安装详解
Revit 2019 LookUp安装详解
Revit 2019 LookUp安装详解
jpeglib的jpeg_finish_compress函数疑似越界
jpeglib的jpeg_finish_compress函数疑似越界
53 0
关于 海思平台sample的demo中添加ffmpeg静态库(.a)报错误undefined reference toavpriv_pix_fmt_hps_avi等错误 的解决方法
关于 海思平台sample的demo中添加ffmpeg静态库(.a)报错误undefined reference toavpriv_pix_fmt_hps_avi等错误 的解决方法
关于 海思平台sample的demo中添加ffmpeg静态库(.a)报错误undefined reference toavpriv_pix_fmt_hps_avi等错误 的解决方法
Win系统 - Hands-Free 和 Stereo 区别?
Win系统 - Hands-Free 和 Stereo 区别?
359 0
Win系统 - Hands-Free 和 Stereo 区别?
|
人工智能 vr&ar
Atcoder--Candy Distribution II--前缀和+map
题目描述 There are N boxes arranged in a row from left to right. The i-th box from the left contains Ai candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l,r) that satisfy the following:
104 0
zbar中的zbar_scan_image 函数
zbar中的zbar_scan_image 函数
390 0
ZBAR库
ZBAR库
240 0