-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
58 lines (44 loc) · 1.18 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#include <time.h>
#include "pgm.h"
#include "lbp.h"
int main(int argc, char *argv[]){
if(argc < 2){
puts("Erro. Uso: ./main.exe <caminho do diretorio contendo as imagens pgm>");
exit(0);
}
clock_t inicio, fim;
double tempo_por_imagem, tempo_total=0;
FILE *fp;
if (!(fp = fopen("histogramas.csv","w"))){
perror("Erro. ao abrir o arquivo histogramas.csv");
exit(1);
}
fclose(fp);
DIR *dir;
struct dirent *larq;
struct pgm img;
dir = opendir(argv[1]);
char caminho_imagem[100];
int count = 0;
while ((larq = readdir(dir)) != NULL){
if (!(strstr(larq->d_name, ".pgm"))) continue;
img.primeiro_digito = larq->d_name[0];
sprintf(caminho_imagem, "%s/%s", argv[1], larq->d_name);
lerImagemPGM(&img, caminho_imagem);
inicio = clock();
salvarHistogramaLBP(&img);
fim = clock();
free(img.pDados);
printf("%03d imagens pgm\n", ++count);
tempo_por_imagem = (double)(fim - inicio) / CLOCKS_PER_SEC;
tempo_total += tempo_por_imagem;
}
closedir(dir);
printf("\nTempo Medio: %lf s\n",tempo_total/count);
printf("Tempo Total: %lf s\n\n",tempo_total);
return 0;
}