Exemplo n.º 1
0
int hrt_main (int argc, char **argv) 
{
    int flag;

    int i;

    // detection parameters
    float scaleFactor = 1.2;
    int minNeighbours = 3;
    int size;

    printf("-- entering main function --\r\n");

    printf("-- loading image --\r\n");

    MyImage imageObj;
    MyImage *image = &imageObj;

    flag = readPgm((char *)INPUT_FILENAME, image);
    if (flag == -1)
    {
        printf( "Unable to open input image\n");
        return 1;
    }

    printf("-- loading cascade classifier --\r\n");

    myCascade cascadeObj;
    myCascade *cascade = &cascadeObj;
    MySize minSize = {20, 20};
    MySize maxSize = {0, 0};

    // classifier properties
    cascade->n_stages=25;
    cascade->total_nodes=2913;
    cascade->orig_window_size.height = 24;
    cascade->orig_window_size.width = 24;

    readTextClassifier(cascade);

    struct MyRect *result[NUM] = {};

    //Load the program 
    hrt_cell_load_program_id(CELL, haar);

    hrt_scalar_store(CELL, MyImage, myimage, image);
    hrt_indexed_store(CELL, MySize, mysize, 0, minSize);
    hrt_indexed_store(CELL, MySize, mysize, 1, maxSize);
    hrt_scalar_store(CELL, myCascade, mycascade, cascade);
    hrt_scalar_store(CELL, float, scalefactor, scaleFactor);
    hrt_scalar_store(CELL, int, minneighbours, minNeighbours); 
    hrt_scalar_store(CELL, MyRect, myrect, result); 

    printf("-- detecting faces --\r\n");
    
    //size = detectObjects(image, minSize, maxSize, cascade, scaleFactor, minNeighbours, result);
    detectObjects();
    size = hrt_scalar_load(CELL, int, size);


    printf("-- drawing boxes --\r\n");
    for(i = 0; i < NUM; i++ )
    {
        if ( result[i] != NULL) {
            struct MyRect *r = result[i];
            drawRectangle(image, r);
        }
        else
            break;
    }

    printf("-- saving output --\r\n");
    flag = writePgm((char *)OUTPUT_FILENAME, image);

    printf("-- image saved --\r\n");

    //    delete image and free classifier
    releaseTextClassifier(cascade);
    freeImage(image);

    

    return 0;
}
Exemplo n.º 2
0
int main()
{
    readTextClassifier();
    return 0;
}