/
testproc.c
85 lines (67 loc) · 3.23 KB
/
testproc.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
#include <stdio.h>
#include <stdlib.h>
#include "cgiu.h"
#include "proc.h"
#define DEBUG 1
void exitfail()
{
print_html_tail();
exit(0);
}
int main(int argc, char *argv[])
{
int x,m;
char *qs;
entry *entries;
int nbTrain,nbVal,nbDims,nbConcepts,c,**trainAnns,**valAnns,ret;
char **trainList,**valList,**concepts,*name;
float **trainDescriptors,**valDescriptors;
/* récupération de la chaîne de paramètres */
qs = get_query_string(argc,argv);
/* récupération des couples (nom,valeur) */
entries = get_entries(qs,&m);
/* émission de l'entête */
print_html_head("Résultat");
/* affichage éventuel des informations de debug */
if (DEBUG) print_debug_query(entries,m,qs,argc,argv);
trainList = readList("/usr/lib/cgi-bin/RIM/images/train/list.txt",&nbTrain);
if (trainList == NULL) {printf("Failed to read %s file.\n","train/list.txt"); exitfail();}
if (DEBUG) printf("Read train list, %d images.<BR>\n",nbTrain);
valList = readList("/usr/lib/cgi-bin/RIM/images/val/list.txt",&nbVal);
if (valList == NULL) {printf("Failed to read %s file.\n","val/list.txt"); exitfail();}
if (DEBUG) printf("Read val list, %d images.<BR>\n",nbVal);
trainDescriptors = readDescriptors("/usr/lib/cgi-bin/RIM/images/train/descriptors.bin",nbTrain,&nbDims);
if (trainDescriptors == NULL) {printf("Failed to read %s file.\n","train/descriptors.bin"); exitfail();}
if (DEBUG) printf("Read train descripors, %d images, %d dimensions.<BR>\n",nbTrain,nbDims);
valDescriptors = readDescriptors("/usr/lib/cgi-bin/RIM/images/val/descriptors.bin",nbVal,&nbDims);
if (valDescriptors == NULL) {printf("Failed to read %s file.\n","val/descriptors.bin"); exitfail();}
if (DEBUG) printf("Read val descripors, %d images, %d dimensions.<BR>\n",nbVal,nbDims);
concepts = readList("/usr/lib/cgi-bin/RIM/images/concepts.txt",&nbConcepts);
if (concepts == NULL) {printf("Failed to read %s file.\n","concepts.txt"); exitfail();}
if (DEBUG) printf("Read concept list, %d concepts.<BR>\n",nbConcepts);
trainAnns = malloc(nbConcepts*sizeof(int *));
if (trainAnns == NULL) {printf("malloc() failed.\n"); exitfail();}
if (DEBUG) printf("Read train annotations:");
for (c = 0; c < nbConcepts; c ++) {
ret = asprintf(&name,"/usr/lib/cgi-bin/RIM/images/train/ann/%s.ann",concepts[c]);
if (ret < 0) {printf("asprintf() failed.\n"); exitfail();}
trainAnns[c] = readAnnotations(name,nbTrain);
if (trainAnns[c] == NULL) {printf("Failed to read train/ann%s.ann file.\n",concepts[c]); exitfail();}
if (DEBUG) printf(" %s",concepts[c]);
}
if (DEBUG) printf(".<BR>\n");
valAnns = malloc(nbConcepts*sizeof(int *));
if (valAnns == NULL) {printf("malloc() failed.\n"); exitfail();}
if (DEBUG) printf("Read val annotations:");
for (c = 0; c < nbConcepts; c ++) {
ret = asprintf(&name,"/usr/lib/cgi-bin/RIM/images/val/ann/%s.ann",concepts[c]);
if (ret < 0) {printf("asprintf() failed.\n"); exitfail();}
valAnns[c] = readAnnotations(name,nbVal);
if (valAnns[c] == NULL) {printf("Failed to read val/ann%s.ann file.\n",concepts[c]); exitfail();}
if (DEBUG) printf(" %s",concepts[c]);
}
if (DEBUG) printf(".<BR>\n");
/* émission de la fin de corps et de document */
print_html_tail();
exit(0);
}