-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.c
executable file
·87 lines (62 loc) · 1.56 KB
/
convert.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "image.h"
#include <sys/types.h>
#include <dirent.h>
typedef struct
{
unsigned char id;
int size;
}input;
int main(int argc, char const *argv[])
{
int id=0;
struct dirent *dc,*rdc;
image img;
input inp;
DIR *dp,*rp;
char raw_folder[200];
strcpy(img.inputs_file,INPUTS_FILE);
img_init(&img);
dp = opendir (RAWS_FOLDER);
remove(INPUTS_FILE);
while((dc=readdir(dp))){
if(strcmp(dc->d_name,".")!=0 && strcmp(dc->d_name,"..")!=0){
strcpy(raw_folder,RAWS_FOLDER);
strcat(raw_folder,dc->d_name);
strcat(raw_folder,"/");
printf("%s\n", raw_folder);
rp = opendir (raw_folder);
while((rdc=readdir(rp))){
if(strcmp(rdc->d_name,".")!=0 && strcmp(rdc->d_name,"..")!=0){
// Image open and read
printf("Resim okunuyor...\n");
strcpy(img.folder,raw_folder);
strcpy(img.file,rdc->d_name);
img_read(&img);
// Do Image map
printf("Map oluşturmaya başla.\n");
img_map(&img);
// Do Image hash
printf("Hash oluşturmaya başla.\n");
img_hash(&img);
// Hash Kaydediliyor
printf("Hash kaydediliyor...\n");
FILE* f = fopen(INPUTS_FILE, "ab");
inp.id = atoi(rdc->d_name);
inp.size = img.hashsize;
//inp.input_data = (float*) calloc(img.hashsize,sizeof(float));
//memcpy(&inp.input_data,&img.hash,inp.size);
fwrite(&inp, sizeof(inp),1, f);
fwrite(&img.hash,img.hashsize,1,f);
fclose(f);
printf("%d %d\n",img.hashsize,inp.id);
}
}
id++;
}
}
return 0;
}