diff --git a/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp b/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp index 487a979..3f87d2f 100644 --- a/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp +++ b/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp @@ -59,11 +59,130 @@ bool ASIFT_matcher::addReference(const char* image_path, unsigned int num_tilts) gray(x,y,0,0) = grayValueWeight; } - vector ipixels1; + std::vector ipixels1; size_t w1=gray.width(), h1=gray.height(); ipixels1.assign(gray.begin(), gray.end()); - ///// Resize the images to area wS*hW in remaining the apsect-ratio + std::cout<<"Building reference from "<< image_path << std::endl; + + return addReference(ipixels1, w1, h1, num_tilts); + // ///// Resize the images to area wS*hW in remaining the apsect-ratio + // ///// Resize if the resize flag is not set or if the flag is set unequal to 0 + // float wS = IM_X; + // float hS = IM_Y; + + // float zoom1=0; + // int wS1=0, hS1=0; + // vector ipixels1_zoom; + + // if(_resize_imgs) + // { + // cout << "WARNING: The input image is resized to " << wS << "x" << hS << " for ASIFT. " << endl + // << " But the results will be normalized to the original image size." << endl << endl; + + // float InitSigma_aa = 1.6; + + // float fproj_p, fproj_bg; + // char fproj_i; + // float *fproj_x4, *fproj_y4; + // int fproj_o; + + // fproj_o = 3; + // fproj_p = 0; + // fproj_i = 0; + // fproj_bg = 0; + // fproj_x4 = 0; + // fproj_y4 = 0; + + // float areaS = wS * hS; + + // // Resize image 1 + // float area1 = w1 * h1; + // zoom1 = sqrt(area1/areaS); + + // wS1 = (int) (w1 / zoom1); + // hS1 = (int) (h1 / zoom1); + + // int fproj_sx = wS1; + // int fproj_sy = hS1; + + // float fproj_x1 = 0; + // float fproj_y1 = 0; + // float fproj_x2 = wS1; + // float fproj_y2 = 0; + // float fproj_x3 = 0; + // float fproj_y3 = hS1; + + // /* Anti-aliasing filtering along vertical direction */ + // if ( zoom1 > 1 ) + // { + // float sigma_aa = InitSigma_aa * zoom1 / 2; + // GaussianBlur1D(ipixels1,w1,h1,sigma_aa,1); + // GaussianBlur1D(ipixels1,w1,h1,sigma_aa,0); + // } + + // // simulate a tilt: subsample the image along the vertical axis by a factor of t. + // ipixels1_zoom.resize(wS1*hS1); + // fproj (ipixels1, ipixels1_zoom, w1, h1, &fproj_sx, &fproj_sy, &fproj_bg, &fproj_o, &fproj_p, + // &fproj_i , fproj_x1 , fproj_y1 , fproj_x2 , fproj_y2 , fproj_x3 , fproj_y3, fproj_x4, fproj_y4); + // } + // else + // { + // ipixels1_zoom.resize(w1*h1); + // ipixels1_zoom = ipixels1; + // wS1 = w1; + // hS1 = h1; + // zoom1 = 1; + // } + + // // image new_ref; + // // new_ref.img = ipixels1_zoom; + // // new_ref.width = wS1; + // // new_ref.height = hS1; + + + // ///// Compute ASIFT keypoints + // asift_keypoints keys; + // // vector< vector< keypointslist > >* keys = new vector< vector< keypointslist > >; + // int num_keys = 0; + + // time_t tstart, tend; + // tstart = time(0); + + // num_keys = compute_asift_keypoints(ipixels1_zoom, wS1, hS1, num_tilts, _showDebug, keys, _siftParam); + + // tend = time(0); + + // //Save data + // _im_refs.push_back(ipixels1_zoom); + // _size_refs.push_back(make_pair(wS1,hS1)); + // _zoom_refs.push_back(zoom1); + + // _num_keys.push_back(num_keys); + // _num_tilts.push_back(num_tilts); + // _keys.push_back(keys); + + // _nb_refs++; + + // cout<<"Reference built in "<< difftime(tend, tstart) << " seconds." << endl; + // cout<<" "<< num_keys <<" ASIFT keypoints found in "<< image_path << endl; + + // return true; +} + +//Image : Gray scale image (image size = w*h) +bool ASIFT_matcher::addReference(const vector& image, unsigned int w, unsigned int h, unsigned int num_tilts) +{ + if(image.size()!=w*h) + { + cerr<<"Error : Input image size doesn't correspond with parameters"< ipixels1 = image; + + ///// Resize the images to area wS*hW in remaining the apsect-ratio ///// Resize if the resize flag is not set or if the flag is set unequal to 0 float wS = IM_X; float hS = IM_Y; @@ -132,15 +251,8 @@ bool ASIFT_matcher::addReference(const char* image_path, unsigned int num_tilts) zoom1 = 1; } - // image new_ref; - // new_ref.img = ipixels1_zoom; - // new_ref.width = wS1; - // new_ref.height = hS1; - - ///// Compute ASIFT keypoints asift_keypoints keys; - // vector< vector< keypointslist > >* keys = new vector< vector< keypointslist > >; int num_keys = 0; time_t tstart, tend; @@ -162,7 +274,7 @@ bool ASIFT_matcher::addReference(const char* image_path, unsigned int num_tilts) _nb_refs++; cout<<"Reference built in "<< difftime(tend, tstart) << " seconds." << endl; - cout<<" "<< num_keys <<" ASIFT keypoints found in "<< image_path << endl; + cout<<" "<< num_keys <<" ASIFT keypoints found."<< endl; return true; } @@ -215,7 +327,25 @@ unsigned int ASIFT_matcher::match(const char* image_path, unsigned int num_tilts size_t w1=gray.width(), h1=gray.height(); ipixels1.assign(gray.begin(), gray.end()); - ///// Resize the images to area wS*hW in remaining the apsect-ratio + std::cout<<"Matching from "<& image, unsigned int w, unsigned int h, unsigned int num_tilts) +{ + if(image.size()!=w*h) + { + cerr<<"Error : Input image size doesn't correspond with parameters"< ipixels1 = image; + + ///// Resize the images to area wS*hW in remaining the apsect-ratio ///// Resize if the resize flag is not set or if the flag is set unequal to 0 float wS = IM_X; float hS = IM_Y; @@ -295,61 +425,7 @@ unsigned int ASIFT_matcher::match(const char* image_path, unsigned int num_tilts tend = time(0); cout<< "Keypoints computation accomplished in " << difftime(tend, tstart) << " seconds." << endl; - cout<<" "<< num_keys <<" ASIFT keypoints found in "<< image_path << endl; - - //// Match ASIFT keypoints - _total_num_matchings=0; - - for(unsigned int i = 0; i<_nb_refs;i++) - { - int num_matchings = 0; - matchingslist matchings; - - cout << "Matching the keypoints..." << endl; - tstart = time(0); - try - { - num_matchings = compute_asift_matches(num_tilts, _num_tilts[i], wS1, hS1, _size_refs[i].first, _size_refs[i].second, _showDebug, keys, _keys[i], matchings, _siftParam); - } - catch(const bad_alloc& ba) - { - cerr<<"ERROR: ASIFT_matcher::match - "; - cerr << ba.what() << endl; - } - // cout<< _keys[i].size()<< " " << _keys[i][0].size() <<" "<< _keys[i][0][0].size()<& image, unsigned int w, unsigned int h, unsigned int num_tilts) -{ - if(image.size()!=w*h) - { - cerr<<"Error : Input image size doesn't correspond with parameters"<& image, unsigned int w, unsigned int h, unsigned int num_tilts =1); unsigned int match(const char* image_path, unsigned int num_tilts =1); - unsigned int match(vector& image, unsigned int w, unsigned int h, unsigned int num_tilts =1); + unsigned int match(const vector& image, unsigned int w, unsigned int h, unsigned int num_tilts =1); bool computeROI(int& x, int& y, unsigned int& h, unsigned int& w) const; //Compute the bounding rectangle of the keypoints bool computeCenter(int& cx, int& cy) const; bool distFilter(int threshold); //Filter keypoint which are far (Euclidian distance) from the center. diff --git a/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/ASIFT_matcher.cpp.o b/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/ASIFT_matcher.cpp.o index aa9d51e..ce4ec8c 100644 Binary files a/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/ASIFT_matcher.cpp.o and b/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/ASIFT_matcher.cpp.o differ diff --git a/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/test_ASIFT.cpp.o b/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/test_ASIFT.cpp.o index c780f6d..b681c8e 100644 Binary files a/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/test_ASIFT.cpp.o and b/ASIFT_tests/demo_ASIFT_src/CMakeFiles/test_ASIFT.dir/test_ASIFT.cpp.o differ diff --git a/ASIFT_tests/demo_ASIFT_src/results/matching.txt b/ASIFT_tests/demo_ASIFT_src/results/matching.txt index e7eb292..08cc601 100644 --- a/ASIFT_tests/demo_ASIFT_src/results/matching.txt +++ b/ASIFT_tests/demo_ASIFT_src/results/matching.txt @@ -1,34 +1,34 @@ 40 2 0 -291.509 169.803 321.857 265.435 322.192 279.122 521.25 53.2794 -361.771 216.725 -2.75171e-10 -5.88405e-11 -310.273 236.617 2.06711e-38 5.80946e-39 -377.929 162.983 0 0 -343.099 119.621 0 0 -329.485 112.667 4.12015e-36 1.10856e-35 +291.509 169.803 321.857 265.435 +361.771 216.725 6.50275e+18 1.3905e+18 +361.959 175.732 1.17666e-38 6.33158e-39 +261.936 171.287 0 0 322.959 119.184 0 0 -363.462 146.017 1.2775e-32 1.33655e-32 -230.152 191.051 0 0 -361.959 175.732 -1.98837e-10 -1.06993e-10 -223.012 231.746 2.45231e-38 1.21982e-38 -368.527 140.516 1.11629e-32 1.33926e-32 +374.229 132.773 4.44369e-36 6.60253e-36 +310.273 236.617 0 0 +230.152 191.051 2.42542e-35 1.79523e-35 +363.462 146.017 0 0 +377.929 162.983 1.17672e-34 7.60752e-35 367.28 179.248 0 0 -355.697 190.284 5.44443e-35 2.23759e-35 +354.104 176.741 1.47763e-35 8.19376e-36 +223.012 231.746 0 0 +317.773 232.706 2.49846e-34 7.0199e-35 +355.697 190.284 0 0 362.208 184.382 0 0 -300.647 157.174 0 0 324.178 230.519 0 0 -354.104 176.741 0 0 -335.039 109.815 2063.98 6047.64 -317.773 232.706 72922.9 20489.1 -371.585 152.449 0 0 -231.499 206.978 0 0 +368.527 140.516 0 0 +231.499 206.978 9506.8 5965.8 +371.585 152.449 31258.7 26473.7 +343.099 119.621 0 0 +300.647 157.174 0 0 315.991 235.875 0 0 221.354 204.377 0 0 -261.936 171.287 0 0 277.903 162.656 0 0 -374.229 132.773 2481.6 3687.22 -341.004 112.32 7112.49 20058.7 +341.004 112.32 0 0 +335.039 109.815 2063.98 6047.64 +294.302 268.305 37080.1 7738.15 307.57 255.971 1473.99 304.215 -322.959 119.184 0 0 +324.178 230.519 0 0 1 diff --git a/ASIFT_tests/demo_ASIFT_src/results/res.png b/ASIFT_tests/demo_ASIFT_src/results/res.png index 670f7a9..32498b4 100644 Binary files a/ASIFT_tests/demo_ASIFT_src/results/res.png and b/ASIFT_tests/demo_ASIFT_src/results/res.png differ diff --git a/ASIFT_tests/demo_ASIFT_src/test_ASIFT b/ASIFT_tests/demo_ASIFT_src/test_ASIFT index 6a527e4..f8e9bcf 100755 Binary files a/ASIFT_tests/demo_ASIFT_src/test_ASIFT and b/ASIFT_tests/demo_ASIFT_src/test_ASIFT differ