list_t * process_files(clinfo_t *clinfo, list_t * files, float threshold) { histogram_cache_descriptor_init(); list_t * similar_files = NULL; list_t * job_waits = NULL; Eina_Hash *map_histo; map_histo = read_histogram_file(CACHE_FILE); clean_inexistant_files(map_histo); job_waits = push_jobs(files, clinfo, map_histo); wait_for_jobs(job_waits, map_histo); list_release(job_waits); write_histogram_to_file(CACHE_FILE, map_histo); similar_files = process_job_results(map_histo, files, threshold); eina_hash_free(map_histo); clinfo_free(clinfo); histogram_cache_descriptor_shutdown(); return similar_files; }
void *read_all_histograms(edizinami ***all_histograms) { DIR *dp; struct dirent *ep; dp = opendir ("./faces/"); char *d; if (dp != NULL) { while (ep = readdir (dp)) { d = strstr(ep->d_name, ".txt"); if(d == NULL) { continue; } //printf("\tFile found! %s\n", ep->d_name); edizinami **tmp = realloc(*all_histograms, ++current_size * sizeof(char*)); if(NULL == tmp) { printf("Cannot alllocate memory"); exit(-1); } *all_histograms = tmp; edizinami *histogram = malloc(1 * sizeof(edizinami)); histogram->filename = malloc((strlen(ep->d_name) + 9) * sizeof(char)); strcpy(histogram->filename, "./faces/"); strcat(histogram->filename, ep->d_name); histogram->data = read_histogram_file(histogram->filename); if(NULL == histogram->data) { printf("Fatal Error!!!!!"); exit(-1); } histogram->fob = 1; (*all_histograms)[current_size-1] = histogram; } } else { printf("Couldn't open the directory"); return NULL; } closedir(dp); //Non-face histograms dp = opendir ("./nonfaces/"); if (dp != NULL) { while (ep = readdir (dp)) { d = strstr(ep->d_name, ".txt"); if(d == NULL) { continue; } //printf("\tFile found! %s\n", ep->d_name); edizinami **tmp = realloc(*all_histograms, ++current_size * sizeof(char*)); if(NULL == tmp) { printf("Cannot alllocate memory"); exit(-1); } *all_histograms = tmp; edizinami *histogram = malloc(1 * sizeof(edizinami)); histogram->filename = malloc((strlen(ep->d_name) + 12) * sizeof(char)); strcpy(histogram->filename, "./nonfaces/"); strcat(histogram->filename, ep->d_name); histogram->data = read_histogram_file(histogram->filename); if(NULL == histogram->data) { printf("Fatal Error!!!!!"); exit(-1); } histogram->fob = 0; (*all_histograms)[current_size-1] = histogram; } } else { printf("Couldn't open the directory"); return NULL; } closedir(dp); return NULL; }