Skip to content

Instantly share code, notes, and snippets.

@arunreddy
Created September 19, 2014 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arunreddy/73cb0023059d69f0d1e2 to your computer and use it in GitHub Desktop.
Save arunreddy/73cb0023059d69f0d1e2 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment