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
| Dans le main :
float **keys = new float *[num_images];
int* num_keys= new int[num_images];
loadKeys((ANNcoord **)keys, num_keys, num_images, key_files);
//Test valeurs sortie
for (i = 0; i < num_images; i++) {
for (j=0; j<num_keys[i]*128; j++)
qDebug() << keys[i][j];
}
_______
void loadKeys(ANNcoord **keys, int *num_keys, int num_images, std::vector<QString> key_files){
for (int i = 0; i < num_images; i++) {
keys[i] = NULL;
num_keys[i] = ReadKeys(key_files[i], keys+i);
}
}
_______
int ReadKeys(QString filename, ANNcoord **keys, keypt_t **info = NULL)
{
QFile fichier(filename);
if (!fichier.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "Error: could not open " << filename;
return 0;
}
QTextStream flux(&fichier);
std::vector<Keypoint *> kps;
int num = -1, len = -1;
flux >> num >> len;
if ((num == -1) || (len == -1)) {
printf("Invalid keypoint file\n");
return 0;
}
if (len != 128) {
printf("Keypoint descriptor length invalid (should be 128).");
return 0;
}
*keys = new ANNcoord[128 * num]; //ANNcoord = double
for (int i = 0; i < num; i++) {
flux.readLine();
QString ligne = flux.readLine();
for(int a = 0; a < 6;a++)
ligne += flux.readLine();
QStringList values = ligne.trimmed().split(QString(" "));
for (int b = 0; b < 128; ++b) {
(*keys)[128 * i + b] = values.at(b).toDouble();
}
}
//Test valeurs sortie
for (int b = 0; b < 128*num; b++){
qDebug() << (*keys)[b];
}
return num;
} |