2018-08-01 15:23:50 +02:00
|
|
|
#ifndef ASIFTMATCHER_HPP
|
|
|
|
#define ASIFTMATCHER_HPP
|
|
|
|
|
2018-07-23 17:30:57 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <vector>
|
2018-07-27 18:20:13 +02:00
|
|
|
#include <sstream>
|
2018-07-23 17:30:57 +02:00
|
|
|
|
|
|
|
#ifdef _OPENMP
|
|
|
|
#include <omp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "demo_lib_sift.h"
|
2018-07-27 18:20:13 +02:00
|
|
|
// #include "io_png/io_png.h"
|
2018-07-23 17:30:57 +02:00
|
|
|
|
|
|
|
#include "library.h"
|
|
|
|
#include "frot.h"
|
|
|
|
#include "fproj.h"
|
|
|
|
#include "compute_asift_keypoints.h"
|
|
|
|
#include "compute_asift_matches.h"
|
|
|
|
|
2018-07-27 18:20:13 +02:00
|
|
|
#include "CImg.h" //Need ImageMagick package
|
2018-07-26 16:57:58 +02:00
|
|
|
|
2018-07-23 17:30:57 +02:00
|
|
|
# define IM_X 800
|
|
|
|
# define IM_Y 600
|
|
|
|
|
2018-07-27 18:20:13 +02:00
|
|
|
using namespace std;
|
2018-07-23 17:30:57 +02:00
|
|
|
|
2018-07-24 14:45:28 +02:00
|
|
|
typedef vector< vector< keypointslist > > asift_keypoints;
|
|
|
|
|
2018-07-25 16:53:48 +02:00
|
|
|
//ASIFT wrapper
|
2018-07-23 17:30:57 +02:00
|
|
|
class ASIFT_matcher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ASIFT_matcher();
|
2018-07-30 17:52:44 +02:00
|
|
|
ASIFT_matcher(const char* ref_path);
|
|
|
|
ASIFT_matcher(const ASIFT_matcher& matcher) { *this = matcher;}
|
2018-07-24 14:45:28 +02:00
|
|
|
// virtual ~ASIFT_matcher();
|
2018-07-23 17:30:57 +02:00
|
|
|
|
2018-07-26 16:57:58 +02:00
|
|
|
bool addReference(const char* image_path, unsigned int num_tilts=1);
|
2018-07-31 10:52:28 +02:00
|
|
|
bool addReference(const vector<float>& image, unsigned int w, unsigned int h, unsigned int num_tilts =1);
|
2018-07-26 16:57:58 +02:00
|
|
|
unsigned int match(const char* image_path, unsigned int num_tilts =1);
|
2018-07-31 10:52:28 +02:00
|
|
|
unsigned int match(const vector<float>& image, unsigned int w, unsigned int h, unsigned int num_tilts =1);
|
2018-07-25 16:29:51 +02:00
|
|
|
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.
|
2018-07-24 17:42:26 +02:00
|
|
|
|
2018-07-26 16:57:58 +02:00
|
|
|
bool saveReferences(const char* ref_path) const;
|
|
|
|
bool loadReferences(const char* ref_path);
|
2018-07-25 16:53:48 +02:00
|
|
|
|
2018-07-30 17:52:44 +02:00
|
|
|
ASIFT_matcher& operator=(const ASIFT_matcher& m);
|
|
|
|
|
2018-07-25 16:53:48 +02:00
|
|
|
unsigned int getNbRef() const{ return _nb_refs;}
|
|
|
|
const vector< vector< float > >& getRefImgs() const{ return _im_refs;}
|
|
|
|
const vector< pair<int,int> >& getSizeRef() const{ return _size_refs;}
|
|
|
|
const vector<float>& getZoomRef() const{ return _zoom_refs;}
|
2018-07-30 17:52:44 +02:00
|
|
|
const std::vector<int>& getNumKeys() const{ return _num_keys;}
|
|
|
|
const std::vector<int>& getNumTilts() const{ return _num_tilts;}
|
|
|
|
const std::vector< asift_keypoints >& getKeys() const{ return _keys;}
|
2018-07-24 17:42:26 +02:00
|
|
|
const vector < unsigned int >& getNbMatchs() const{ return _num_matchings;}
|
2018-07-25 17:33:34 +02:00
|
|
|
unsigned int getNbMatch() const{ return _total_num_matchings;}
|
2018-07-24 17:42:26 +02:00
|
|
|
const vector< matchingslist >& getMatch() const{ return _matchings;}
|
2018-07-25 14:04:56 +02:00
|
|
|
vector< matchingslist >& getMatch(){ return _matchings;}
|
2018-07-30 17:52:44 +02:00
|
|
|
const siftPar& getSiftPar() const{ return _siftParam;}
|
2018-07-25 16:53:48 +02:00
|
|
|
void setSiftPar(const siftPar &newSiftPar){ _siftParam = newSiftPar;}
|
2018-07-30 17:52:44 +02:00
|
|
|
bool isResizingImg() const{ return _resize_imgs;}
|
2018-08-08 15:45:19 +02:00
|
|
|
void resizeImg(bool resize_imgs){ _resize_imgs=resize_imgs;}
|
2018-07-30 17:52:44 +02:00
|
|
|
bool isShowingDebug() const{ return _showDebug;}
|
2018-07-25 16:53:48 +02:00
|
|
|
void showDebug(bool showDebug){ _showDebug=showDebug;}
|
2018-08-08 15:45:19 +02:00
|
|
|
bool isShowingInfo() const{ return _showInfo;}
|
|
|
|
void showInfo(bool showInfo){ _showInfo=showInfo;}
|
2018-07-24 14:45:28 +02:00
|
|
|
|
2018-07-30 17:52:44 +02:00
|
|
|
void print() const; //Debugging function
|
|
|
|
|
2018-07-23 17:30:57 +02:00
|
|
|
protected:
|
|
|
|
|
|
|
|
//Reference Images
|
2018-07-25 16:53:48 +02:00
|
|
|
unsigned int _nb_refs;// = 0; //Number of reference images
|
|
|
|
vector< vector< float > > _im_refs; //Reference images used for matching
|
2018-07-23 17:30:57 +02:00
|
|
|
vector< pair<int,int> > _size_refs; //Width/Height
|
2018-07-25 16:53:48 +02:00
|
|
|
vector<float> _zoom_refs; //Zoom coeffs
|
2018-07-23 17:30:57 +02:00
|
|
|
|
|
|
|
//ASIFT Keypoints
|
2018-07-25 16:53:48 +02:00
|
|
|
vector< int > _num_keys; //Number of keypoint/reference
|
|
|
|
vector< int > _num_tilts; //Number of tilts/reference (Speed VS Precision)
|
|
|
|
vector< asift_keypoints > _keys; //Keypoints
|
2018-07-23 17:30:57 +02:00
|
|
|
|
|
|
|
//Matchs
|
2018-07-25 17:33:34 +02:00
|
|
|
unsigned int _total_num_matchings;
|
2018-07-25 16:53:48 +02:00
|
|
|
vector < unsigned int > _num_matchings; //Number of match/reference
|
|
|
|
vector< matchingslist > _matchings; //Matchs
|
2018-07-23 17:30:57 +02:00
|
|
|
|
2018-07-25 16:53:48 +02:00
|
|
|
siftPar _siftParam; //SIFT parameters
|
2018-07-23 17:30:57 +02:00
|
|
|
|
|
|
|
//Flags
|
2018-07-25 16:53:48 +02:00
|
|
|
bool _resize_imgs;// = false; //Resize images to IM_X/IM_Y ?
|
|
|
|
bool _showDebug;// = 0; //Show debugging messages ?
|
2018-08-08 15:45:19 +02:00
|
|
|
bool _showInfo; //Show info messages
|
2018-07-27 18:20:13 +02:00
|
|
|
};
|
2018-08-01 15:23:50 +02:00
|
|
|
|
|
|
|
#endif
|