int main(int argc, char **argv) { // Setting default parameters int n_hist = 4; int n_ori = 8; int n_bins = 36; int meth_flag = 1; float thresh = 0.6; int verb_flag = 0; char label[256]; strcpy(label, "extra"); // Parsing command line int res = parse_options(argc, argv, &n_bins, &n_hist, &n_ori, &meth_flag, &thresh, &verb_flag, label); if (res == EXIT_FAILURE) return EXIT_FAILURE; // Memory allocation struct sift_keypoints* k1 = sift_malloc_keypoints(); struct sift_keypoints* k2 = sift_malloc_keypoints(); struct sift_keypoints* out_k1 = sift_malloc_keypoints(); struct sift_keypoints* out_k2A = sift_malloc_keypoints(); struct sift_keypoints* out_k2B = sift_malloc_keypoints(); // Read input keypoint ASCII files int readflag = verb_flag + 1; sift_read_keypoints(k1, argv[1], n_hist, n_ori, n_bins, readflag); sift_read_keypoints(k2, argv[2], n_hist, n_ori, n_bins, readflag); debug("size read keys / k1 %i / k2 %i /", k1->size, k2->size); // Matching matching(k1, k2, out_k1, out_k2A, out_k2B, thresh, meth_flag); // Print print_pairs(out_k1, out_k2A); char name[FILENAME_MAX]; if(verb_flag == 1){ save_pairs_extra("OUTmatches.txt", out_k1, out_k2A, out_k2B); sprintf(name, "%s_im0.txt", label); sift_save_keypoints(out_k1, name, 1); sprintf(name, "%s_im1.txt", label); sift_save_keypoints(out_k2A, name, 1); } // Free memory sift_free_keypoints(k1); sift_free_keypoints(k2); sift_free_keypoints(out_k1); sift_free_keypoints(out_k2A); sift_free_keypoints(out_k2B); return EXIT_SUCCESS; }
struct sift_keypoint_std *sift_read_keyslocation_from_file(char *filename, int *n) { struct sift_parameters* p = sift_assign_default_parameters(); int n_ori = p->n_ori; // 8 int n_hist = p->n_hist; // 4 int l = n_hist*n_hist*n_ori; int n_bins = p->n_bins; // read keypoints locations from a file and // save them into a sift_keypoints structure struct sift_keypoints* keys = sift_malloc_keypoints(); int flag = 0; // read coordinates sift_read_keypoints(keys, filename, n_hist, n_ori, n_bins, flag); // translate the sift_keypoints structure into a flat list *n = keys->size; struct sift_keypoint_std* k = xmalloc((*n)*sizeof(struct sift_keypoint_std)); for(int i = 0; i < keys->size; i++){ k[i].x = keys->list[i]->x; k[i].y = keys->list[i]->y; k[i].scale = keys->list[i]->sigma; k[i].orientation = keys->list[i]->theta; // 0 for(int j=0; j<l; j++){ k[i].descriptor[j] = keys->list[i]->descr[j]; // 0 } } sift_free_keypoints(keys); return k; }