arunreddy
9/19/2014 - 11:44 AM

Calculate number of haar features - Viola Jones Face Detection.

Calculate number of haar features - Viola Jones Face Detection.

#include <stdio.h>
int main()
{
    int i, x, y, sizeX, sizeY, width, height, count, c;

    /* All five shape types */
    const int features = 5;
    const int feature[][2] = {{2,1}, {1,2}, {3,1}, {1,3}, {2,2}};
    const int frameSize = 24;

    count = 0;
    int shapeCount = 0;
    /* Each shape */
    for (i = 0; i < features; i++) {
        sizeX = feature[i][0];
        sizeY = feature[i][1];
        printf("%dx%d shapes:\n", sizeX, sizeY);

        /* each size (multiples of basic shapes) */
        for (width = sizeX; width <= frameSize; width+=sizeX) {
            for (height = sizeY; height <= frameSize; height+=sizeY) {
                printf("\tsize: %dx%d => ", width, height);
                c=count;

                /* each possible position given size */
                for (x = 0; x <= frameSize-width; x++) {
                    for (y = 0; y <= frameSize-height; y++) {
                        count++;
			shapeCount++;
                    }
                }
                printf("count: %d\n", count-c);
            }
        }
        printf("%dx%d shapes count: %d\n", sizeX, sizeY,shapeCount);
	shapeCount=0;
    }
    printf("%d\n", count);

    return 0;
}