From f9006166b69ffc0a70b2351bd942b17f0e72f1a9 Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Mon, 1 Oct 2012 09:25:45 -0400 Subject: use the C++/openCV version of our background generator now, delete the old C implementation and updated the makefile accordingly --- fly-tools/Makefile | 10 +- fly-tools/background/main.c | 218 -------------------------------------------- 2 files changed, 5 insertions(+), 223 deletions(-) delete mode 100644 fly-tools/background/main.c (limited to 'fly-tools') diff --git a/fly-tools/Makefile b/fly-tools/Makefile index eea1a76..ab33ac1 100644 --- a/fly-tools/Makefile +++ b/fly-tools/Makefile @@ -1,17 +1,17 @@ CPPC = g++ CC = gcc -CFLAGS= -O2 -Wall -s -Wextra -CPPFLAGS= -O2 -Wall -s -Wextra +CFLAGS= -O2 -Wall -s -Wextra -mtune=native +CPPFLAGS= -O2 -Wall -s -Wextra -mtune=native MAGICKCPPFLAGS = $(shell pkg-config --cflags --libs ImageMagick++ gsl) MAGICKCFLAGS = $(shell pkg-config --cflags --libs MagickWand ) CVBLOBCPPFLAGS = $(shell pkg-config --cflags --libs opencv cvblob ) - +CVCPPFLAGS = $(shell pkg-config --cflags --libs opencv) all: FilterFlyMask FlyTrackingMain mask-generator derive-background standard-deviation filter-mask derive-background: - $(CC) background/main.c -std=c99 -o derive-background $(CFLAGS) $(MAGICKCFLAGS) + $(CC) background/main.cpp -o derive-background $(CPPFLAGS) $(CVCPPFLAGS) filter-mask: - $(CPPC) filter/main.cpp -o filter-mask $(CPPFLAGS) $(CVBLOBCPPFLAGS) + $(CPPC) filter/main.cpp -o filter-mask $(CPPFLAGS) $(CVBLOBCPPFLAGS) $(CVCPPFLAGS) mask-generator: $(CC) mask/main.c mask/thpool.c -I./mask/ -o mask-generator $(CFLAGS) $(MAGICKCFLAGS) -pthread standard-deviation: diff --git a/fly-tools/background/main.c b/fly-tools/background/main.c deleted file mode 100644 index 18fcc29..0000000 --- a/fly-tools/background/main.c +++ /dev/null @@ -1,218 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#define round(x)((int)((x)+0.5)) -#define ThrowWandException(wand) { char *description; ExceptionType severity; description=MagickGetException(wand,&severity); (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); description=(char *) MagickRelinquishMemory(description); exit(-1); } -#define array(i,j,k,l) (array[height*width*i + width*j + k + l]) - -int nImages; -unsigned long height; -unsigned long width; - -int findmax (uint8_t *p, int n) { - int mx = 0, v = p[0]; - for (int i = 1; i < n; i++) { - if (p[i] > v) { - v = p[i]; - mx = i; - } - } - return mx; -} - -int main(int argc, char **argv ) { - - char *usage = "derive-background -i -o "; - char *output_file = NULL; - char *image_list = NULL; - int c; - - while ((c = getopt (argc, argv, "i:o:h")) != -1) - switch (c) { - case 'i': - image_list = optarg; - break; - case 'o': - output_file = optarg; - break; - case 'h': - puts(usage); - exit(1); - break; - default: - break; - } - - if( image_list == NULL || output_file == NULL ) { - puts(usage); - exit(1); - } - - MagickWand *input_wand, *first_wand, *output_wand; - PixelIterator *input_iterator, *output_iterator; - PixelWand **pixels, *p_out; - - double green, red, blue; - - int i,j, k; - int image = 0; - - char filename[256]; - char rgb[128]; - char *temp; - - FILE *input_file; - - uint8_t ***output; - - MagickWandGenesis(); - - // open first image in input_file to deterimine the height and width - input_file = fopen( image_list, "r"); - if(input_file != NULL) { - fgets(filename, sizeof(filename), input_file); - temp = strchr(filename, '\n'); - if (temp != NULL) *temp = '\0'; - } else { - printf("could not open file \n"); - exit(1); - } - fclose(input_file); - - first_wand = NewMagickWand(); - if(MagickReadImage(first_wand, filename) == MagickFalse) { - ThrowWandException(first_wand); - } - - int height = MagickGetImageHeight(first_wand); - int width = MagickGetImageWidth(first_wand); - - if (height == 0 || width == 0) { - puts("height/or width is 0!"); - exit(1); - } - - first_wand = DestroyMagickWand(first_wand); - - printf("height: %d width:%d \n", height, width); - - // count number of images we have in the file - input_file = fopen( image_list, "r"); - while((fgets(filename, sizeof(filename), input_file)) != NULL) { - nImages++; - } - fclose(input_file); - - printf("number of images: %d \n", nImages); - - // initialize the storage arrays - uint8_t * array = (uint8_t *)malloc(nImages*height*width*3*sizeof(uint8_t)); - - output = calloc(height, sizeof(output[0])); - for(i = 0; i < height; i++) { - output[i] = calloc(width, sizeof(output[0][0])); - for(j = 0; j < width; j++) { - output[i][j] = calloc(3, sizeof(output[0][0][0])); - } - } - - // store each pixel in the storage array. array(nImages,height,width,{ R, G, B} ) - input_file = fopen( image_list, "r"); - if(input_file == NULL ) { - printf("error could not open input file"); - exit(1); - } - - while ((fgets(filename, sizeof(filename), input_file)) != NULL ) { - - temp = strchr(filename, '\n'); - if (temp != NULL) *temp = '\0'; - - input_wand = NewMagickWand(); - MagickReadImage(input_wand, filename); - - input_iterator = NewPixelIterator(input_wand); - - printf("Image number:%d Filename: %s \n", image, filename); - for (i=0; i