diff --git a/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp b/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp index f62c4c6..425a423 100644 --- a/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp +++ b/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp @@ -1,6 +1,6 @@ #include "ASIFT_matcher.hpp" -ASIFT_matcher::ASIFT_matcher(): _verb(0), _nb_refs(0), _resize_imgs(false) +ASIFT_matcher::ASIFT_matcher(): _showDebug(0), _nb_refs(0), _resize_imgs(false) { default_sift_parameters(_siftParam); } @@ -105,7 +105,7 @@ bool ASIFT_matcher::addReference(const char* image, unsigned int num_tilts) time_t tstart, tend; tstart = time(0); - num_keys = compute_asift_keypoints(ipixels1_zoom, wS1, hS1, num_tilts, _verb, keys, _siftParam); + num_keys = compute_asift_keypoints(ipixels1_zoom, wS1, hS1, num_tilts, _showDebug, keys, _siftParam); tend = time(0); @@ -219,7 +219,7 @@ bool ASIFT_matcher::match(const char* image, unsigned int num_tilts) time_t tstart, tend; tstart = time(0); - num_keys = compute_asift_keypoints(ipixels1_zoom, wS1, hS1, num_tilts, _verb, keys, _siftParam); + num_keys = compute_asift_keypoints(ipixels1_zoom, wS1, hS1, num_tilts, _showDebug, keys, _siftParam); tend = time(0); cout<< "Keypoints computation accomplished in " << difftime(tend, tstart) << " seconds." << endl; @@ -237,7 +237,7 @@ bool ASIFT_matcher::match(const char* image, unsigned int num_tilts) tstart = time(0); try { - num_matchings = compute_asift_matches(num_tilts, _num_tilts[i], wS1, hS1, _size_refs[i].first, _size_refs[i].second, _verb, keys, _keys[i], matchings, _siftParam); + 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) { @@ -271,7 +271,7 @@ bool ASIFT_matcher::match(vector& image, unsigned int w, unsigned int h, time_t tstart, tend; tstart = time(0); - num_keys = compute_asift_keypoints(image, w, h, num_tilts, _verb, keys, _siftParam); + num_keys = compute_asift_keypoints(image, w, h, num_tilts, _showDebug, keys, _siftParam); tend = time(0); cout<< "Keypoints computation accomplished in " << difftime(tend, tstart) << " seconds." << endl; @@ -289,7 +289,7 @@ bool ASIFT_matcher::match(vector& image, unsigned int w, unsigned int h, tstart = time(0); try { - num_matchings = compute_asift_matches(num_tilts, _num_tilts[i], w, h, _size_refs[i].first, _size_refs[i].second, _verb, keys, _keys[i], matchings, _siftParam); + num_matchings = compute_asift_matches(num_tilts, _num_tilts[i], w, h, _size_refs[i].first, _size_refs[i].second, _showDebug, keys, _keys[i], matchings, _siftParam); } catch(const bad_alloc& ba) { @@ -308,7 +308,7 @@ bool ASIFT_matcher::match(vector& image, unsigned int w, unsigned int h, return true; } -void ASIFT_matcher::computeROI(int& x, int& y, unsigned int& h, unsigned int& w, int zoom) const +void ASIFT_matcher::computeROI(int& x, int& y, unsigned int& h, unsigned int& w) const { if(getNbMatch()==0) { diff --git a/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.hpp b/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.hpp index 46375b7..85fa27c 100644 --- a/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.hpp +++ b/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.hpp @@ -40,17 +40,18 @@ public: bool match(const char* image, unsigned int num_tilts =1); bool match(vector& image, unsigned int w, unsigned int h, unsigned int num_tilts =1); void print() const; - void computeROI(int& x, int& y, unsigned int& h, unsigned int& w, int zoom =1) const; + void computeROI(int& x, int& y, unsigned int& h, unsigned int& w) const; void setResizeImg(bool resize_imgs){ _resize_imgs=resize_imgs;} + void showDebug(bool showDebug){ _showDebug=showDebug;} const vector < unsigned int >& getNbMatchs() const{ return _num_matchings;} unsigned int getNbMatch() const; const vector< matchingslist >& getMatch() const{ return _matchings;} + vector< matchingslist >& getMatch(){ return _matchings;} protected: - //QUESCEQUESAI - int _verb;// = 0; + int _showDebug;// = 0; //Reference Images // vector< image > _im_refs; 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 9fcdec3..b3112bd 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 eaa97f0..e6f1cb9 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/res.png b/ASIFT_tests/demo_ASIFT_src/results/res.png index db67b5c..cbcd724 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 ddc661c..ac2d3fe 100755 Binary files a/ASIFT_tests/demo_ASIFT_src/test_ASIFT and b/ASIFT_tests/demo_ASIFT_src/test_ASIFT differ diff --git a/ASIFT_tests/demo_ASIFT_src/test_ASIFT.cpp b/ASIFT_tests/demo_ASIFT_src/test_ASIFT.cpp index 7a34af4..3d1d76d 100644 --- a/ASIFT_tests/demo_ASIFT_src/test_ASIFT.cpp +++ b/ASIFT_tests/demo_ASIFT_src/test_ASIFT.cpp @@ -8,7 +8,7 @@ int main(int argc, char **argv) << " ******************************************************************************* " << std::endl << "Usage: " << argv[0] << " imgIn.png [Tilt number option] [Resize option: 0/1] " << std::endl << "- imgIn.png: input image (in PNG format). " << std::endl - << "- [Tilt number option: 1..n]. " << std::endl + << "- [Tilt number option: 1..(32+ ?)] : 8: Recommended / 1: no tilt. " << std::endl << "- [Resize option: 0/1]. 1: input images resize to 800x600 (default). 0: no resize. " << std::endl << " ******************************************************************************* " << std::endl << " ********************* Jean-Michel Morel, Guoshen Yu, 2010 ******************** " << std::endl @@ -107,8 +107,12 @@ int main(int argc, char **argv) ASIFT_matcher matcher; matcher.setResizeImg(flag_resize); - matcher.addReference(refData[0].c_str(), 7); - matcher.addReference(refData[1].c_str(), 7); + + time_t tstart, tend; + tstart = time(0); + + matcher.addReference(refData[0].c_str(), 8); + matcher.addReference(refData[1].c_str(), 8); // matcher.print(); // matcher.match(refData[3].c_str(), 4); if(argc>2) @@ -116,8 +120,11 @@ int main(int argc, char **argv) else matcher.match(ipixels1_zoom, wS1, hS1); + tend = time(0); + vector NbMatch = matcher.getNbMatchs(); - cout<<"Nb match : "< besoin du coef zoom + matcher.computeROI(x,y,h,w); float *opixelsASIFT = new float[w1*h1]; @@ -133,130 +140,22 @@ int main(int argc, char **argv) for(int j = 0; j < (int) h1; j++) for(int i = 0; i < (int) w1; i++) opixelsASIFT[j*w1+i] = ipixels1[j*w1+i]; //////////////////////////////////////////////////////////////////// Draw ROI - draw_square(opixelsASIFT, x, y, w, h, 255, w1, h1); + draw_square(opixelsASIFT, zoom1*x, zoom1*y, zoom1*w, zoom1*h, 255, w1, h1); + + //////////////////////////////////////////////////////////////////// Draw matches + int point_size = 2; + for(unsigned int j=0; jfirst.x), (int) (zoom1*ptrH->first.y), point_size, point_size, 255, w1, h1); + } + } ///////////////////////////////////////////////////////////////// Save imgOut write_png_f32("./results/res.png", opixelsASIFT, w1, h1, 1); delete[] opixelsASIFT; /*memcheck*/ - // /////////// Output image containing line matches (the two images are concatenated one aside the other) - // int woH = w1+w2+band_w; - // int hoH = MAX(h1,h2); - - // float *opixelsASIFT_H = new float[woH*hoH]; - - // for(int j = 0; j < (int) hoH; j++) - // for(int i = 0; i < (int) woH; i++) opixelsASIFT_H[j*woH+i] = 255; - - // /////////////////////////////////////////////////////////////////// Copy both images to output - // for(int j = 0; j < (int) h1; j++) - // for(int i = 0; i < (int) w1; i++) opixelsASIFT_H[j*woH+i] = ipixels1[j*w1+i]; - - // for(int j = 0; j < (int) h2; j++) - // for(int i = 0; i < (int) w2; i++) opixelsASIFT_H[j*woH + w1 + band_w + i] = ipixels2[j*w2 + i]; - - - // //////////////////////////////////////////////////////////////////// Draw matches - // matchingslist::iterator ptrH = matchings.begin(); - // for(int i=0; i < (int) matchings.size(); i++, ptrH++) - // { - // draw_line(opixelsASIFT_H, (int) (zoom1*ptrH->first.x), (int) (zoom1*ptrH->first.y), - // (int) (zoom2*ptrH->second.x) + w1 + band_w, (int) (zoom2*ptrH->second.y), 255.0f, woH, hoH); - // } - - // ///////////////////////////////////////////////////////////////// Save imgOut - // write_png_f32(argv[4], opixelsASIFT_H, woH, hoH, 1); - - // delete[] opixelsASIFT_H; /*memcheck*/ - - // ////// Write the coordinates of the matched points (row1, col1, row2, col2) to the file argv[5] - // std::ofstream file(argv[5]); - // if (file.is_open()) - // { - // // Write the number of matchings in the first line - // file << num_matchings << std::endl; - - // matchingslist::iterator ptr = matchings.begin(); - // for(int i=0; i < (int) matchings.size(); i++, ptr++) - // { - // file << zoom1*ptr->first.x << " " << zoom1*ptr->first.y << " " << zoom2*ptr->second.x << - // " " << zoom2*ptr->second.y << std::endl; - // } - // } - // else - // { - // std::cerr << "Unable to open the file matchings."; - // } - - // file.close(); - - - - // // Write all the keypoints (row, col, scale, orientation, desciptor (128 integers)) to - // // the file argv[6] (so that the users can match the keypoints with their own matching algorithm if they wish to) - // // keypoints in the 1st image - // std::ofstream file_key1(argv[6]); - // if (file_key1.is_open()) - // { - // // Follow the same convention of David Lowe: - // // the first line contains the number of keypoints and the length of the desciptors (128) - // file_key1 << num_keys1 << " " << VecLength << " " << std::endl; - // for (int tt = 0; tt < (int) keys1.size(); tt++) - // { - // for (int rr = 0; rr < (int) keys1[tt].size(); rr++) - // { - // keypointslist::iterator ptr = keys1[tt][rr].begin(); - // for(int i=0; i < (int) keys1[tt][rr].size(); i++, ptr++) - // { - // file_key1 << zoom1*ptr->x << " " << zoom1*ptr->y << " " << zoom1*ptr->scale << " " << ptr->angle; - - // for (int ii = 0; ii < (int) VecLength; ii++) - // { - // file_key1 << " " << ptr->vec[ii]; - // } - - // file_key1 << std::endl; - // } - // } - // } - // } - // else - // { - // std::cerr << "Unable to open the file keys1."; - // } - - // file_key1.close(); - - // ////// keypoints in the 2nd image - // std::ofstream file_key2(argv[7]); - // if (file_key2.is_open()) - // { - // // Follow the same convention of David Lowe: - // // the first line contains the number of keypoints and the length of the desciptors (128) - // file_key2 << num_keys2 << " " << VecLength << " " << std::endl; - // for (int tt = 0; tt < (int) keys2.size(); tt++) - // { - // for (int rr = 0; rr < (int) keys2[tt].size(); rr++) - // { - // keypointslist::iterator ptr = keys2[tt][rr].begin(); - // for(int i=0; i < (int) keys2[tt][rr].size(); i++, ptr++) - // { - // file_key2 << zoom2*ptr->x << " " << zoom2*ptr->y << " " << zoom2*ptr->scale << " " << ptr->angle; - - // for (int ii = 0; ii < (int) VecLength; ii++) - // { - // file_key2 << " " << ptr->vec[ii]; - // } - // file_key2 << std::endl; - // } - // } - // } - // } - // else - // { - // std::cerr << "Unable to open the file keys2."; - // } - // file_key2.close(); - return 0; }