コード例 #1
0
ファイル: test.c プロジェクト: 8l/mxp
int compare_gen_integrals_to_vector_get_img(unsigned short* img, unsigned int* iImg, unsigned int* iiImg, unsigned short* vbx_img, unsigned int* vbx_iImg, unsigned int* vbx_iiImg, pixel* vbx_input, int width, int height, int max_print_errors)
{
    int j, errors = 0;

    gen_integrals(img, iImg, iiImg, width, height);
    /* bin is 1*/
	vector_get_img(vbx_img, vbx_iImg, vbx_iiImg, vbx_input, 1, width, height, width, 1);

    /* test greyscale image */
    for (j = 0; j < height; j++) {
        errors += match_array_half(img+j*width, vbx_img+j*width, "greyscale", width, 1, 0, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    /* test integral image */
    for (j = 0; j < height; j++) {
        errors += match_array_word(iImg+j*width, vbx_iImg+j*width, "integral", width, 1, 0, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    /* test squared integral image */
    for (j = 0; j < height; j++) {
        errors += match_array_word(iiImg+j*width, vbx_iiImg+j*width, "squared", width, 1, 0, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }
    return errors;
}
コード例 #2
0
ファイル: test.c プロジェクト: 8l/mxp
int compare_ScalarLBPRestrictedPatterns_to_SATBinaryPattern(unsigned short *vbx_img, int log, int width, int height, int max_print_errors)
{
    int l, i, j, cell, errors = 0;

    /* generate patterns */
    unsigned short **sums = ScalarLBPRestrictedSums(vbx_img, width, height, log);
    unsigned char **patterns = ScalarLBPRestrictedPatterns(sums, width, height, log);

    unsigned char **sat_patterns = (unsigned char**)vbx_shared_malloc((log+1)*sizeof(unsigned char*));
    for (l=0; l<log+1; l++) {
        sat_patterns[l] = (unsigned char*)vbx_shared_malloc(width*height*sizeof(unsigned char));
    }

    unsigned int *iImg, *iiImg;
    iImg = (unsigned int *)vbx_shared_malloc(width*height*sizeof(unsigned int));
    iiImg = (unsigned int *)vbx_shared_malloc(width*height*sizeof(unsigned int));
    gen_integrals(vbx_img, iImg, iiImg, width, height);

    image_t lbp_img = {iImg, {width, height}};
    for (l=0; l<log+1; l++) {
        cell = 1 << l;
        lbp_feat_t lbp_feat = {{{0, 0}, {cell, cell}}, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
        for (j = 0; j < height - (3*cell-1); j++) {
            for (i = 0; i < width - (3*cell-1); i++) {
                pair_t lbp_p = {i, j};
                sat_patterns[l][j*width+i] = SATBinaryPattern(lbp_img, &lbp_feat, lbp_p);
            }
        }
    }

    /* test patterns vs sat binary patterns */
    for (l=0; l<log+1; l++) {
        cell = 1 << l;
        for (j = 0; j < height - (3*cell-1); j++) {
            errors += match_array_byte(patterns[l] + j*width, sat_patterns[l] + j*width, "patterns", width - (3*cell-1), 1, 0, max_print_errors, 1, j);
            if (errors > max_print_errors){
                max_print_errors = 0;
            }
        }
    }
    return errors;
}
コード例 #3
0
ファイル: test.c プロジェクト: 8l/mxp
//FIXME stride for match not implemented
int compare_LBPPassStage_to_restricted(unsigned short *vbx_img, int log, lbp_stage_t lbp_stage, int window, int width, int height, int max_print_errors)
{
    int l, i, j, cell, errors = 0;

    unsigned char** scalar_patterns = test_scalar_patterns(vbx_img, log, width, height);

    unsigned char *pass, *vbx_pass;
    pass = (unsigned char*)vbx_shared_malloc(width*height*sizeof(unsigned char));
    vbx_pass = (unsigned char*)vbx_shared_malloc(width*height*sizeof(unsigned char));
    
    vbx_byte_t** v_lbp =(vbx_byte_t**)vbx_shared_malloc((log+1)*sizeof(vbx_byte_t*));
    for (l=0; l<log+1; l++) {
        v_lbp[l] = (vbx_byte_t*)vbx_sp_malloc((window+1)*width*sizeof(vbx_byte_t)); 
    }
    vbx_byte_t* v_lut = (vbx_byte_t*)vbx_sp_malloc(width*sizeof(vbx_byte_t)); 
    vbx_byte_t* v_stage = (vbx_byte_t*)vbx_sp_malloc(width*sizeof(vbx_byte_t)); 
    vbx_byte_t* v_pattern;
    lbp_feat_t feat;
    int dx, dy, dw, f;

    for (l=0; l<log+1; l++) {
        vbx_dma_to_vector(v_lbp[l]+width, scalar_patterns[l], (window)*width*sizeof(unsigned char));
    }
    vbx_sync();
    for(j=0; j < height-(window+1); j++) {
        for (l=0; l<log+1; l++) {
            vbx_set_vl(width * window);
            vbx(VVB, VMOV, v_lbp[l], v_lbp[l]+width, NULL);
            vbx_dma_to_vector(v_lbp[l] + window*width, scalar_patterns[l]+(j+window)*width, width*sizeof(unsigned char));
        }

        vbx_set_vl(width-(window+1));
        vbx(SVB, VMOV, v_stage, 0, NULL);
        for (f = 0; f < lbp_stage.count; f++) {
            feat = lbp_stage.feats[f];
            dx = feat.pos.src.x;
            dy = feat.pos.src.y;
            dw = feat.pos.size.x;
            v_pattern = v_lbp[dw>>1]+(dy*width+dx);

            vbx(SVBU, VLBPLUT, v_lut, f, v_pattern);
            vbx(VVB, VADD, v_stage, v_stage, v_lut);
        }
        vbx(SVB, VMOV, v_lut, 0, NULL);
        vbx(SVB, VCMV_GEZ, v_lut, 1, v_stage);
        vbx_dma_to_host(vbx_pass + j*width, v_lut, (width-(window+1))*sizeof(unsigned char));
        vbx_sync();
    }


    unsigned int *iImg, *iiImg;
    iImg = (unsigned int *)vbx_shared_malloc(width*height*sizeof(unsigned int));
    iiImg = (unsigned int *)vbx_shared_malloc(width*height*sizeof(unsigned int));

    gen_integrals(vbx_img, iImg, iiImg, width, height);

    image_t lbp_img = {iImg, {width, height}};
    for (j = 0; j < height - (window + 1); j++) {
        for (i = 0; i < width - (window + 1); i++) {
            pair_t lbp_p = {i, j};
            pass[j*width+i] = LBPPassStage(lbp_img, lbp_stage, lbp_p);
        }
    }

    /* test pass vs vbx pass */
    for (j = 0; j < height - (window + 1); j++) {
        errors += match_array_byte(vbx_pass + j*width, pass + j*width, "pass stage", width - (window + 1), 1, 0, max_print_errors, 1, j);
        if (errors > max_print_errors){
            max_print_errors = 0;
        }
    }
    return errors;
}
コード例 #4
0
ファイル: test.c プロジェクト: 8l/mxp
int compare_scalar_BLIP2_to_vector_BLIP(unsigned short* img, pixel* vbx_input, int width, int height, int max_print_errors, int scale_factor)
{
    int j, errors = 0;
    int scaled_width, scaled_height;

    /* scale facetor v/v+1, v is between 1-10 */
    scaled_width = width*scale_factor/(scale_factor+1);
    scaled_height= height*scale_factor/(scale_factor+1);

    unsigned short *scaled_img, *vbx_img, *vbx_scaled_img; 
    unsigned char *vbx_img8, *vbx_scaled_img8;
    unsigned int *iImg, *iiImg, *vbx_iImg, *vbx_iiImg;

    scaled_img = (unsigned short*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned short));

    iImg = (unsigned int*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned int));
    iiImg = (unsigned int*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned int));

    vbx_scaled_img = (unsigned short*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned short));
    vbx_img = (unsigned short*)vbx_shared_malloc(width*height*sizeof(unsigned short));
    vbx_img8 = (unsigned char*)vbx_shared_malloc(width*height*sizeof(unsigned char));
    vbx_scaled_img8 = (unsigned char*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned char));

    vbx_iImg = (unsigned int*)vbx_shared_malloc(width*height*sizeof(unsigned int));
    vbx_iiImg = (unsigned int*)vbx_shared_malloc(width*height*sizeof(unsigned int));


#if 0
    scalar_BLIP2(img, height, width, scaled_img, scaled_height, scaled_width, scale_factor);
#else
    float percent = 1.0 * (scale_factor+1) / scale_factor;
    scalar_BLIP(img, height, width, scaled_img, scaled_height, scaled_width, &percent);
#endif
    gen_integrals(scaled_img, iImg, iiImg, scaled_width, scaled_height);

	vector_get_img(vbx_img, vbx_iImg, vbx_iiImg, vbx_input, 1, width, height, width, 1);
    vector_BLIP(vbx_img, height, width, vbx_scaled_img, vbx_iImg, vbx_iiImg, scaled_height, scaled_width, scale_factor, 1);
	vector_get_img8(vbx_img8, vbx_input, 1, width, height, width);
    /* vector_BLIP8(vbx_img8, height, width, vbx_scaled_img8, scaled_height, scaled_width, scale_factor); */
	vbx_timestamp_start();
	vbx_timestamp_t time_start, time_stop;
    double vbx_time;
    time_start = vbx_timestamp();
#if 1
    vector_BLIP8F3(vbx_img8, height, width, vbx_scaled_img8, scaled_height, scaled_width, scale_factor);
#else
    vector_BLIP8F2(vbx_img8, height, width, vbx_scaled_img8, scaled_height, scaled_width, scale_factor);
#endif
    time_stop = vbx_timestamp();
    vbx_time = vbx_print_vector_time(time_start, time_stop, 0.0);

    /* test greyscale image */
    for (j = 0; j < height; j++) {
        errors += match_array_half(img+j*width, vbx_img+j*width, "greyscale", width, 1, 0, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    /* test scaled image */
    for (j = 0; j < scaled_height; j++) {
        errors += match_array_half(scaled_img+j*scaled_width, vbx_scaled_img+j*scaled_width, "scaled greyscale", scaled_width, 1, 1, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    for (j = 0; j < scaled_height; j++) {
        errors += match_array_half_byte(scaled_img+j*scaled_width, vbx_scaled_img8+j*scaled_width, "scaled greyscale8", scaled_width, 1, 1, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

#if 0
    /* test scaled_integral image */
    for (j = 0; j < scaled_height; j++) {
        errors += match_array_word(iImg+j*scaled_width, vbx_iImg+j*scaled_width, "scaled integral", scaled_width, 1, 0, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    /* test scaled squared integral image */
    for (j = 0; j < scaled_height; j++) {
        errors += match_array_word(iiImg+j*scaled_width, vbx_iiImg+j*scaled_width, "scaled squared", scaled_width, 1, 0, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }
#endif

    /* test scaled_integral image */
    return errors;
}
コード例 #5
0
ファイル: test.c プロジェクト: cirqueit/mxp
int compare_scalar_BLIP2_to_vector_BLIP(unsigned short* img, pixel* vbx_input, int width, int height, int max_print_errors)
{
    int j, errors = 0;
    int value, scaled_width, scaled_height;

    /* scale facetor v/v+1, v is between 1-10 */
    value = 3; //BAD 2,5,6,8
    scaled_width = width*value/(value+1);
    scaled_height= height*value/(value+1);

    unsigned short *scaled_img, *vbx_img, *vbx_scaled_img;
    unsigned int *iImg, *iiImg, *vbx_iImg, *vbx_iiImg;

    scaled_img = (unsigned short*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned short));

    iImg = (unsigned int*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned int));
    iiImg = (unsigned int*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned int));

    vbx_scaled_img = (unsigned short*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned short));
    vbx_img = (unsigned short*)vbx_shared_malloc(width*height*sizeof(unsigned short));

    vbx_iImg = (unsigned int*)vbx_shared_malloc(width*height*sizeof(unsigned int));
    vbx_iiImg = (unsigned int*)vbx_shared_malloc(width*height*sizeof(unsigned int));


    scalar_BLIP2(img, height, width, scaled_img, scaled_height, scaled_width, value);
    gen_integrals(scaled_img, iImg, iiImg, scaled_width, scaled_height);

	vector_get_img(vbx_img, vbx_iImg, vbx_iiImg, vbx_input, 1, width, height, width, 1);
    vector_BLIP(vbx_img, height, width, vbx_scaled_img, vbx_iImg, vbx_iiImg, scaled_height, scaled_width, value, 1);

    /* test greyscale image */
    for (j = 0; j < height; j++) {
        errors += match_array_half(img+j*width, vbx_img+j*width, "greyscale", width, 1, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    /* test scaled image */
    for (j = 0; j < scaled_height; j++) {
        errors += match_array_half(scaled_img+j*scaled_width, vbx_scaled_img+j*scaled_width, "scaled greyscale", scaled_width, 1, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    /* test scaled_integral image */
    for (j = 0; j < scaled_height; j++) {
        errors += match_array_word(iImg+j*scaled_width, vbx_iImg+j*scaled_width, "scaled integral", scaled_width, 1, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }

    /* test scaled squared integral image */
    for (j = 0; j < scaled_height; j++) {
        errors += match_array_word(iiImg+j*scaled_width, vbx_iiImg+j*scaled_width, "scaled squared", scaled_width, 1, max_print_errors, j);
        if(errors > max_print_errors) {
            max_print_errors = 0;
        }
    }
    return errors;
}