Remove all using directives for STL namespace and members
Made all STL usages explicit to be able automatically find all usages of particular class or function.
This commit is contained in:
parent
f783f34e0b
commit
2a6fb2867e
@ -4,6 +4,7 @@
|
|||||||
#include "HOGfeatures.h"
|
#include "HOGfeatures.h"
|
||||||
#include "cascadeclassifier.h"
|
#include "cascadeclassifier.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
CvHOGFeatureParams::CvHOGFeatureParams()
|
CvHOGFeatureParams::CvHOGFeatureParams()
|
||||||
{
|
{
|
||||||
|
@ -26,13 +26,13 @@ public:
|
|||||||
virtual void writeFeatures( FileStorage &fs, const Mat& featureMap ) const;
|
virtual void writeFeatures( FileStorage &fs, const Mat& featureMap ) const;
|
||||||
protected:
|
protected:
|
||||||
virtual void generateFeatures();
|
virtual void generateFeatures();
|
||||||
virtual void integralHistogram(const Mat &img, vector<Mat> &histogram, Mat &norm, int nbins) const;
|
virtual void integralHistogram(const Mat &img, std::vector<Mat> &histogram, Mat &norm, int nbins) const;
|
||||||
class Feature
|
class Feature
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Feature();
|
Feature();
|
||||||
Feature( int offset, int x, int y, int cellW, int cellH );
|
Feature( int offset, int x, int y, int cellW, int cellH );
|
||||||
float calc( const vector<Mat> &_hists, const Mat &_normSum, size_t y, int featComponent ) const;
|
float calc( const std::vector<Mat> &_hists, const Mat &_normSum, size_t y, int featComponent ) const;
|
||||||
void write( FileStorage &fs ) const;
|
void write( FileStorage &fs ) const;
|
||||||
void write( FileStorage &fs, int varIdx ) const;
|
void write( FileStorage &fs, int varIdx ) const;
|
||||||
|
|
||||||
@ -43,10 +43,10 @@ protected:
|
|||||||
int p0, p1, p2, p3;
|
int p0, p1, p2, p3;
|
||||||
} fastRect[N_CELLS];
|
} fastRect[N_CELLS];
|
||||||
};
|
};
|
||||||
vector<Feature> features;
|
std::vector<Feature> features;
|
||||||
|
|
||||||
Mat normSum; //for nomalization calculation (L1 or L2)
|
Mat normSum; //for nomalization calculation (L1 or L2)
|
||||||
vector<Mat> hist;
|
std::vector<Mat> hist;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const
|
inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const
|
||||||
@ -57,7 +57,7 @@ inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const
|
|||||||
return features[featureIdx].calc( hist, normSum, sampleIdx, componentIdx);
|
return features[featureIdx].calc( hist, normSum, sampleIdx, componentIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float CvHOGEvaluator::Feature::calc( const vector<Mat>& _hists, const Mat& _normSum, size_t y, int featComponent ) const
|
inline float CvHOGEvaluator::Feature::calc( const std::vector<Mat>& _hists, const Mat& _normSum, size_t y, int featComponent ) const
|
||||||
{
|
{
|
||||||
float normFactor;
|
float normFactor;
|
||||||
float res;
|
float res;
|
||||||
|
@ -160,10 +160,10 @@ CvCascadeBoostParams::CvCascadeBoostParams( int _boostType,
|
|||||||
|
|
||||||
void CvCascadeBoostParams::write( FileStorage &fs ) const
|
void CvCascadeBoostParams::write( FileStorage &fs ) const
|
||||||
{
|
{
|
||||||
String boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
|
string boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
|
||||||
boost_type == CvBoost::REAL ? CC_REAL_BOOST :
|
boost_type == CvBoost::REAL ? CC_REAL_BOOST :
|
||||||
boost_type == CvBoost::LOGIT ? CC_LOGIT_BOOST :
|
boost_type == CvBoost::LOGIT ? CC_LOGIT_BOOST :
|
||||||
boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : String();
|
boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : string();
|
||||||
CV_Assert( !boostTypeStr.empty() );
|
CV_Assert( !boostTypeStr.empty() );
|
||||||
fs << CC_BOOST_TYPE << boostTypeStr;
|
fs << CC_BOOST_TYPE << boostTypeStr;
|
||||||
fs << CC_MINHITRATE << minHitRate;
|
fs << CC_MINHITRATE << minHitRate;
|
||||||
@ -175,7 +175,7 @@ void CvCascadeBoostParams::write( FileStorage &fs ) const
|
|||||||
|
|
||||||
bool CvCascadeBoostParams::read( const FileNode &node )
|
bool CvCascadeBoostParams::read( const FileNode &node )
|
||||||
{
|
{
|
||||||
String boostTypeStr;
|
string boostTypeStr;
|
||||||
FileNode rnode = node[CC_BOOST_TYPE];
|
FileNode rnode = node[CC_BOOST_TYPE];
|
||||||
rnode >> boostTypeStr;
|
rnode >> boostTypeStr;
|
||||||
boost_type = !boostTypeStr.compare( CC_DISCRETE_BOOST ) ? CvBoost::DISCRETE :
|
boost_type = !boostTypeStr.compare( CC_DISCRETE_BOOST ) ? CvBoost::DISCRETE :
|
||||||
@ -213,10 +213,10 @@ void CvCascadeBoostParams::printDefaults() const
|
|||||||
|
|
||||||
void CvCascadeBoostParams::printAttrs() const
|
void CvCascadeBoostParams::printAttrs() const
|
||||||
{
|
{
|
||||||
String boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
|
string boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST :
|
||||||
boost_type == CvBoost::REAL ? CC_REAL_BOOST :
|
boost_type == CvBoost::REAL ? CC_REAL_BOOST :
|
||||||
boost_type == CvBoost::LOGIT ? CC_LOGIT_BOOST :
|
boost_type == CvBoost::LOGIT ? CC_LOGIT_BOOST :
|
||||||
boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : String();
|
boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : string();
|
||||||
CV_Assert( !boostTypeStr.empty() );
|
CV_Assert( !boostTypeStr.empty() );
|
||||||
cout << "boostType: " << boostTypeStr << endl;
|
cout << "boostType: " << boostTypeStr << endl;
|
||||||
cout << "minHitRate: " << minHitRate << endl;
|
cout << "minHitRate: " << minHitRate << endl;
|
||||||
@ -226,7 +226,7 @@ void CvCascadeBoostParams::printAttrs() const
|
|||||||
cout << "maxWeakCount: " << weak_count << endl;
|
cout << "maxWeakCount: " << weak_count << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvCascadeBoostParams::scanAttr( const String prmName, const String val)
|
bool CvCascadeBoostParams::scanAttr( const string prmName, const string val)
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ struct CvCascadeBoostParams : CvBoostParams
|
|||||||
bool read( const FileNode &node );
|
bool read( const FileNode &node );
|
||||||
virtual void printDefaults() const;
|
virtual void printDefaults() const;
|
||||||
virtual void printAttrs() const;
|
virtual void printAttrs() const;
|
||||||
virtual bool scanAttr( const String prmName, const String val);
|
virtual bool scanAttr( const std::string prmName, const std::string val);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CvCascadeBoostTrainData : CvDTreeTrainData
|
struct CvCascadeBoostTrainData : CvDTreeTrainData
|
||||||
|
@ -24,10 +24,10 @@ CvCascadeParams::CvCascadeParams( int _stageType, int _featureType ) : stageType
|
|||||||
|
|
||||||
void CvCascadeParams::write( FileStorage &fs ) const
|
void CvCascadeParams::write( FileStorage &fs ) const
|
||||||
{
|
{
|
||||||
String stageTypeStr = stageType == BOOST ? CC_BOOST : String();
|
string stageTypeStr = stageType == BOOST ? CC_BOOST : string();
|
||||||
CV_Assert( !stageTypeStr.empty() );
|
CV_Assert( !stageTypeStr.empty() );
|
||||||
fs << CC_STAGE_TYPE << stageTypeStr;
|
fs << CC_STAGE_TYPE << stageTypeStr;
|
||||||
String featureTypeStr = featureType == CvFeatureParams::HAAR ? CC_HAAR :
|
string featureTypeStr = featureType == CvFeatureParams::HAAR ? CC_HAAR :
|
||||||
featureType == CvFeatureParams::LBP ? CC_LBP :
|
featureType == CvFeatureParams::LBP ? CC_LBP :
|
||||||
featureType == CvFeatureParams::HOG ? CC_HOG :
|
featureType == CvFeatureParams::HOG ? CC_HOG :
|
||||||
0;
|
0;
|
||||||
@ -41,7 +41,7 @@ bool CvCascadeParams::read( const FileNode &node )
|
|||||||
{
|
{
|
||||||
if ( node.empty() )
|
if ( node.empty() )
|
||||||
return false;
|
return false;
|
||||||
String stageTypeStr, featureTypeStr;
|
string stageTypeStr, featureTypeStr;
|
||||||
FileNode rnode = node[CC_STAGE_TYPE];
|
FileNode rnode = node[CC_STAGE_TYPE];
|
||||||
if ( !rnode.isString() )
|
if ( !rnode.isString() )
|
||||||
return false;
|
return false;
|
||||||
@ -96,7 +96,7 @@ void CvCascadeParams::printAttrs() const
|
|||||||
cout << "sampleHeight: " << winSize.height << endl;
|
cout << "sampleHeight: " << winSize.height << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvCascadeParams::scanAttr( const String prmName, const String val )
|
bool CvCascadeParams::scanAttr( const string prmName, const string val )
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if( !prmName.compare( "-stageType" ) )
|
if( !prmName.compare( "-stageType" ) )
|
||||||
@ -126,9 +126,9 @@ bool CvCascadeParams::scanAttr( const String prmName, const String val )
|
|||||||
|
|
||||||
//---------------------------- CascadeClassifier --------------------------------------
|
//---------------------------- CascadeClassifier --------------------------------------
|
||||||
|
|
||||||
bool CvCascadeClassifier::train( const String _cascadeDirName,
|
bool CvCascadeClassifier::train( const string _cascadeDirName,
|
||||||
const String _posFilename,
|
const string _posFilename,
|
||||||
const String _negFilename,
|
const string _negFilename,
|
||||||
int _numPos, int _numNeg,
|
int _numPos, int _numNeg,
|
||||||
int _precalcValBufSize, int _precalcIdxBufSize,
|
int _precalcValBufSize, int _precalcIdxBufSize,
|
||||||
int _numStages,
|
int _numStages,
|
||||||
@ -399,7 +399,7 @@ bool CvCascadeClassifier::readStages( const FileNode &node)
|
|||||||
#define ICV_HAAR_PARENT_NAME "parent"
|
#define ICV_HAAR_PARENT_NAME "parent"
|
||||||
#define ICV_HAAR_NEXT_NAME "next"
|
#define ICV_HAAR_NEXT_NAME "next"
|
||||||
|
|
||||||
void CvCascadeClassifier::save( const String filename, bool baseFormat )
|
void CvCascadeClassifier::save( const string filename, bool baseFormat )
|
||||||
{
|
{
|
||||||
FileStorage fs( filename, FileStorage::WRITE );
|
FileStorage fs( filename, FileStorage::WRITE );
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ void CvCascadeClassifier::save( const String filename, bool baseFormat )
|
|||||||
fs << "}";
|
fs << "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvCascadeClassifier::load( const String cascadeDirName )
|
bool CvCascadeClassifier::load( const string cascadeDirName )
|
||||||
{
|
{
|
||||||
FileStorage fs( cascadeDirName + CC_PARAMS_FILENAME, FileStorage::READ );
|
FileStorage fs( cascadeDirName + CC_PARAMS_FILENAME, FileStorage::READ );
|
||||||
if ( !fs.isOpened() )
|
if ( !fs.isOpened() )
|
||||||
|
@ -77,7 +77,7 @@ public:
|
|||||||
|
|
||||||
void printDefaults() const;
|
void printDefaults() const;
|
||||||
void printAttrs() const;
|
void printAttrs() const;
|
||||||
bool scanAttr( const String prmName, const String val );
|
bool scanAttr( const std::string prmName, const std::string val );
|
||||||
|
|
||||||
int stageType;
|
int stageType;
|
||||||
int featureType;
|
int featureType;
|
||||||
@ -87,9 +87,9 @@ public:
|
|||||||
class CvCascadeClassifier
|
class CvCascadeClassifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool train( const String _cascadeDirName,
|
bool train( const std::string _cascadeDirName,
|
||||||
const String _posFilename,
|
const std::string _posFilename,
|
||||||
const String _negFilename,
|
const std::string _negFilename,
|
||||||
int _numPos, int _numNeg,
|
int _numPos, int _numNeg,
|
||||||
int _precalcValBufSize, int _precalcIdxBufSize,
|
int _precalcValBufSize, int _precalcIdxBufSize,
|
||||||
int _numStages,
|
int _numStages,
|
||||||
@ -99,8 +99,8 @@ public:
|
|||||||
bool baseFormatSave = false );
|
bool baseFormatSave = false );
|
||||||
private:
|
private:
|
||||||
int predict( int sampleIdx );
|
int predict( int sampleIdx );
|
||||||
void save( const String cascadeDirName, bool baseFormat = false );
|
void save( const std::string cascadeDirName, bool baseFormat = false );
|
||||||
bool load( const String cascadeDirName );
|
bool load( const std::string cascadeDirName );
|
||||||
bool updateTrainingSet( double& acceptanceRatio );
|
bool updateTrainingSet( double& acceptanceRatio );
|
||||||
int fillPassedSamples( int first, int count, bool isPositive, int64& consumed );
|
int fillPassedSamples( int first, int count, bool isPositive, int64& consumed );
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ private:
|
|||||||
Ptr<CvCascadeBoostParams> stageParams;
|
Ptr<CvCascadeBoostParams> stageParams;
|
||||||
|
|
||||||
Ptr<CvFeatureEvaluator> featureEvaluator;
|
Ptr<CvFeatureEvaluator> featureEvaluator;
|
||||||
vector< Ptr<CvCascadeBoost> > stageClassifiers;
|
std::vector< Ptr<CvCascadeBoost> > stageClassifiers;
|
||||||
CvCascadeImageReader imgReader;
|
CvCascadeImageReader imgReader;
|
||||||
int numStages, curNumSamples;
|
int numStages, curNumSamples;
|
||||||
int numPos, numNeg;
|
int numPos, numNeg;
|
||||||
|
@ -24,7 +24,7 @@ CvParams::CvParams() : name( "params" ) {}
|
|||||||
void CvParams::printDefaults() const
|
void CvParams::printDefaults() const
|
||||||
{ cout << "--" << name << "--" << endl; }
|
{ cout << "--" << name << "--" << endl; }
|
||||||
void CvParams::printAttrs() const {}
|
void CvParams::printAttrs() const {}
|
||||||
bool CvParams::scanAttr( const String, const String ) { return false; }
|
bool CvParams::scanAttr( const string, const string ) { return false; }
|
||||||
|
|
||||||
|
|
||||||
//---------------------------- FeatureParams --------------------------------------
|
//---------------------------- FeatureParams --------------------------------------
|
||||||
|
@ -25,9 +25,9 @@ void CvHaarFeatureParams::init( const CvFeatureParams& fp )
|
|||||||
void CvHaarFeatureParams::write( FileStorage &fs ) const
|
void CvHaarFeatureParams::write( FileStorage &fs ) const
|
||||||
{
|
{
|
||||||
CvFeatureParams::write( fs );
|
CvFeatureParams::write( fs );
|
||||||
String modeStr = mode == BASIC ? CC_MODE_BASIC :
|
string modeStr = mode == BASIC ? CC_MODE_BASIC :
|
||||||
mode == CORE ? CC_MODE_CORE :
|
mode == CORE ? CC_MODE_CORE :
|
||||||
mode == ALL ? CC_MODE_ALL : String();
|
mode == ALL ? CC_MODE_ALL : string();
|
||||||
CV_Assert( !modeStr.empty() );
|
CV_Assert( !modeStr.empty() );
|
||||||
fs << CC_MODE << modeStr;
|
fs << CC_MODE << modeStr;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ bool CvHaarFeatureParams::read( const FileNode &node )
|
|||||||
FileNode rnode = node[CC_MODE];
|
FileNode rnode = node[CC_MODE];
|
||||||
if( !rnode.isString() )
|
if( !rnode.isString() )
|
||||||
return false;
|
return false;
|
||||||
String modeStr;
|
string modeStr;
|
||||||
rnode >> modeStr;
|
rnode >> modeStr;
|
||||||
mode = !modeStr.compare( CC_MODE_BASIC ) ? BASIC :
|
mode = !modeStr.compare( CC_MODE_BASIC ) ? BASIC :
|
||||||
!modeStr.compare( CC_MODE_CORE ) ? CORE :
|
!modeStr.compare( CC_MODE_CORE ) ? CORE :
|
||||||
@ -58,13 +58,13 @@ void CvHaarFeatureParams::printDefaults() const
|
|||||||
void CvHaarFeatureParams::printAttrs() const
|
void CvHaarFeatureParams::printAttrs() const
|
||||||
{
|
{
|
||||||
CvFeatureParams::printAttrs();
|
CvFeatureParams::printAttrs();
|
||||||
String mode_str = mode == BASIC ? CC_MODE_BASIC :
|
string mode_str = mode == BASIC ? CC_MODE_BASIC :
|
||||||
mode == CORE ? CC_MODE_CORE :
|
mode == CORE ? CC_MODE_CORE :
|
||||||
mode == ALL ? CC_MODE_ALL : 0;
|
mode == ALL ? CC_MODE_ALL : 0;
|
||||||
cout << "mode: " << mode_str << endl;
|
cout << "mode: " << mode_str << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvHaarFeatureParams::scanAttr( const String prmName, const String val)
|
bool CvHaarFeatureParams::scanAttr( const string prmName, const string val)
|
||||||
{
|
{
|
||||||
if ( !CvFeatureParams::scanAttr( prmName, val ) )
|
if ( !CvFeatureParams::scanAttr( prmName, val ) )
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
|
|
||||||
virtual void printDefaults() const;
|
virtual void printDefaults() const;
|
||||||
virtual void printAttrs() const;
|
virtual void printAttrs() const;
|
||||||
virtual bool scanAttr( const String prm, const String val);
|
virtual bool scanAttr( const std::string prm, const std::string val);
|
||||||
|
|
||||||
int mode;
|
int mode;
|
||||||
};
|
};
|
||||||
@ -64,7 +64,7 @@ protected:
|
|||||||
} fastRect[CV_HAAR_FEATURE_MAX];
|
} fastRect[CV_HAAR_FEATURE_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<Feature> features;
|
std::vector<Feature> features;
|
||||||
Mat sum; /* sum images (each row represents image) */
|
Mat sum; /* sum images (each row represents image) */
|
||||||
Mat tilted; /* tilted sum images (each row represents image) */
|
Mat tilted; /* tilted sum images (each row represents image) */
|
||||||
Mat normfactor; /* normalization factor */
|
Mat normfactor; /* normalization factor */
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
bool CvCascadeImageReader::create( const String _posFilename, const String _negFilename, Size _winSize )
|
using namespace std;
|
||||||
|
|
||||||
|
bool CvCascadeImageReader::create( const string _posFilename, const string _negFilename, Size _winSize )
|
||||||
{
|
{
|
||||||
return posReader.create(_posFilename) && negReader.create(_negFilename, _winSize);
|
return posReader.create(_posFilename) && negReader.create(_negFilename, _winSize);
|
||||||
}
|
}
|
||||||
@ -22,21 +24,21 @@ CvCascadeImageReader::NegReader::NegReader()
|
|||||||
stepFactor = 0.5F;
|
stepFactor = 0.5F;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvCascadeImageReader::NegReader::create( const String _filename, Size _winSize )
|
bool CvCascadeImageReader::NegReader::create( const string _filename, Size _winSize )
|
||||||
{
|
{
|
||||||
String dirname, str;
|
string dirname, str;
|
||||||
std::ifstream file(_filename.c_str());
|
std::ifstream file(_filename.c_str());
|
||||||
if ( !file.is_open() )
|
if ( !file.is_open() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_t pos = _filename.rfind('\\');
|
size_t pos = _filename.rfind('\\');
|
||||||
char dlmrt = '\\';
|
char dlmrt = '\\';
|
||||||
if (pos == String::npos)
|
if (pos == string::npos)
|
||||||
{
|
{
|
||||||
pos = _filename.rfind('/');
|
pos = _filename.rfind('/');
|
||||||
dlmrt = '/';
|
dlmrt = '/';
|
||||||
}
|
}
|
||||||
dirname = pos == String::npos ? "" : _filename.substr(0, pos) + dlmrt;
|
dirname = pos == string::npos ? "" : _filename.substr(0, pos) + dlmrt;
|
||||||
while( !file.eof() )
|
while( !file.eof() )
|
||||||
{
|
{
|
||||||
std::getline(file, str);
|
std::getline(file, str);
|
||||||
@ -64,8 +66,8 @@ bool CvCascadeImageReader::NegReader::nextImg()
|
|||||||
round = round % (winSize.width * winSize.height);
|
round = round % (winSize.width * winSize.height);
|
||||||
last %= count;
|
last %= count;
|
||||||
|
|
||||||
_offset.x = min( (int)round % winSize.width, src.cols - winSize.width );
|
_offset.x = std::min( (int)round % winSize.width, src.cols - winSize.width );
|
||||||
_offset.y = min( (int)round / winSize.width, src.rows - winSize.height );
|
_offset.y = std::min( (int)round / winSize.width, src.rows - winSize.height );
|
||||||
if( !src.empty() && src.type() == CV_8UC1
|
if( !src.empty() && src.type() == CV_8UC1
|
||||||
&& offset.x >= 0 && offset.y >= 0 )
|
&& offset.x >= 0 && offset.y >= 0 )
|
||||||
break;
|
break;
|
||||||
@ -126,7 +128,7 @@ CvCascadeImageReader::PosReader::PosReader()
|
|||||||
vec = 0;
|
vec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvCascadeImageReader::PosReader::create( const String _filename )
|
bool CvCascadeImageReader::PosReader::create( const string _filename )
|
||||||
{
|
{
|
||||||
if ( file )
|
if ( file )
|
||||||
fclose( file );
|
fclose( file );
|
||||||
|
@ -8,7 +8,7 @@ using namespace cv;
|
|||||||
class CvCascadeImageReader
|
class CvCascadeImageReader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool create( const String _posFilename, const String _negFilename, Size _winSize );
|
bool create( const std::string _posFilename, const std::string _negFilename, Size _winSize );
|
||||||
void restart() { posReader.restart(); }
|
void restart() { posReader.restart(); }
|
||||||
bool getNeg(Mat &_img) { return negReader.get( _img ); }
|
bool getNeg(Mat &_img) { return negReader.get( _img ); }
|
||||||
bool getPos(Mat &_img) { return posReader.get( _img ); }
|
bool getPos(Mat &_img) { return posReader.get( _img ); }
|
||||||
@ -19,7 +19,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
PosReader();
|
PosReader();
|
||||||
virtual ~PosReader();
|
virtual ~PosReader();
|
||||||
bool create( const String _filename );
|
bool create( const std::string _filename );
|
||||||
bool get( Mat &_img );
|
bool get( Mat &_img );
|
||||||
void restart();
|
void restart();
|
||||||
|
|
||||||
@ -35,12 +35,12 @@ private:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NegReader();
|
NegReader();
|
||||||
bool create( const String _filename, Size _winSize );
|
bool create( const std::string _filename, Size _winSize );
|
||||||
bool get( Mat& _img );
|
bool get( Mat& _img );
|
||||||
bool nextImg();
|
bool nextImg();
|
||||||
|
|
||||||
Mat src, img;
|
Mat src, img;
|
||||||
vector<String> imgFilenames;
|
std::vector<std::string> imgFilenames;
|
||||||
Point offset, point;
|
Point offset, point;
|
||||||
float scale;
|
float scale;
|
||||||
float scaleFactor;
|
float scaleFactor;
|
||||||
|
@ -34,7 +34,7 @@ protected:
|
|||||||
Rect rect;
|
Rect rect;
|
||||||
int p[16];
|
int p[16];
|
||||||
};
|
};
|
||||||
vector<Feature> features;
|
std::vector<Feature> features;
|
||||||
|
|
||||||
Mat sum;
|
Mat sum;
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@ using namespace std;
|
|||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
CvCascadeClassifier classifier;
|
CvCascadeClassifier classifier;
|
||||||
String cascadeDirName, vecName, bgName;
|
string cascadeDirName, vecName, bgName;
|
||||||
int numPos = 2000;
|
int numPos = 2000;
|
||||||
int numNeg = 1000;
|
int numNeg = 1000;
|
||||||
int numStages = 20;
|
int numStages = 20;
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
float calcNormFactor( const Mat& sum, const Mat& sqSum );
|
float calcNormFactor( const Mat& sum, const Mat& sqSum );
|
||||||
|
|
||||||
template<class Feature>
|
template<class Feature>
|
||||||
void _writeFeatures( const vector<Feature> features, FileStorage &fs, const Mat& featureMap )
|
void _writeFeatures( const std::vector<Feature> features, FileStorage &fs, const Mat& featureMap )
|
||||||
{
|
{
|
||||||
fs << FEATURES << "[";
|
fs << FEATURES << "[";
|
||||||
const Mat_<int>& featureMap_ = (const Mat_<int>&)featureMap;
|
const Mat_<int>& featureMap_ = (const Mat_<int>&)featureMap;
|
||||||
@ -58,8 +58,8 @@ public:
|
|||||||
// from|to screen
|
// from|to screen
|
||||||
virtual void printDefaults() const;
|
virtual void printDefaults() const;
|
||||||
virtual void printAttrs() const;
|
virtual void printAttrs() const;
|
||||||
virtual bool scanAttr( const String prmName, const String val );
|
virtual bool scanAttr( const std::string prmName, const std::string val );
|
||||||
String name;
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CvFeatureParams : public CvParams
|
class CvFeatureParams : public CvParams
|
||||||
|
@ -28,9 +28,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class CameraWrapperConnector
|
class CameraWrapperConnector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -50,7 +47,7 @@ private:
|
|||||||
static std::string getDefaultPathLibFolder();
|
static std::string getDefaultPathLibFolder();
|
||||||
static CameraActivity::ErrorCode connectToLib();
|
static CameraActivity::ErrorCode connectToLib();
|
||||||
static CameraActivity::ErrorCode getSymbolFromLib(void * libHandle, const char* symbolName, void** ppSymbol);
|
static CameraActivity::ErrorCode getSymbolFromLib(void * libHandle, const char* symbolName, void** ppSymbol);
|
||||||
static void fillListWrapperLibs(const string& folderPath, vector<string>& listLibs);
|
static void fillListWrapperLibs(const std::string& folderPath, std::vector<std::string>& listLibs);
|
||||||
|
|
||||||
static InitCameraConnectC pInitCameraC;
|
static InitCameraConnectC pInitCameraC;
|
||||||
static CloseCameraConnectC pCloseCameraC;
|
static CloseCameraConnectC pCloseCameraC;
|
||||||
@ -168,7 +165,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib()
|
|||||||
}
|
}
|
||||||
|
|
||||||
dlerror();
|
dlerror();
|
||||||
string folderPath = getPathLibFolder();
|
std::string folderPath = getPathLibFolder();
|
||||||
if (folderPath.empty())
|
if (folderPath.empty())
|
||||||
{
|
{
|
||||||
LOGD("Trying to find native camera in default OpenCV packages");
|
LOGD("Trying to find native camera in default OpenCV packages");
|
||||||
@ -177,12 +174,12 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib()
|
|||||||
|
|
||||||
LOGD("CameraWrapperConnector::connectToLib: folderPath=%s", folderPath.c_str());
|
LOGD("CameraWrapperConnector::connectToLib: folderPath=%s", folderPath.c_str());
|
||||||
|
|
||||||
vector<string> listLibs;
|
std::vector<std::string> listLibs;
|
||||||
fillListWrapperLibs(folderPath, listLibs);
|
fillListWrapperLibs(folderPath, listLibs);
|
||||||
std::sort(listLibs.begin(), listLibs.end(), std::greater<string>());
|
std::sort(listLibs.begin(), listLibs.end(), std::greater<std::string>());
|
||||||
|
|
||||||
void * libHandle=0;
|
void * libHandle=0;
|
||||||
string cur_path;
|
std::string cur_path;
|
||||||
for(size_t i = 0; i < listLibs.size(); i++) {
|
for(size_t i = 0; i < listLibs.size(); i++) {
|
||||||
cur_path=folderPath + listLibs[i];
|
cur_path=folderPath + listLibs[i];
|
||||||
LOGD("try to load library '%s'", listLibs[i].c_str());
|
LOGD("try to load library '%s'", listLibs[i].c_str());
|
||||||
@ -248,7 +245,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::getSymbolFromLib(void* libHand
|
|||||||
return CameraActivity::NO_ERROR;
|
return CameraActivity::NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraWrapperConnector::fillListWrapperLibs(const string& folderPath, vector<string>& listLibs)
|
void CameraWrapperConnector::fillListWrapperLibs(const std::string& folderPath, std::vector<std::string>& listLibs)
|
||||||
{
|
{
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *ep;
|
struct dirent *ep;
|
||||||
@ -290,7 +287,7 @@ std::string CameraWrapperConnector::getDefaultPathLibFolder()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CameraWrapperConnector::getPathLibFolder()
|
std::string CameraWrapperConnector::getPathLibFolder()
|
||||||
@ -361,10 +358,10 @@ std::string CameraWrapperConnector::getPathLibFolder()
|
|||||||
LOGE("Could not get library name and base address");
|
LOGE("Could not get library name and base address");
|
||||||
}
|
}
|
||||||
|
|
||||||
return string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraWrapperConnector::setPathLibFolder(const string& path)
|
void CameraWrapperConnector::setPathLibFolder(const std::string& path)
|
||||||
{
|
{
|
||||||
pathLibFolder=path;
|
pathLibFolder=path;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ PERF_TEST_P(String_Size, asymm_circles_grid, testing::Values(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
String filename = getDataPath(get<0>(GetParam()));
|
string filename = getDataPath(get<0>(GetParam()));
|
||||||
Size gridSize = get<1>(GetParam());
|
Size gridSize = get<1>(GetParam());
|
||||||
|
|
||||||
Mat frame = imread(filename);
|
Mat frame = imread(filename);
|
||||||
|
@ -1903,7 +1903,7 @@ bool cv::findChessboardCorners( InputArray _image, Size patternSize,
|
|||||||
OutputArray corners, int flags )
|
OutputArray corners, int flags )
|
||||||
{
|
{
|
||||||
int count = patternSize.area()*2;
|
int count = patternSize.area()*2;
|
||||||
vector<Point2f> tmpcorners(count+1);
|
std::vector<Point2f> tmpcorners(count+1);
|
||||||
Mat image = _image.getMat(); CvMat c_image = image;
|
Mat image = _image.getMat(); CvMat c_image = image;
|
||||||
bool ok = cvFindChessboardCorners(&c_image, patternSize,
|
bool ok = cvFindChessboardCorners(&c_image, patternSize,
|
||||||
(CvPoint2D32f*)&tmpcorners[0], &count, flags ) > 0;
|
(CvPoint2D32f*)&tmpcorners[0], &count, flags ) > 0;
|
||||||
@ -1949,11 +1949,11 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
|||||||
CV_Assert(isAsymmetricGrid ^ isSymmetricGrid);
|
CV_Assert(isAsymmetricGrid ^ isSymmetricGrid);
|
||||||
|
|
||||||
Mat image = _image.getMat();
|
Mat image = _image.getMat();
|
||||||
vector<Point2f> centers;
|
std::vector<Point2f> centers;
|
||||||
|
|
||||||
vector<KeyPoint> keypoints;
|
std::vector<KeyPoint> keypoints;
|
||||||
blobDetector->detect(image, keypoints);
|
blobDetector->detect(image, keypoints);
|
||||||
vector<Point2f> points;
|
std::vector<Point2f> points;
|
||||||
for (size_t i = 0; i < keypoints.size(); i++)
|
for (size_t i = 0; i < keypoints.size(); i++)
|
||||||
{
|
{
|
||||||
points.push_back (keypoints[i].pt);
|
points.push_back (keypoints[i].pt);
|
||||||
|
@ -546,7 +546,7 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian )
|
|||||||
ry = src->data.db[step];
|
ry = src->data.db[step];
|
||||||
rz = src->data.db[step*2];
|
rz = src->data.db[step*2];
|
||||||
}
|
}
|
||||||
theta = sqrt(rx*rx + ry*ry + rz*rz);
|
theta = std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||||
|
|
||||||
if( theta < DBL_EPSILON )
|
if( theta < DBL_EPSILON )
|
||||||
{
|
{
|
||||||
@ -632,7 +632,7 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian )
|
|||||||
ry = R[2] - R[6];
|
ry = R[2] - R[6];
|
||||||
rz = R[3] - R[1];
|
rz = R[3] - R[1];
|
||||||
|
|
||||||
s = sqrt((rx*rx + ry*ry + rz*rz)*0.25);
|
s = std::sqrt((rx*rx + ry*ry + rz*rz)*0.25);
|
||||||
c = (R[0] + R[4] + R[8] - 1)*0.5;
|
c = (R[0] + R[4] + R[8] - 1)*0.5;
|
||||||
c = c > 1. ? 1. : c < -1. ? -1. : c;
|
c = c > 1. ? 1. : c < -1. ? -1. : c;
|
||||||
theta = acos(c);
|
theta = acos(c);
|
||||||
@ -646,14 +646,14 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = (R[0] + 1)*0.5;
|
t = (R[0] + 1)*0.5;
|
||||||
rx = sqrt(MAX(t,0.));
|
rx = std::sqrt(MAX(t,0.));
|
||||||
t = (R[4] + 1)*0.5;
|
t = (R[4] + 1)*0.5;
|
||||||
ry = sqrt(MAX(t,0.))*(R[1] < 0 ? -1. : 1.);
|
ry = std::sqrt(MAX(t,0.))*(R[1] < 0 ? -1. : 1.);
|
||||||
t = (R[8] + 1)*0.5;
|
t = (R[8] + 1)*0.5;
|
||||||
rz = sqrt(MAX(t,0.))*(R[2] < 0 ? -1. : 1.);
|
rz = std::sqrt(MAX(t,0.))*(R[2] < 0 ? -1. : 1.);
|
||||||
if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R[5] > 0) != (ry*rz > 0) )
|
if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R[5] > 0) != (ry*rz > 0) )
|
||||||
rz = -rz;
|
rz = -rz;
|
||||||
theta /= sqrt(rx*rx + ry*ry + rz*rz);
|
theta /= std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||||
rx *= theta;
|
rx *= theta;
|
||||||
ry *= theta;
|
ry *= theta;
|
||||||
rz *= theta;
|
rz *= theta;
|
||||||
@ -1249,8 +1249,8 @@ CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints,
|
|||||||
cvGetCol( &matH, &_h1, 0 );
|
cvGetCol( &matH, &_h1, 0 );
|
||||||
_h2 = _h1; _h2.data.db++;
|
_h2 = _h1; _h2.data.db++;
|
||||||
_h3 = _h2; _h3.data.db++;
|
_h3 = _h2; _h3.data.db++;
|
||||||
h1_norm = sqrt(h[0]*h[0] + h[3]*h[3] + h[6]*h[6]);
|
h1_norm = std::sqrt(h[0]*h[0] + h[3]*h[3] + h[6]*h[6]);
|
||||||
h2_norm = sqrt(h[1]*h[1] + h[4]*h[4] + h[7]*h[7]);
|
h2_norm = std::sqrt(h[1]*h[1] + h[4]*h[4] + h[7]*h[7]);
|
||||||
|
|
||||||
cvScale( &_h1, &_h1, 1./MAX(h1_norm, DBL_EPSILON) );
|
cvScale( &_h1, &_h1, 1./MAX(h1_norm, DBL_EPSILON) );
|
||||||
cvScale( &_h2, &_h2, 1./MAX(h2_norm, DBL_EPSILON) );
|
cvScale( &_h2, &_h2, 1./MAX(h2_norm, DBL_EPSILON) );
|
||||||
@ -1424,7 +1424,7 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for( j = 0; j < 4; j++ )
|
for( j = 0; j < 4; j++ )
|
||||||
n[j] = 1./sqrt(n[j]);
|
n[j] = 1./std::sqrt(n[j]);
|
||||||
|
|
||||||
for( j = 0; j < 3; j++ )
|
for( j = 0; j < 3; j++ )
|
||||||
{
|
{
|
||||||
@ -1438,8 +1438,8 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cvSolve( matA, _b, &_f, CV_NORMAL + CV_SVD );
|
cvSolve( matA, _b, &_f, CV_NORMAL + CV_SVD );
|
||||||
a[0] = sqrt(fabs(1./f[0]));
|
a[0] = std::sqrt(fabs(1./f[0]));
|
||||||
a[4] = sqrt(fabs(1./f[1]));
|
a[4] = std::sqrt(fabs(1./f[1]));
|
||||||
if( aspectRatio != 0 )
|
if( aspectRatio != 0 )
|
||||||
{
|
{
|
||||||
double tf = (a[0] + a[4])/(aspectRatio + 1.);
|
double tf = (a[0] + a[4])/(aspectRatio + 1.);
|
||||||
@ -2721,7 +2721,7 @@ CV_IMPL int cvStereoRectifyUncalibrated(
|
|||||||
cvMatMul( &T, &E2, &E2 );
|
cvMatMul( &T, &E2, &E2 );
|
||||||
|
|
||||||
int mirror = e2[0] < 0;
|
int mirror = e2[0] < 0;
|
||||||
double d = MAX(sqrt(e2[0]*e2[0] + e2[1]*e2[1]),DBL_EPSILON);
|
double d = MAX(std::sqrt(e2[0]*e2[0] + e2[1]*e2[1]),DBL_EPSILON);
|
||||||
double alpha = e2[0]/d;
|
double alpha = e2[0]/d;
|
||||||
double beta = e2[1]/d;
|
double beta = e2[1]/d;
|
||||||
double r[] =
|
double r[] =
|
||||||
@ -2841,7 +2841,7 @@ void cv::reprojectImageTo3D( InputArray _disparity,
|
|||||||
int x, cols = disparity.cols;
|
int x, cols = disparity.cols;
|
||||||
CV_Assert( cols >= 0 );
|
CV_Assert( cols >= 0 );
|
||||||
|
|
||||||
vector<float> _sbuf(cols+1), _dbuf(cols*3+1);
|
std::vector<float> _sbuf(cols+1), _dbuf(cols*3+1);
|
||||||
float* sbuf = &_sbuf[0], *dbuf = &_dbuf[0];
|
float* sbuf = &_sbuf[0], *dbuf = &_dbuf[0];
|
||||||
double minDisparity = FLT_MAX;
|
double minDisparity = FLT_MAX;
|
||||||
|
|
||||||
@ -2958,7 +2958,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
|
|||||||
*/
|
*/
|
||||||
s = matM[2][1];
|
s = matM[2][1];
|
||||||
c = matM[2][2];
|
c = matM[2][2];
|
||||||
z = 1./sqrt(c * c + s * s + DBL_EPSILON);
|
z = 1./std::sqrt(c * c + s * s + DBL_EPSILON);
|
||||||
c *= z;
|
c *= z;
|
||||||
s *= z;
|
s *= z;
|
||||||
|
|
||||||
@ -2977,7 +2977,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
|
|||||||
*/
|
*/
|
||||||
s = -matR[2][0];
|
s = -matR[2][0];
|
||||||
c = matR[2][2];
|
c = matR[2][2];
|
||||||
z = 1./sqrt(c * c + s * s + DBL_EPSILON);
|
z = 1./std::sqrt(c * c + s * s + DBL_EPSILON);
|
||||||
c *= z;
|
c *= z;
|
||||||
s *= z;
|
s *= z;
|
||||||
|
|
||||||
@ -2997,7 +2997,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
|
|||||||
|
|
||||||
s = matM[1][0];
|
s = matM[1][0];
|
||||||
c = matM[1][1];
|
c = matM[1][1];
|
||||||
z = 1./sqrt(c * c + s * s + DBL_EPSILON);
|
z = 1./std::sqrt(c * c + s * s + DBL_EPSILON);
|
||||||
c *= z;
|
c *= z;
|
||||||
s *= z;
|
s *= z;
|
||||||
|
|
||||||
@ -3683,7 +3683,7 @@ static void adjust3rdMatrix(InputArrayOfArrays _imgpt1_0,
|
|||||||
const Mat& R1, const Mat& R3, const Mat& P1, Mat& P3 )
|
const Mat& R1, const Mat& R3, const Mat& P1, Mat& P3 )
|
||||||
{
|
{
|
||||||
size_t n1 = _imgpt1_0.total(), n3 = _imgpt3_0.total();
|
size_t n1 = _imgpt1_0.total(), n3 = _imgpt3_0.total();
|
||||||
vector<Point2f> imgpt1, imgpt3;
|
std::vector<Point2f> imgpt1, imgpt3;
|
||||||
|
|
||||||
for( int i = 0; i < (int)std::min(n1, n3); i++ )
|
for( int i = 0; i < (int)std::min(n1, n3); i++ )
|
||||||
{
|
{
|
||||||
|
@ -53,10 +53,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#ifdef DEBUG_CIRCLES
|
#ifdef DEBUG_CIRCLES
|
||||||
void drawPoints(const vector<Point2f> &points, Mat &outImage, int radius = 2, Scalar color = Scalar::all(255), int thickness = -1)
|
void drawPoints(const std::vector<Point2f> &points, Mat &outImage, int radius = 2, Scalar color = Scalar::all(255), int thickness = -1)
|
||||||
{
|
{
|
||||||
for(size_t i=0; i<points.size(); i++)
|
for(size_t i=0; i<points.size(); i++)
|
||||||
{
|
{
|
||||||
@ -65,7 +64,7 @@ void drawPoints(const vector<Point2f> &points, Mat &outImage, int radius = 2, S
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void CirclesGridClusterFinder::hierarchicalClustering(const vector<Point2f> points, const Size &patternSz, vector<Point2f> &patternPoints)
|
void CirclesGridClusterFinder::hierarchicalClustering(const std::vector<Point2f> points, const Size &patternSz, std::vector<Point2f> &patternPoints)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||||
if(tegra::hierarchicalClustering(points, patternSz, patternPoints))
|
if(tegra::hierarchicalClustering(points, patternSz, patternPoints))
|
||||||
@ -96,7 +95,7 @@ void CirclesGridClusterFinder::hierarchicalClustering(const vector<Point2f> poin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<std::list<size_t> > clusters(points.size());
|
std::vector<std::list<size_t> > clusters(points.size());
|
||||||
for(size_t i=0; i<points.size(); i++)
|
for(size_t i=0; i<points.size(); i++)
|
||||||
{
|
{
|
||||||
clusters[i].push_back(i);
|
clusters[i].push_back(i);
|
||||||
@ -134,7 +133,7 @@ void CirclesGridClusterFinder::hierarchicalClustering(const vector<Point2f> poin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridClusterFinder::findGrid(const std::vector<cv::Point2f> points, cv::Size _patternSize, vector<Point2f>& centers)
|
void CirclesGridClusterFinder::findGrid(const std::vector<cv::Point2f> points, cv::Size _patternSize, std::vector<Point2f>& centers)
|
||||||
{
|
{
|
||||||
patternSize = _patternSize;
|
patternSize = _patternSize;
|
||||||
centers.clear();
|
centers.clear();
|
||||||
@ -143,7 +142,7 @@ void CirclesGridClusterFinder::findGrid(const std::vector<cv::Point2f> points, c
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Point2f> patternPoints;
|
std::vector<Point2f> patternPoints;
|
||||||
hierarchicalClustering(points, patternSize, patternPoints);
|
hierarchicalClustering(points, patternSize, patternPoints);
|
||||||
if(patternPoints.empty())
|
if(patternPoints.empty())
|
||||||
{
|
{
|
||||||
@ -156,18 +155,18 @@ void CirclesGridClusterFinder::findGrid(const std::vector<cv::Point2f> points, c
|
|||||||
imshow("pattern points", patternPointsImage);
|
imshow("pattern points", patternPointsImage);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vector<Point2f> hull2f;
|
std::vector<Point2f> hull2f;
|
||||||
convexHull(Mat(patternPoints), hull2f, false);
|
convexHull(Mat(patternPoints), hull2f, false);
|
||||||
const size_t cornersCount = isAsymmetricGrid ? 6 : 4;
|
const size_t cornersCount = isAsymmetricGrid ? 6 : 4;
|
||||||
if(hull2f.size() < cornersCount)
|
if(hull2f.size() < cornersCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vector<Point2f> corners;
|
std::vector<Point2f> corners;
|
||||||
findCorners(hull2f, corners);
|
findCorners(hull2f, corners);
|
||||||
if(corners.size() != cornersCount)
|
if(corners.size() != cornersCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vector<Point2f> outsideCorners, sortedCorners;
|
std::vector<Point2f> outsideCorners, sortedCorners;
|
||||||
if(isAsymmetricGrid)
|
if(isAsymmetricGrid)
|
||||||
{
|
{
|
||||||
findOutsideCorners(corners, outsideCorners);
|
findOutsideCorners(corners, outsideCorners);
|
||||||
@ -179,7 +178,7 @@ void CirclesGridClusterFinder::findGrid(const std::vector<cv::Point2f> points, c
|
|||||||
if(sortedCorners.size() != cornersCount)
|
if(sortedCorners.size() != cornersCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vector<Point2f> rectifiedPatternPoints;
|
std::vector<Point2f> rectifiedPatternPoints;
|
||||||
rectifyPatternPoints(patternPoints, sortedCorners, rectifiedPatternPoints);
|
rectifyPatternPoints(patternPoints, sortedCorners, rectifiedPatternPoints);
|
||||||
if(patternPoints.size() != rectifiedPatternPoints.size())
|
if(patternPoints.size() != rectifiedPatternPoints.size())
|
||||||
return;
|
return;
|
||||||
@ -190,7 +189,7 @@ void CirclesGridClusterFinder::findGrid(const std::vector<cv::Point2f> points, c
|
|||||||
void CirclesGridClusterFinder::findCorners(const std::vector<cv::Point2f> &hull2f, std::vector<cv::Point2f> &corners)
|
void CirclesGridClusterFinder::findCorners(const std::vector<cv::Point2f> &hull2f, std::vector<cv::Point2f> &corners)
|
||||||
{
|
{
|
||||||
//find angles (cosines) of vertices in convex hull
|
//find angles (cosines) of vertices in convex hull
|
||||||
vector<float> angles;
|
std::vector<float> angles;
|
||||||
for(size_t i=0; i<hull2f.size(); i++)
|
for(size_t i=0; i<hull2f.size(); i++)
|
||||||
{
|
{
|
||||||
Point2f vec1 = hull2f[(i+1) % hull2f.size()] - hull2f[i % hull2f.size()];
|
Point2f vec1 = hull2f[(i+1) % hull2f.size()] - hull2f[i % hull2f.size()];
|
||||||
@ -228,7 +227,7 @@ void CirclesGridClusterFinder::findOutsideCorners(const std::vector<cv::Point2f>
|
|||||||
imshow("corners", cornersImage);
|
imshow("corners", cornersImage);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vector<Point2f> tangentVectors(corners.size());
|
std::vector<Point2f> tangentVectors(corners.size());
|
||||||
for(size_t k=0; k<corners.size(); k++)
|
for(size_t k=0; k<corners.size(); k++)
|
||||||
{
|
{
|
||||||
Point2f diff = corners[(k + 1) % corners.size()] - corners[k];
|
Point2f diff = corners[(k + 1) % corners.size()] - corners[k];
|
||||||
@ -299,7 +298,7 @@ void CirclesGridClusterFinder::getSortedCorners(const std::vector<cv::Point2f> &
|
|||||||
Point2f center = std::accumulate(corners.begin(), corners.end(), Point2f(0.0f, 0.0f));
|
Point2f center = std::accumulate(corners.begin(), corners.end(), Point2f(0.0f, 0.0f));
|
||||||
center *= 1.0 / corners.size();
|
center *= 1.0 / corners.size();
|
||||||
|
|
||||||
vector<Point2f> centerToCorners;
|
std::vector<Point2f> centerToCorners;
|
||||||
for(size_t i=0; i<outsideCorners.size(); i++)
|
for(size_t i=0; i<outsideCorners.size(); i++)
|
||||||
{
|
{
|
||||||
centerToCorners.push_back(outsideCorners[i] - center);
|
centerToCorners.push_back(outsideCorners[i] - center);
|
||||||
@ -318,17 +317,17 @@ void CirclesGridClusterFinder::getSortedCorners(const std::vector<cv::Point2f> &
|
|||||||
|
|
||||||
std::vector<Point2f>::const_iterator firstCornerIterator = std::find(hull2f.begin(), hull2f.end(), firstCorner);
|
std::vector<Point2f>::const_iterator firstCornerIterator = std::find(hull2f.begin(), hull2f.end(), firstCorner);
|
||||||
sortedCorners.clear();
|
sortedCorners.clear();
|
||||||
for(vector<Point2f>::const_iterator it = firstCornerIterator; it != hull2f.end(); it++)
|
for(std::vector<Point2f>::const_iterator it = firstCornerIterator; it != hull2f.end(); it++)
|
||||||
{
|
{
|
||||||
vector<Point2f>::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it);
|
std::vector<Point2f>::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it);
|
||||||
if(itCorners != corners.end())
|
if(itCorners != corners.end())
|
||||||
{
|
{
|
||||||
sortedCorners.push_back(*it);
|
sortedCorners.push_back(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(vector<Point2f>::const_iterator it = hull2f.begin(); it != firstCornerIterator; it++)
|
for(std::vector<Point2f>::const_iterator it = hull2f.begin(); it != firstCornerIterator; it++)
|
||||||
{
|
{
|
||||||
vector<Point2f>::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it);
|
std::vector<Point2f>::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it);
|
||||||
if(itCorners != corners.end())
|
if(itCorners != corners.end())
|
||||||
{
|
{
|
||||||
sortedCorners.push_back(*it);
|
sortedCorners.push_back(*it);
|
||||||
@ -354,7 +353,7 @@ void CirclesGridClusterFinder::getSortedCorners(const std::vector<cv::Point2f> &
|
|||||||
void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2f> &patternPoints, const std::vector<cv::Point2f> &sortedCorners, std::vector<cv::Point2f> &rectifiedPatternPoints)
|
void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2f> &patternPoints, const std::vector<cv::Point2f> &sortedCorners, std::vector<cv::Point2f> &rectifiedPatternPoints)
|
||||||
{
|
{
|
||||||
//indices of corner points in pattern
|
//indices of corner points in pattern
|
||||||
vector<Point> trueIndices;
|
std::vector<Point> trueIndices;
|
||||||
trueIndices.push_back(Point(0, 0));
|
trueIndices.push_back(Point(0, 0));
|
||||||
trueIndices.push_back(Point(patternSize.width - 1, 0));
|
trueIndices.push_back(Point(patternSize.width - 1, 0));
|
||||||
if(isAsymmetricGrid)
|
if(isAsymmetricGrid)
|
||||||
@ -365,7 +364,7 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2
|
|||||||
trueIndices.push_back(Point(patternSize.width - 1, patternSize.height - 1));
|
trueIndices.push_back(Point(patternSize.width - 1, patternSize.height - 1));
|
||||||
trueIndices.push_back(Point(0, patternSize.height - 1));
|
trueIndices.push_back(Point(0, patternSize.height - 1));
|
||||||
|
|
||||||
vector<Point2f> idealPoints;
|
std::vector<Point2f> idealPoints;
|
||||||
for(size_t idx=0; idx<trueIndices.size(); idx++)
|
for(size_t idx=0; idx<trueIndices.size(); idx++)
|
||||||
{
|
{
|
||||||
int i = trueIndices[idx].y;
|
int i = trueIndices[idx].y;
|
||||||
@ -403,10 +402,10 @@ void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f>
|
|||||||
else
|
else
|
||||||
idealPt = Point2f(j*squareSize, i*squareSize);
|
idealPt = Point2f(j*squareSize, i*squareSize);
|
||||||
|
|
||||||
vector<float> query = Mat(idealPt);
|
std::vector<float> query = Mat(idealPt);
|
||||||
int knn = 1;
|
int knn = 1;
|
||||||
vector<int> indices(knn);
|
std::vector<int> indices(knn);
|
||||||
vector<float> dists(knn);
|
std::vector<float> dists(knn);
|
||||||
flannIndex.knnSearch(query, indices, dists, knn, flann::SearchParams());
|
flannIndex.knnSearch(query, indices, dists, knn, flann::SearchParams());
|
||||||
centers.push_back(patternPoints.at(indices[0]));
|
centers.push_back(patternPoints.at(indices[0]));
|
||||||
|
|
||||||
@ -439,7 +438,7 @@ void Graph::addVertex(size_t id)
|
|||||||
{
|
{
|
||||||
assert( !doesVertexExist( id ) );
|
assert( !doesVertexExist( id ) );
|
||||||
|
|
||||||
vertices.insert(pair<size_t, Vertex> (id, Vertex()));
|
vertices.insert(std::pair<size_t, Vertex> (id, Vertex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::addEdge(size_t id1, size_t id2)
|
void Graph::addEdge(size_t id1, size_t id2)
|
||||||
@ -534,7 +533,7 @@ CirclesGridFinder::Segment::Segment(cv::Point2f _s, cv::Point2f _e) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeShortestPath(Mat &predecessorMatrix, int v1, int v2, vector<int> &path);
|
void computeShortestPath(Mat &predecessorMatrix, int v1, int v2, std::vector<int> &path);
|
||||||
void computePredecessorMatrix(const Mat &dm, int verticesCount, Mat &predecessorMatrix);
|
void computePredecessorMatrix(const Mat &dm, int verticesCount, Mat &predecessorMatrix);
|
||||||
|
|
||||||
CirclesGridFinderParameters::CirclesGridFinderParameters()
|
CirclesGridFinderParameters::CirclesGridFinderParameters()
|
||||||
@ -557,7 +556,7 @@ CirclesGridFinderParameters::CirclesGridFinderParameters()
|
|||||||
gridType = SYMMETRIC_GRID;
|
gridType = SYMMETRIC_GRID;
|
||||||
}
|
}
|
||||||
|
|
||||||
CirclesGridFinder::CirclesGridFinder(Size _patternSize, const vector<Point2f> &testKeypoints,
|
CirclesGridFinder::CirclesGridFinder(Size _patternSize, const std::vector<Point2f> &testKeypoints,
|
||||||
const CirclesGridFinderParameters &_parameters) :
|
const CirclesGridFinderParameters &_parameters) :
|
||||||
patternSize(static_cast<size_t> (_patternSize.width), static_cast<size_t> (_patternSize.height))
|
patternSize(static_cast<size_t> (_patternSize.width), static_cast<size_t> (_patternSize.height))
|
||||||
{
|
{
|
||||||
@ -575,11 +574,11 @@ bool CirclesGridFinder::findHoles()
|
|||||||
{
|
{
|
||||||
case CirclesGridFinderParameters::SYMMETRIC_GRID:
|
case CirclesGridFinderParameters::SYMMETRIC_GRID:
|
||||||
{
|
{
|
||||||
vector<Point2f> vectors, filteredVectors, basis;
|
std::vector<Point2f> vectors, filteredVectors, basis;
|
||||||
Graph rng(0);
|
Graph rng(0);
|
||||||
computeRNG(rng, vectors);
|
computeRNG(rng, vectors);
|
||||||
filterOutliersByDensity(vectors, filteredVectors);
|
filterOutliersByDensity(vectors, filteredVectors);
|
||||||
vector<Graph> basisGraphs;
|
std::vector<Graph> basisGraphs;
|
||||||
findBasis(filteredVectors, basis, basisGraphs);
|
findBasis(filteredVectors, basis, basisGraphs);
|
||||||
findMCS(basis, basisGraphs);
|
findMCS(basis, basisGraphs);
|
||||||
break;
|
break;
|
||||||
@ -587,12 +586,12 @@ bool CirclesGridFinder::findHoles()
|
|||||||
|
|
||||||
case CirclesGridFinderParameters::ASYMMETRIC_GRID:
|
case CirclesGridFinderParameters::ASYMMETRIC_GRID:
|
||||||
{
|
{
|
||||||
vector<Point2f> vectors, tmpVectors, filteredVectors, basis;
|
std::vector<Point2f> vectors, tmpVectors, filteredVectors, basis;
|
||||||
Graph rng(0);
|
Graph rng(0);
|
||||||
computeRNG(rng, tmpVectors);
|
computeRNG(rng, tmpVectors);
|
||||||
rng2gridGraph(rng, vectors);
|
rng2gridGraph(rng, vectors);
|
||||||
filterOutliersByDensity(vectors, filteredVectors);
|
filterOutliersByDensity(vectors, filteredVectors);
|
||||||
vector<Graph> basisGraphs;
|
std::vector<Graph> basisGraphs;
|
||||||
findBasis(filteredVectors, basis, basisGraphs);
|
findBasis(filteredVectors, basis, basisGraphs);
|
||||||
findMCS(basis, basisGraphs);
|
findMCS(basis, basisGraphs);
|
||||||
eraseUsedGraph(basisGraphs);
|
eraseUsedGraph(basisGraphs);
|
||||||
@ -635,7 +634,7 @@ void CirclesGridFinder::rng2gridGraph(Graph &rng, std::vector<cv::Point2f> &vect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::eraseUsedGraph(vector<Graph> &basisGraphs) const
|
void CirclesGridFinder::eraseUsedGraph(std::vector<Graph> &basisGraphs) const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < holes.size(); i++)
|
for (size_t i = 0; i < holes.size(); i++)
|
||||||
{
|
{
|
||||||
@ -666,7 +665,7 @@ bool CirclesGridFinder::isDetectionCorrect()
|
|||||||
if (holes.size() != patternSize.height)
|
if (holes.size() != patternSize.height)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
set<size_t> vertices;
|
std::set<size_t> vertices;
|
||||||
for (size_t i = 0; i < holes.size(); i++)
|
for (size_t i = 0; i < holes.size(); i++)
|
||||||
{
|
{
|
||||||
if (holes[i].size() != patternSize.width)
|
if (holes[i].size() != patternSize.width)
|
||||||
@ -714,7 +713,7 @@ bool CirclesGridFinder::isDetectionCorrect()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set<size_t> vertices;
|
std::set<size_t> vertices;
|
||||||
for (size_t i = 0; i < largeHoles->size(); i++)
|
for (size_t i = 0; i < largeHoles->size(); i++)
|
||||||
{
|
{
|
||||||
if (largeHoles->at(i).size() != lw)
|
if (largeHoles->at(i).size() != lw)
|
||||||
@ -750,12 +749,12 @@ bool CirclesGridFinder::isDetectionCorrect()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::findMCS(const vector<Point2f> &basis, vector<Graph> &basisGraphs)
|
void CirclesGridFinder::findMCS(const std::vector<Point2f> &basis, std::vector<Graph> &basisGraphs)
|
||||||
{
|
{
|
||||||
holes.clear();
|
holes.clear();
|
||||||
Path longestPath;
|
Path longestPath;
|
||||||
size_t bestGraphIdx = findLongestPath(basisGraphs, longestPath);
|
size_t bestGraphIdx = findLongestPath(basisGraphs, longestPath);
|
||||||
vector<size_t> holesRow = longestPath.vertices;
|
std::vector<size_t> holesRow = longestPath.vertices;
|
||||||
|
|
||||||
while (holesRow.size() > std::max(patternSize.width, patternSize.height))
|
while (holesRow.size() > std::max(patternSize.width, patternSize.height))
|
||||||
{
|
{
|
||||||
@ -809,14 +808,14 @@ void CirclesGridFinder::findMCS(const vector<Point2f> &basis, vector<Graph> &bas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const vector<Point2f>& centers,
|
Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const std::vector<Point2f>& centers,
|
||||||
const vector<Point2f> &keypoints, vector<Point2f> &warpedKeypoints)
|
const std::vector<Point2f> &keypoints, std::vector<Point2f> &warpedKeypoints)
|
||||||
{
|
{
|
||||||
assert( !centers.empty() );
|
assert( !centers.empty() );
|
||||||
const float edgeLength = 30;
|
const float edgeLength = 30;
|
||||||
const Point2f offset(150, 150);
|
const Point2f offset(150, 150);
|
||||||
|
|
||||||
vector<Point2f> dstPoints;
|
std::vector<Point2f> dstPoints;
|
||||||
bool isClockwiseBefore =
|
bool isClockwiseBefore =
|
||||||
getDirection(centers[0], centers[detectedGridSize.width - 1], centers[centers.size() - 1]) < 0;
|
getDirection(centers[0], centers[detectedGridSize.width - 1], centers[centers.size() - 1]) < 0;
|
||||||
|
|
||||||
@ -834,7 +833,7 @@ Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const vector<Point2f>&
|
|||||||
Mat H = findHomography(Mat(centers), Mat(dstPoints), CV_RANSAC);
|
Mat H = findHomography(Mat(centers), Mat(dstPoints), CV_RANSAC);
|
||||||
//Mat H = findHomography( Mat( corners ), Mat( dstPoints ) );
|
//Mat H = findHomography( Mat( corners ), Mat( dstPoints ) );
|
||||||
|
|
||||||
vector<Point2f> srcKeypoints;
|
std::vector<Point2f> srcKeypoints;
|
||||||
for (size_t i = 0; i < keypoints.size(); i++)
|
for (size_t i = 0; i < keypoints.size(); i++)
|
||||||
{
|
{
|
||||||
srcKeypoints.push_back(keypoints[i]);
|
srcKeypoints.push_back(keypoints[i]);
|
||||||
@ -842,7 +841,7 @@ Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const vector<Point2f>&
|
|||||||
|
|
||||||
Mat dstKeypointsMat;
|
Mat dstKeypointsMat;
|
||||||
transform(Mat(srcKeypoints), dstKeypointsMat, H);
|
transform(Mat(srcKeypoints), dstKeypointsMat, H);
|
||||||
vector<Point2f> dstKeypoints;
|
std::vector<Point2f> dstKeypoints;
|
||||||
convertPointsFromHomogeneous(dstKeypointsMat, dstKeypoints);
|
convertPointsFromHomogeneous(dstKeypointsMat, dstKeypoints);
|
||||||
|
|
||||||
warpedKeypoints.clear();
|
warpedKeypoints.clear();
|
||||||
@ -871,7 +870,7 @@ size_t CirclesGridFinder::findNearestKeypoint(Point2f pt) const
|
|||||||
return bestIdx;
|
return bestIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::addPoint(Point2f pt, vector<size_t> &points)
|
void CirclesGridFinder::addPoint(Point2f pt, std::vector<size_t> &points)
|
||||||
{
|
{
|
||||||
size_t ptIdx = findNearestKeypoint(pt);
|
size_t ptIdx = findNearestKeypoint(pt);
|
||||||
if (norm(keypoints[ptIdx] - pt) > parameters.minDistanceToAddKeypoint)
|
if (norm(keypoints[ptIdx] - pt) > parameters.minDistanceToAddKeypoint)
|
||||||
@ -886,8 +885,8 @@ void CirclesGridFinder::addPoint(Point2f pt, vector<size_t> &points)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::findCandidateLine(vector<size_t> &line, size_t seedLineIdx, bool addRow, Point2f basisVec,
|
void CirclesGridFinder::findCandidateLine(std::vector<size_t> &line, size_t seedLineIdx, bool addRow, Point2f basisVec,
|
||||||
vector<size_t> &seeds)
|
std::vector<size_t> &seeds)
|
||||||
{
|
{
|
||||||
line.clear();
|
line.clear();
|
||||||
seeds.clear();
|
seeds.clear();
|
||||||
@ -914,8 +913,8 @@ void CirclesGridFinder::findCandidateLine(vector<size_t> &line, size_t seedLineI
|
|||||||
assert( line.size() == seeds.size() );
|
assert( line.size() == seeds.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::findCandidateHoles(vector<size_t> &above, vector<size_t> &below, bool addRow, Point2f basisVec,
|
void CirclesGridFinder::findCandidateHoles(std::vector<size_t> &above, std::vector<size_t> &below, bool addRow, Point2f basisVec,
|
||||||
vector<size_t> &aboveSeeds, vector<size_t> &belowSeeds)
|
std::vector<size_t> &aboveSeeds, std::vector<size_t> &belowSeeds)
|
||||||
{
|
{
|
||||||
above.clear();
|
above.clear();
|
||||||
below.clear();
|
below.clear();
|
||||||
@ -931,7 +930,7 @@ void CirclesGridFinder::findCandidateHoles(vector<size_t> &above, vector<size_t>
|
|||||||
assert( below.size() == belowSeeds.size() );
|
assert( below.size() == belowSeeds.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CirclesGridFinder::areCentersNew(const vector<size_t> &newCenters, const vector<vector<size_t> > &holes)
|
bool CirclesGridFinder::areCentersNew(const std::vector<size_t> &newCenters, const std::vector<std::vector<size_t> > &holes)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < newCenters.size(); i++)
|
for (size_t i = 0; i < newCenters.size(); i++)
|
||||||
{
|
{
|
||||||
@ -948,8 +947,8 @@ bool CirclesGridFinder::areCentersNew(const vector<size_t> &newCenters, const ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::insertWinner(float aboveConfidence, float belowConfidence, float minConfidence, bool addRow,
|
void CirclesGridFinder::insertWinner(float aboveConfidence, float belowConfidence, float minConfidence, bool addRow,
|
||||||
const vector<size_t> &above, const vector<size_t> &below,
|
const std::vector<size_t> &above, const std::vector<size_t> &below,
|
||||||
vector<vector<size_t> > &holes)
|
std::vector<std::vector<size_t> > &holes)
|
||||||
{
|
{
|
||||||
if (aboveConfidence < minConfidence && belowConfidence < minConfidence)
|
if (aboveConfidence < minConfidence && belowConfidence < minConfidence)
|
||||||
return;
|
return;
|
||||||
@ -996,8 +995,8 @@ void CirclesGridFinder::insertWinner(float aboveConfidence, float belowConfidenc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float CirclesGridFinder::computeGraphConfidence(const vector<Graph> &basisGraphs, bool addRow,
|
float CirclesGridFinder::computeGraphConfidence(const std::vector<Graph> &basisGraphs, bool addRow,
|
||||||
const vector<size_t> &points, const vector<size_t> &seeds)
|
const std::vector<size_t> &points, const std::vector<size_t> &seeds)
|
||||||
{
|
{
|
||||||
assert( points.size() == seeds.size() );
|
assert( points.size() == seeds.size() );
|
||||||
float confidence = 0;
|
float confidence = 0;
|
||||||
@ -1042,9 +1041,9 @@ float CirclesGridFinder::computeGraphConfidence(const vector<Graph> &basisGraphs
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::addHolesByGraph(const vector<Graph> &basisGraphs, bool addRow, Point2f basisVec)
|
void CirclesGridFinder::addHolesByGraph(const std::vector<Graph> &basisGraphs, bool addRow, Point2f basisVec)
|
||||||
{
|
{
|
||||||
vector<size_t> above, below, aboveSeeds, belowSeeds;
|
std::vector<size_t> above, below, aboveSeeds, belowSeeds;
|
||||||
findCandidateHoles(above, below, addRow, basisVec, aboveSeeds, belowSeeds);
|
findCandidateHoles(above, below, addRow, basisVec, aboveSeeds, belowSeeds);
|
||||||
float aboveConfidence = computeGraphConfidence(basisGraphs, addRow, above, aboveSeeds);
|
float aboveConfidence = computeGraphConfidence(basisGraphs, addRow, above, aboveSeeds);
|
||||||
float belowConfidence = computeGraphConfidence(basisGraphs, addRow, below, belowSeeds);
|
float belowConfidence = computeGraphConfidence(basisGraphs, addRow, below, belowSeeds);
|
||||||
@ -1052,7 +1051,7 @@ void CirclesGridFinder::addHolesByGraph(const vector<Graph> &basisGraphs, bool a
|
|||||||
insertWinner(aboveConfidence, belowConfidence, parameters.minGraphConfidence, addRow, above, below, holes);
|
insertWinner(aboveConfidence, belowConfidence, parameters.minGraphConfidence, addRow, above, below, holes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::filterOutliersByDensity(const vector<Point2f> &samples, vector<Point2f> &filteredSamples)
|
void CirclesGridFinder::filterOutliersByDensity(const std::vector<Point2f> &samples, std::vector<Point2f> &filteredSamples)
|
||||||
{
|
{
|
||||||
if (samples.empty())
|
if (samples.empty())
|
||||||
CV_Error( 0, "samples is empty" );
|
CV_Error( 0, "samples is empty" );
|
||||||
@ -1077,7 +1076,7 @@ void CirclesGridFinder::filterOutliersByDensity(const vector<Point2f> &samples,
|
|||||||
CV_Error( 0, "filteredSamples is empty" );
|
CV_Error( 0, "filteredSamples is empty" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::findBasis(const vector<Point2f> &samples, vector<Point2f> &basis, vector<Graph> &basisGraphs)
|
void CirclesGridFinder::findBasis(const std::vector<Point2f> &samples, std::vector<Point2f> &basis, std::vector<Graph> &basisGraphs)
|
||||||
{
|
{
|
||||||
basis.clear();
|
basis.clear();
|
||||||
Mat bestLabels;
|
Mat bestLabels;
|
||||||
@ -1088,7 +1087,7 @@ void CirclesGridFinder::findBasis(const vector<Point2f> &samples, vector<Point2f
|
|||||||
KMEANS_RANDOM_CENTERS, centers);
|
KMEANS_RANDOM_CENTERS, centers);
|
||||||
assert( centers.type() == CV_32FC1 );
|
assert( centers.type() == CV_32FC1 );
|
||||||
|
|
||||||
vector<int> basisIndices;
|
std::vector<int> basisIndices;
|
||||||
//TODO: only remove duplicate
|
//TODO: only remove duplicate
|
||||||
for (int i = 0; i < clustersCount; i++)
|
for (int i = 0; i < clustersCount; i++)
|
||||||
{
|
{
|
||||||
@ -1113,7 +1112,7 @@ void CirclesGridFinder::findBasis(const vector<Point2f> &samples, vector<Point2f
|
|||||||
if (norm(basis[0] - basis[1]) < minBasisDif)
|
if (norm(basis[0] - basis[1]) < minBasisDif)
|
||||||
CV_Error(0, "degenerate basis" );
|
CV_Error(0, "degenerate basis" );
|
||||||
|
|
||||||
vector<vector<Point2f> > clusters(2), hulls(2);
|
std::vector<std::vector<Point2f> > clusters(2), hulls(2);
|
||||||
for (int k = 0; k < (int)samples.size(); k++)
|
for (int k = 0; k < (int)samples.size(); k++)
|
||||||
{
|
{
|
||||||
int label = bestLabels.at<int> (k, 0);
|
int label = bestLabels.at<int> (k, 0);
|
||||||
@ -1223,7 +1222,7 @@ void computePredecessorMatrix(const Mat &dm, int verticesCount, Mat &predecessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, vector<size_t> &path)
|
static void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, std::vector<size_t> &path)
|
||||||
{
|
{
|
||||||
if (predecessorMatrix.at<int> ((int)v1, (int)v2) < 0)
|
if (predecessorMatrix.at<int> ((int)v1, (int)v2) < 0)
|
||||||
{
|
{
|
||||||
@ -1235,10 +1234,10 @@ static void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, ve
|
|||||||
path.push_back(v2);
|
path.push_back(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CirclesGridFinder::findLongestPath(vector<Graph> &basisGraphs, Path &bestPath)
|
size_t CirclesGridFinder::findLongestPath(std::vector<Graph> &basisGraphs, Path &bestPath)
|
||||||
{
|
{
|
||||||
vector<Path> longestPaths(1);
|
std::vector<Path> longestPaths(1);
|
||||||
vector<int> confidences;
|
std::vector<int> confidences;
|
||||||
|
|
||||||
size_t bestGraphIdx = 0;
|
size_t bestGraphIdx = 0;
|
||||||
const int infinity = -1;
|
const int infinity = -1;
|
||||||
@ -1305,7 +1304,7 @@ size_t CirclesGridFinder::findLongestPath(vector<Graph> &basisGraphs, Path &best
|
|||||||
return bestGraphIdx;
|
return bestGraphIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::drawBasis(const vector<Point2f> &basis, Point2f origin, Mat &drawImg) const
|
void CirclesGridFinder::drawBasis(const std::vector<Point2f> &basis, Point2f origin, Mat &drawImg) const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < basis.size(); i++)
|
for (size_t i = 0; i < basis.size(); i++)
|
||||||
{
|
{
|
||||||
@ -1314,7 +1313,7 @@ void CirclesGridFinder::drawBasis(const vector<Point2f> &basis, Point2f origin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::drawBasisGraphs(const vector<Graph> &basisGraphs, Mat &drawImage, bool drawEdges,
|
void CirclesGridFinder::drawBasisGraphs(const std::vector<Graph> &basisGraphs, Mat &drawImage, bool drawEdges,
|
||||||
bool drawVertices) const
|
bool drawVertices) const
|
||||||
{
|
{
|
||||||
//const int vertexRadius = 1;
|
//const int vertexRadius = 1;
|
||||||
@ -1390,7 +1389,7 @@ Size CirclesGridFinder::getDetectedGridSize() const
|
|||||||
return Size((int)holes[0].size(), (int)holes.size());
|
return Size((int)holes[0].size(), (int)holes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::getHoles(vector<Point2f> &outHoles) const
|
void CirclesGridFinder::getHoles(std::vector<Point2f> &outHoles) const
|
||||||
{
|
{
|
||||||
outHoles.clear();
|
outHoles.clear();
|
||||||
|
|
||||||
@ -1403,7 +1402,7 @@ void CirclesGridFinder::getHoles(vector<Point2f> &outHoles) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool areIndicesCorrect(Point pos, vector<vector<size_t> > *points)
|
static bool areIndicesCorrect(Point pos, std::vector<std::vector<size_t> > *points)
|
||||||
{
|
{
|
||||||
if (pos.y < 0 || pos.x < 0)
|
if (pos.y < 0 || pos.x < 0)
|
||||||
return false;
|
return false;
|
||||||
@ -1414,8 +1413,8 @@ void CirclesGridFinder::getAsymmetricHoles(std::vector<cv::Point2f> &outHoles) c
|
|||||||
{
|
{
|
||||||
outHoles.clear();
|
outHoles.clear();
|
||||||
|
|
||||||
vector<Point> largeCornerIndices, smallCornerIndices;
|
std::vector<Point> largeCornerIndices, smallCornerIndices;
|
||||||
vector<Point> firstSteps, secondSteps;
|
std::vector<Point> firstSteps, secondSteps;
|
||||||
size_t cornerIdx = getFirstCorner(largeCornerIndices, smallCornerIndices, firstSteps, secondSteps);
|
size_t cornerIdx = getFirstCorner(largeCornerIndices, smallCornerIndices, firstSteps, secondSteps);
|
||||||
CV_Assert(largeHoles != 0 && smallHoles != 0)
|
CV_Assert(largeHoles != 0 && smallHoles != 0)
|
||||||
;
|
;
|
||||||
@ -1472,9 +1471,9 @@ bool CirclesGridFinder::areSegmentsIntersecting(Segment seg1, Segment seg2)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesGridFinder::getCornerSegments(const vector<vector<size_t> > &points, vector<vector<Segment> > &segments,
|
void CirclesGridFinder::getCornerSegments(const std::vector<std::vector<size_t> > &points, std::vector<std::vector<Segment> > &segments,
|
||||||
vector<Point> &cornerIndices, vector<Point> &firstSteps,
|
std::vector<Point> &cornerIndices, std::vector<Point> &firstSteps,
|
||||||
vector<Point> &secondSteps) const
|
std::vector<Point> &secondSteps) const
|
||||||
{
|
{
|
||||||
segments.clear();
|
segments.clear();
|
||||||
cornerIndices.clear();
|
cornerIndices.clear();
|
||||||
@ -1486,7 +1485,7 @@ void CirclesGridFinder::getCornerSegments(const vector<vector<size_t> > &points,
|
|||||||
;
|
;
|
||||||
|
|
||||||
//all 8 segments with one end in a corner
|
//all 8 segments with one end in a corner
|
||||||
vector<Segment> corner;
|
std::vector<Segment> corner;
|
||||||
corner.push_back(Segment(keypoints[points[1][0]], keypoints[points[0][0]]));
|
corner.push_back(Segment(keypoints[points[1][0]], keypoints[points[0][0]]));
|
||||||
corner.push_back(Segment(keypoints[points[0][0]], keypoints[points[0][1]]));
|
corner.push_back(Segment(keypoints[points[0][0]], keypoints[points[0][1]]));
|
||||||
segments.push_back(corner);
|
segments.push_back(corner);
|
||||||
@ -1535,7 +1534,7 @@ void CirclesGridFinder::getCornerSegments(const vector<vector<size_t> > &points,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CirclesGridFinder::doesIntersectionExist(const vector<Segment> &corner, const vector<vector<Segment> > &segments)
|
bool CirclesGridFinder::doesIntersectionExist(const std::vector<Segment> &corner, const std::vector<std::vector<Segment> > &segments)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < corner.size(); i++)
|
for (size_t i = 0; i < corner.size(); i++)
|
||||||
{
|
{
|
||||||
@ -1552,11 +1551,11 @@ bool CirclesGridFinder::doesIntersectionExist(const vector<Segment> &corner, con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CirclesGridFinder::getFirstCorner(vector<Point> &largeCornerIndices, vector<Point> &smallCornerIndices, vector<
|
size_t CirclesGridFinder::getFirstCorner(std::vector<Point> &largeCornerIndices, std::vector<Point> &smallCornerIndices, std::vector<
|
||||||
Point> &firstSteps, vector<Point> &secondSteps) const
|
Point> &firstSteps, std::vector<Point> &secondSteps) const
|
||||||
{
|
{
|
||||||
vector<vector<Segment> > largeSegments;
|
std::vector<std::vector<Segment> > largeSegments;
|
||||||
vector<vector<Segment> > smallSegments;
|
std::vector<std::vector<Segment> > smallSegments;
|
||||||
|
|
||||||
getCornerSegments(*largeHoles, largeSegments, largeCornerIndices, firstSteps, secondSteps);
|
getCornerSegments(*largeHoles, largeSegments, largeCornerIndices, firstSteps, secondSteps);
|
||||||
getCornerSegments(*smallHoles, smallSegments, smallCornerIndices, firstSteps, secondSteps);
|
getCornerSegments(*smallHoles, smallSegments, smallCornerIndices, firstSteps, secondSteps);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
#include "epnp.h"
|
#include "epnp.h"
|
||||||
|
|
||||||
|
@ -3,31 +3,30 @@
|
|||||||
#include "_modelest.h"
|
#include "_modelest.h"
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class CvEMEstimator : public CvModelEstimator2
|
class CvEMEstimator : public CvModelEstimator2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CvEMEstimator();
|
CvEMEstimator();
|
||||||
virtual int runKernel( const CvMat* m1, const CvMat* m2, CvMat* model );
|
virtual int runKernel( const CvMat* m1, const CvMat* m2, CvMat* model );
|
||||||
virtual int run5Point( const CvMat* _q1, const CvMat* _q2, CvMat* _ematrix );
|
virtual int run5Point( const CvMat* _q1, const CvMat* _q2, CvMat* _ematrix );
|
||||||
protected:
|
protected:
|
||||||
bool reliable( const CvMat* m1, const CvMat* m2, const CvMat* model );
|
bool reliable( const CvMat* m1, const CvMat* m2, const CvMat* model );
|
||||||
virtual void calibrated_fivepoint_helper( double *eet, double* at );
|
virtual void calibrated_fivepoint_helper( double *eet, double* at );
|
||||||
virtual void computeReprojError( const CvMat* m1, const CvMat* m2,
|
virtual void computeReprojError( const CvMat* m1, const CvMat* m2,
|
||||||
const CvMat* model, CvMat* error );
|
const CvMat* model, CvMat* error );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Input should be a vector of n 2D points or a Nx2 matrix
|
// Input should be a vector of n 2D points or a Nx2 matrix
|
||||||
Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal, Point2d pp,
|
Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal, Point2d pp,
|
||||||
int method, double prob, double threshold, OutputArray _mask)
|
int method, double prob, double threshold, OutputArray _mask)
|
||||||
{
|
{
|
||||||
Mat points1, points2;
|
Mat points1, points2;
|
||||||
_points1.getMat().copyTo(points1);
|
_points1.getMat().copyTo(points1);
|
||||||
_points2.getMat().copyTo(points2);
|
_points2.getMat().copyTo(points2);
|
||||||
|
|
||||||
int npoints = points1.checkVector(2);
|
int npoints = points1.checkVector(2);
|
||||||
CV_Assert( npoints >= 5 && points2.checkVector(2) == npoints &&
|
CV_Assert( npoints >= 5 && points2.checkVector(2) == npoints &&
|
||||||
@ -35,231 +34,231 @@ Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal
|
|||||||
|
|
||||||
if (points1.channels() > 1)
|
if (points1.channels() > 1)
|
||||||
{
|
{
|
||||||
points1 = points1.reshape(1, npoints);
|
points1 = points1.reshape(1, npoints);
|
||||||
points2 = points2.reshape(1, npoints);
|
points2 = points2.reshape(1, npoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
points1.convertTo(points1, CV_64F);
|
|
||||||
points2.convertTo(points2, CV_64F);
|
|
||||||
|
|
||||||
points1.col(0) = (points1.col(0) - pp.x) / focal;
|
points1.convertTo(points1, CV_64F);
|
||||||
points2.col(0) = (points2.col(0) - pp.x) / focal;
|
points2.convertTo(points2, CV_64F);
|
||||||
points1.col(1) = (points1.col(1) - pp.y) / focal;
|
|
||||||
points2.col(1) = (points2.col(1) - pp.y) / focal;
|
points1.col(0) = (points1.col(0) - pp.x) / focal;
|
||||||
|
points2.col(0) = (points2.col(0) - pp.x) / focal;
|
||||||
|
points1.col(1) = (points1.col(1) - pp.y) / focal;
|
||||||
|
points2.col(1) = (points2.col(1) - pp.y) / focal;
|
||||||
|
|
||||||
// Reshape data to fit opencv ransac function
|
// Reshape data to fit opencv ransac function
|
||||||
points1 = points1.reshape(2, 1);
|
points1 = points1.reshape(2, 1);
|
||||||
points2 = points2.reshape(2, 1);
|
points2 = points2.reshape(2, 1);
|
||||||
|
|
||||||
Mat E(3, 3, CV_64F);
|
Mat E(3, 3, CV_64F);
|
||||||
CvEMEstimator estimator;
|
CvEMEstimator estimator;
|
||||||
|
|
||||||
CvMat p1 = points1;
|
CvMat p1 = points1;
|
||||||
CvMat p2 = points2;
|
CvMat p2 = points2;
|
||||||
CvMat _E = E;
|
CvMat _E = E;
|
||||||
CvMat* tempMask = cvCreateMat(1, npoints, CV_8U);
|
CvMat* tempMask = cvCreateMat(1, npoints, CV_8U);
|
||||||
|
|
||||||
assert(npoints >= 5);
|
assert(npoints >= 5);
|
||||||
threshold /= focal;
|
threshold /= focal;
|
||||||
int count = 1;
|
int count = 1;
|
||||||
if (npoints == 5)
|
if (npoints == 5)
|
||||||
{
|
{
|
||||||
E.create(3 * 10, 3, CV_64F);
|
E.create(3 * 10, 3, CV_64F);
|
||||||
_E = E;
|
_E = E;
|
||||||
count = estimator.runKernel(&p1, &p2, &_E);
|
count = estimator.runKernel(&p1, &p2, &_E);
|
||||||
E = E.rowRange(0, 3 * count) * 1.0;
|
E = E.rowRange(0, 3 * count) * 1.0;
|
||||||
Mat(tempMask).setTo(true);
|
Mat(tempMask).setTo(true);
|
||||||
}
|
}
|
||||||
else if (method == CV_RANSAC)
|
else if (method == CV_RANSAC)
|
||||||
{
|
{
|
||||||
estimator.runRANSAC(&p1, &p2, &_E, tempMask, threshold, prob);
|
estimator.runRANSAC(&p1, &p2, &_E, tempMask, threshold, prob);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
estimator.runLMeDS(&p1, &p2, &_E, tempMask, prob);
|
estimator.runLMeDS(&p1, &p2, &_E, tempMask, prob);
|
||||||
}
|
}
|
||||||
if (_mask.needed())
|
if (_mask.needed())
|
||||||
{
|
{
|
||||||
_mask.create(1, npoints, CV_8U, -1, true);
|
_mask.create(1, npoints, CV_8U, -1, true);
|
||||||
Mat mask = _mask.getMat();
|
Mat mask = _mask.getMat();
|
||||||
Mat(tempMask).copyTo(mask);
|
Mat(tempMask).copyTo(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return E;
|
|
||||||
|
return E;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, OutputArray _R, OutputArray _t,
|
int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, OutputArray _R, OutputArray _t,
|
||||||
double focal, Point2d pp,
|
double focal, Point2d pp,
|
||||||
InputOutputArray _mask)
|
InputOutputArray _mask)
|
||||||
{
|
{
|
||||||
Mat points1, points2;
|
Mat points1, points2;
|
||||||
_points1.getMat().copyTo(points1);
|
_points1.getMat().copyTo(points1);
|
||||||
_points2.getMat().copyTo(points2);
|
_points2.getMat().copyTo(points2);
|
||||||
|
|
||||||
int npoints = points1.checkVector(2);
|
int npoints = points1.checkVector(2);
|
||||||
CV_Assert( npoints >= 0 && points2.checkVector(2) == npoints &&
|
CV_Assert( npoints >= 0 && points2.checkVector(2) == npoints &&
|
||||||
points1.type() == points2.type());
|
points1.type() == points2.type());
|
||||||
|
|
||||||
if (points1.channels() > 1)
|
if (points1.channels() > 1)
|
||||||
{
|
{
|
||||||
points1 = points1.reshape(1, npoints);
|
points1 = points1.reshape(1, npoints);
|
||||||
points2 = points2.reshape(1, npoints);
|
points2 = points2.reshape(1, npoints);
|
||||||
}
|
}
|
||||||
points1.convertTo(points1, CV_64F);
|
points1.convertTo(points1, CV_64F);
|
||||||
points2.convertTo(points2, CV_64F);
|
points2.convertTo(points2, CV_64F);
|
||||||
|
|
||||||
points1.col(0) = (points1.col(0) - pp.x) / focal;
|
points1.col(0) = (points1.col(0) - pp.x) / focal;
|
||||||
points2.col(0) = (points2.col(0) - pp.x) / focal;
|
points2.col(0) = (points2.col(0) - pp.x) / focal;
|
||||||
points1.col(1) = (points1.col(1) - pp.y) / focal;
|
points1.col(1) = (points1.col(1) - pp.y) / focal;
|
||||||
points2.col(1) = (points2.col(1) - pp.y) / focal;
|
points2.col(1) = (points2.col(1) - pp.y) / focal;
|
||||||
|
|
||||||
points1 = points1.t();
|
points1 = points1.t();
|
||||||
points2 = points2.t();
|
points2 = points2.t();
|
||||||
|
|
||||||
Mat R1, R2, t;
|
|
||||||
decomposeEssentialMat(E, R1, R2, t);
|
|
||||||
Mat P0 = Mat::eye(3, 4, R1.type());
|
|
||||||
Mat P1(3, 4, R1.type()), P2(3, 4, R1.type()), P3(3, 4, R1.type()), P4(3, 4, R1.type());
|
|
||||||
P1(Range::all(), Range(0, 3)) = R1 * 1.0; P1.col(3) = t * 1.0;
|
|
||||||
P2(Range::all(), Range(0, 3)) = R2 * 1.0; P2.col(3) = t * 1.0;
|
|
||||||
P3(Range::all(), Range(0, 3)) = R1 * 1.0; P3.col(3) = -t * 1.0;
|
|
||||||
P4(Range::all(), Range(0, 3)) = R2 * 1.0; P4.col(3) = -t * 1.0;
|
|
||||||
|
|
||||||
// Do the cheirality check.
|
Mat R1, R2, t;
|
||||||
|
decomposeEssentialMat(E, R1, R2, t);
|
||||||
|
Mat P0 = Mat::eye(3, 4, R1.type());
|
||||||
|
Mat P1(3, 4, R1.type()), P2(3, 4, R1.type()), P3(3, 4, R1.type()), P4(3, 4, R1.type());
|
||||||
|
P1(Range::all(), Range(0, 3)) = R1 * 1.0; P1.col(3) = t * 1.0;
|
||||||
|
P2(Range::all(), Range(0, 3)) = R2 * 1.0; P2.col(3) = t * 1.0;
|
||||||
|
P3(Range::all(), Range(0, 3)) = R1 * 1.0; P3.col(3) = -t * 1.0;
|
||||||
|
P4(Range::all(), Range(0, 3)) = R2 * 1.0; P4.col(3) = -t * 1.0;
|
||||||
|
|
||||||
|
// Do the cheirality check.
|
||||||
// Notice here a threshold dist is used to filter
|
// Notice here a threshold dist is used to filter
|
||||||
// out far away points (i.e. infinite points) since
|
// out far away points (i.e. infinite points) since
|
||||||
// there depth may vary between postive and negtive.
|
// there depth may vary between postive and negtive.
|
||||||
double dist = 50.0;
|
double dist = 50.0;
|
||||||
Mat Q;
|
Mat Q;
|
||||||
triangulatePoints(P0, P1, points1, points2, Q);
|
triangulatePoints(P0, P1, points1, points2, Q);
|
||||||
Mat mask1 = Q.row(2).mul(Q.row(3)) > 0;
|
Mat mask1 = Q.row(2).mul(Q.row(3)) > 0;
|
||||||
Q.row(0) /= Q.row(3);
|
Q.row(0) /= Q.row(3);
|
||||||
Q.row(1) /= Q.row(3);
|
Q.row(1) /= Q.row(3);
|
||||||
Q.row(2) /= Q.row(3);
|
Q.row(2) /= Q.row(3);
|
||||||
Q.row(3) /= Q.row(3);
|
Q.row(3) /= Q.row(3);
|
||||||
mask1 = (Q.row(2) < dist) & mask1;
|
mask1 = (Q.row(2) < dist) & mask1;
|
||||||
Q = P1 * Q;
|
Q = P1 * Q;
|
||||||
mask1 = (Q.row(2) > 0) & mask1;
|
mask1 = (Q.row(2) > 0) & mask1;
|
||||||
mask1 = (Q.row(2) < dist) & mask1;
|
mask1 = (Q.row(2) < dist) & mask1;
|
||||||
|
|
||||||
triangulatePoints(P0, P2, points1, points2, Q);
|
triangulatePoints(P0, P2, points1, points2, Q);
|
||||||
Mat mask2 = Q.row(2).mul(Q.row(3)) > 0;
|
Mat mask2 = Q.row(2).mul(Q.row(3)) > 0;
|
||||||
Q.row(0) /= Q.row(3);
|
Q.row(0) /= Q.row(3);
|
||||||
Q.row(1) /= Q.row(3);
|
Q.row(1) /= Q.row(3);
|
||||||
Q.row(2) /= Q.row(3);
|
Q.row(2) /= Q.row(3);
|
||||||
Q.row(3) /= Q.row(3);
|
Q.row(3) /= Q.row(3);
|
||||||
mask2 = (Q.row(2) < dist) & mask2;
|
mask2 = (Q.row(2) < dist) & mask2;
|
||||||
Q = P2 * Q;
|
Q = P2 * Q;
|
||||||
mask2 = (Q.row(2) > 0) & mask2;
|
mask2 = (Q.row(2) > 0) & mask2;
|
||||||
mask2 = (Q.row(2) < dist) & mask2;
|
mask2 = (Q.row(2) < dist) & mask2;
|
||||||
|
|
||||||
triangulatePoints(P0, P3, points1, points2, Q);
|
triangulatePoints(P0, P3, points1, points2, Q);
|
||||||
Mat mask3 = Q.row(2).mul(Q.row(3)) > 0;
|
Mat mask3 = Q.row(2).mul(Q.row(3)) > 0;
|
||||||
Q.row(0) /= Q.row(3);
|
Q.row(0) /= Q.row(3);
|
||||||
Q.row(1) /= Q.row(3);
|
Q.row(1) /= Q.row(3);
|
||||||
Q.row(2) /= Q.row(3);
|
Q.row(2) /= Q.row(3);
|
||||||
Q.row(3) /= Q.row(3);
|
Q.row(3) /= Q.row(3);
|
||||||
mask3 = (Q.row(2) < dist) & mask3;
|
mask3 = (Q.row(2) < dist) & mask3;
|
||||||
Q = P3 * Q;
|
Q = P3 * Q;
|
||||||
mask3 = (Q.row(2) > 0) & mask3;
|
mask3 = (Q.row(2) > 0) & mask3;
|
||||||
mask3 = (Q.row(2) < dist) & mask3;
|
mask3 = (Q.row(2) < dist) & mask3;
|
||||||
|
|
||||||
triangulatePoints(P0, P4, points1, points2, Q);
|
triangulatePoints(P0, P4, points1, points2, Q);
|
||||||
Mat mask4 = Q.row(2).mul(Q.row(3)) > 0;
|
Mat mask4 = Q.row(2).mul(Q.row(3)) > 0;
|
||||||
Q.row(0) /= Q.row(3);
|
Q.row(0) /= Q.row(3);
|
||||||
Q.row(1) /= Q.row(3);
|
Q.row(1) /= Q.row(3);
|
||||||
Q.row(2) /= Q.row(3);
|
Q.row(2) /= Q.row(3);
|
||||||
Q.row(3) /= Q.row(3);
|
Q.row(3) /= Q.row(3);
|
||||||
mask4 = (Q.row(2) < dist) & mask4;
|
mask4 = (Q.row(2) < dist) & mask4;
|
||||||
Q = P4 * Q;
|
Q = P4 * Q;
|
||||||
mask4 = (Q.row(2) > 0) & mask4;
|
mask4 = (Q.row(2) > 0) & mask4;
|
||||||
mask4 = (Q.row(2) < dist) & mask4;
|
mask4 = (Q.row(2) < dist) & mask4;
|
||||||
|
|
||||||
// If _mask is given, then use it to filter outliers.
|
// If _mask is given, then use it to filter outliers.
|
||||||
if (_mask.needed())
|
if (_mask.needed())
|
||||||
{
|
{
|
||||||
_mask.create(1, npoints, CV_8U, -1, true);
|
_mask.create(1, npoints, CV_8U, -1, true);
|
||||||
Mat mask = _mask.getMat();
|
Mat mask = _mask.getMat();
|
||||||
bitwise_and(mask, mask1, mask1);
|
bitwise_and(mask, mask1, mask1);
|
||||||
bitwise_and(mask, mask2, mask2);
|
bitwise_and(mask, mask2, mask2);
|
||||||
bitwise_and(mask, mask3, mask3);
|
bitwise_and(mask, mask3, mask3);
|
||||||
bitwise_and(mask, mask4, mask4);
|
bitwise_and(mask, mask4, mask4);
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_Assert(_R.needed() && _t.needed());
|
CV_Assert(_R.needed() && _t.needed());
|
||||||
_R.create(3, 3, R1.type());
|
_R.create(3, 3, R1.type());
|
||||||
_t.create(3, 1, t.type());
|
_t.create(3, 1, t.type());
|
||||||
|
|
||||||
int good1 = countNonZero(mask1);
|
int good1 = countNonZero(mask1);
|
||||||
int good2 = countNonZero(mask2);
|
int good2 = countNonZero(mask2);
|
||||||
int good3 = countNonZero(mask3);
|
int good3 = countNonZero(mask3);
|
||||||
int good4 = countNonZero(mask4);
|
int good4 = countNonZero(mask4);
|
||||||
if (good1 >= good2 && good1 >= good3 && good1 >= good4)
|
if (good1 >= good2 && good1 >= good3 && good1 >= good4)
|
||||||
{
|
{
|
||||||
R1.copyTo(_R.getMat());
|
R1.copyTo(_R.getMat());
|
||||||
t.copyTo(_t.getMat());
|
t.copyTo(_t.getMat());
|
||||||
if (_mask.needed()) mask1.copyTo(_mask.getMat());
|
if (_mask.needed()) mask1.copyTo(_mask.getMat());
|
||||||
return good1;
|
return good1;
|
||||||
}
|
}
|
||||||
else if (good2 >= good1 && good2 >= good3 && good2 >= good4)
|
else if (good2 >= good1 && good2 >= good3 && good2 >= good4)
|
||||||
{
|
{
|
||||||
R2.copyTo(_R.getMat());
|
R2.copyTo(_R.getMat());
|
||||||
t.copyTo(_t.getMat());
|
t.copyTo(_t.getMat());
|
||||||
if (_mask.needed()) mask2.copyTo(_mask.getMat());
|
if (_mask.needed()) mask2.copyTo(_mask.getMat());
|
||||||
return good2;
|
return good2;
|
||||||
}
|
}
|
||||||
else if (good3 >= good1 && good3 >= good2 && good3 >= good4)
|
else if (good3 >= good1 && good3 >= good2 && good3 >= good4)
|
||||||
{
|
{
|
||||||
t = -t;
|
t = -t;
|
||||||
R1.copyTo(_R.getMat());
|
R1.copyTo(_R.getMat());
|
||||||
t.copyTo(_t.getMat());
|
t.copyTo(_t.getMat());
|
||||||
if (_mask.needed()) mask3.copyTo(_mask.getMat());
|
if (_mask.needed()) mask3.copyTo(_mask.getMat());
|
||||||
return good3;
|
return good3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = -t;
|
t = -t;
|
||||||
R2.copyTo(_R.getMat());
|
R2.copyTo(_R.getMat());
|
||||||
t.copyTo(_t.getMat());
|
t.copyTo(_t.getMat());
|
||||||
if (_mask.needed()) mask4.copyTo(_mask.getMat());
|
if (_mask.needed()) mask4.copyTo(_mask.getMat());
|
||||||
return good4;
|
return good4;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cv::decomposeEssentialMat( InputArray _E, OutputArray _R1, OutputArray _R2, OutputArray _t )
|
void cv::decomposeEssentialMat( InputArray _E, OutputArray _R1, OutputArray _R2, OutputArray _t )
|
||||||
{
|
{
|
||||||
Mat E;
|
Mat E;
|
||||||
_E.getMat().copyTo(E);
|
_E.getMat().copyTo(E);
|
||||||
E = E.reshape(1, 3);
|
E = E.reshape(1, 3);
|
||||||
|
|
||||||
assert(E.cols == 3 && E.rows == 3);
|
assert(E.cols == 3 && E.rows == 3);
|
||||||
|
|
||||||
Mat D, U, Vt;
|
|
||||||
SVD::compute(E, D, U, Vt);
|
|
||||||
|
|
||||||
if (determinant(U) < 0) U = -U;
|
|
||||||
if (determinant(Vt) < 0) Vt = -Vt;
|
|
||||||
|
|
||||||
Mat W = (Mat_<double>(3, 3) << 0, 1, 0, -1, 0, 0, 0, 0, 1);
|
|
||||||
W.convertTo(W, E.type());
|
|
||||||
|
|
||||||
Mat R1, R2, t;
|
|
||||||
R1 = U * W * Vt;
|
|
||||||
R2 = U * W.t() * Vt;
|
|
||||||
t = U.col(2) * 1.0;
|
|
||||||
|
|
||||||
_R1.create(3, 3, E.type());
|
Mat D, U, Vt;
|
||||||
_R2.create(3, 3, E.type());
|
SVD::compute(E, D, U, Vt);
|
||||||
_t.create(3, 1, E.type());
|
|
||||||
R1.copyTo(_R1.getMat());
|
if (determinant(U) < 0) U = -U;
|
||||||
R2.copyTo(_R2.getMat());
|
if (determinant(Vt) < 0) Vt = -Vt;
|
||||||
t.copyTo(_t.getMat());
|
|
||||||
|
Mat W = (Mat_<double>(3, 3) << 0, 1, 0, -1, 0, 0, 0, 0, 1);
|
||||||
|
W.convertTo(W, E.type());
|
||||||
|
|
||||||
|
Mat R1, R2, t;
|
||||||
|
R1 = U * W * Vt;
|
||||||
|
R2 = U * W.t() * Vt;
|
||||||
|
t = U.col(2) * 1.0;
|
||||||
|
|
||||||
|
_R1.create(3, 3, E.type());
|
||||||
|
_R2.create(3, 3, E.type());
|
||||||
|
_t.create(3, 1, E.type());
|
||||||
|
R1.copyTo(_R1.getMat());
|
||||||
|
R2.copyTo(_R2.getMat());
|
||||||
|
t.copyTo(_t.getMat());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,150 +270,150 @@ CvEMEstimator::CvEMEstimator()
|
|||||||
|
|
||||||
int CvEMEstimator::runKernel( const CvMat* m1, const CvMat* m2, CvMat* model )
|
int CvEMEstimator::runKernel( const CvMat* m1, const CvMat* m2, CvMat* model )
|
||||||
{
|
{
|
||||||
return run5Point(m1, m2, model);
|
return run5Point(m1, m2, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notice to keep compatibility with opencv ransac, q1 and q2 have
|
// Notice to keep compatibility with opencv ransac, q1 and q2 have
|
||||||
// to be of 1 row x n col x 2 channel.
|
// to be of 1 row x n col x 2 channel.
|
||||||
int CvEMEstimator::run5Point( const CvMat* q1, const CvMat* q2, CvMat* ematrix )
|
int CvEMEstimator::run5Point( const CvMat* q1, const CvMat* q2, CvMat* ematrix )
|
||||||
{
|
{
|
||||||
Mat Q1 = Mat(q1).reshape(1, q1->cols);
|
Mat Q1 = Mat(q1).reshape(1, q1->cols);
|
||||||
Mat Q2 = Mat(q2).reshape(1, q2->cols);
|
Mat Q2 = Mat(q2).reshape(1, q2->cols);
|
||||||
|
|
||||||
int n = Q1.rows;
|
int n = Q1.rows;
|
||||||
Mat Q(n, 9, CV_64F);
|
Mat Q(n, 9, CV_64F);
|
||||||
Q.col(0) = Q1.col(0).mul( Q2.col(0) );
|
Q.col(0) = Q1.col(0).mul( Q2.col(0) );
|
||||||
Q.col(1) = Q1.col(1).mul( Q2.col(0) );
|
Q.col(1) = Q1.col(1).mul( Q2.col(0) );
|
||||||
Q.col(2) = Q2.col(0) * 1.0;
|
Q.col(2) = Q2.col(0) * 1.0;
|
||||||
Q.col(3) = Q1.col(0).mul( Q2.col(1) );
|
Q.col(3) = Q1.col(0).mul( Q2.col(1) );
|
||||||
Q.col(4) = Q1.col(1).mul( Q2.col(1) );
|
Q.col(4) = Q1.col(1).mul( Q2.col(1) );
|
||||||
Q.col(5) = Q2.col(1) * 1.0;
|
Q.col(5) = Q2.col(1) * 1.0;
|
||||||
Q.col(6) = Q1.col(0) * 1.0;
|
Q.col(6) = Q1.col(0) * 1.0;
|
||||||
Q.col(7) = Q1.col(1) * 1.0;
|
Q.col(7) = Q1.col(1) * 1.0;
|
||||||
Q.col(8) = 1.0;
|
Q.col(8) = 1.0;
|
||||||
|
|
||||||
Mat U, W, Vt;
|
Mat U, W, Vt;
|
||||||
SVD::compute(Q, W, U, Vt, SVD::MODIFY_A | SVD::FULL_UV);
|
SVD::compute(Q, W, U, Vt, SVD::MODIFY_A | SVD::FULL_UV);
|
||||||
|
|
||||||
Mat EE = Mat(Vt.t()).colRange(5, 9) * 1.0;
|
|
||||||
Mat AA(20, 10, CV_64F);
|
|
||||||
EE = EE.t();
|
|
||||||
calibrated_fivepoint_helper((double*)EE.data, (double*)AA.data);
|
|
||||||
AA = AA.t();
|
|
||||||
EE = EE.t();
|
|
||||||
|
|
||||||
Mat A(10, 20, CV_64F);
|
Mat EE = Mat(Vt.t()).colRange(5, 9) * 1.0;
|
||||||
int perm[20] = {0, 3, 1, 2, 4, 10, 6, 12, 5, 11, 7, 13, 16, 8, 14, 17, 9, 15, 18, 19};
|
Mat AA(20, 10, CV_64F);
|
||||||
|
EE = EE.t();
|
||||||
|
calibrated_fivepoint_helper((double*)EE.data, (double*)AA.data);
|
||||||
|
AA = AA.t();
|
||||||
|
EE = EE.t();
|
||||||
|
|
||||||
|
Mat A(10, 20, CV_64F);
|
||||||
|
int perm[20] = {0, 3, 1, 2, 4, 10, 6, 12, 5, 11, 7, 13, 16, 8, 14, 17, 9, 15, 18, 19};
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
A.col(i) = AA.col(perm[i]) * 1.0;
|
A.col(i) = AA.col(perm[i]) * 1.0;
|
||||||
|
|
||||||
|
|
||||||
A = A.colRange(0, 10).inv() * A.colRange(10, 20);
|
A = A.colRange(0, 10).inv() * A.colRange(10, 20);
|
||||||
|
|
||||||
double b[3 * 13];
|
double b[3 * 13];
|
||||||
Mat B(3, 13, CV_64F, b);
|
Mat B(3, 13, CV_64F, b);
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
Mat arow1 = A.row(i * 2 + 4) * 1.0;
|
Mat arow1 = A.row(i * 2 + 4) * 1.0;
|
||||||
Mat arow2 = A.row(i * 2 + 5) * 1.0;
|
Mat arow2 = A.row(i * 2 + 5) * 1.0;
|
||||||
Mat row1(1, 13, CV_64F, Scalar(0.0));
|
Mat row1(1, 13, CV_64F, Scalar(0.0));
|
||||||
Mat row2(1, 13, CV_64F, Scalar(0.0));
|
Mat row2(1, 13, CV_64F, Scalar(0.0));
|
||||||
|
|
||||||
row1.colRange(1, 4) = arow1.colRange(0, 3) * 1.0;
|
row1.colRange(1, 4) = arow1.colRange(0, 3) * 1.0;
|
||||||
row1.colRange(5, 8) = arow1.colRange(3, 6) * 1.0;
|
row1.colRange(5, 8) = arow1.colRange(3, 6) * 1.0;
|
||||||
row1.colRange(9, 13) = arow1.colRange(6, 10) * 1.0;
|
row1.colRange(9, 13) = arow1.colRange(6, 10) * 1.0;
|
||||||
|
|
||||||
row2.colRange(0, 3) = arow2.colRange(0, 3) * 1.0;
|
row2.colRange(0, 3) = arow2.colRange(0, 3) * 1.0;
|
||||||
row2.colRange(4, 7) = arow2.colRange(3, 6) * 1.0;
|
row2.colRange(4, 7) = arow2.colRange(3, 6) * 1.0;
|
||||||
row2.colRange(8, 12) = arow2.colRange(6, 10) * 1.0;
|
row2.colRange(8, 12) = arow2.colRange(6, 10) * 1.0;
|
||||||
|
|
||||||
B.row(i) = row1 - row2;
|
B.row(i) = row1 - row2;
|
||||||
}
|
}
|
||||||
|
|
||||||
double c[11];
|
double c[11];
|
||||||
Mat coeffs(1, 11, CV_64F, c);
|
Mat coeffs(1, 11, CV_64F, c);
|
||||||
c[10] = (b[0]*b[17]*b[34]+b[26]*b[4]*b[21]-b[26]*b[17]*b[8]-b[13]*b[4]*b[34]-b[0]*b[21]*b[30]+b[13]*b[30]*b[8]);
|
c[10] = (b[0]*b[17]*b[34]+b[26]*b[4]*b[21]-b[26]*b[17]*b[8]-b[13]*b[4]*b[34]-b[0]*b[21]*b[30]+b[13]*b[30]*b[8]);
|
||||||
c[9] = (b[26]*b[4]*b[22]+b[14]*b[30]*b[8]+b[13]*b[31]*b[8]+b[1]*b[17]*b[34]-b[13]*b[5]*b[34]+b[26]*b[5]*b[21]-b[0]*b[21]*b[31]-b[26]*b[17]*b[9]-b[1]*b[21]*b[30]+b[27]*b[4]*b[21]+b[0]*b[17]*b[35]-b[0]*b[22]*b[30]+b[13]*b[30]*b[9]+b[0]*b[18]*b[34]-b[27]*b[17]*b[8]-b[14]*b[4]*b[34]-b[13]*b[4]*b[35]-b[26]*b[18]*b[8]);
|
c[9] = (b[26]*b[4]*b[22]+b[14]*b[30]*b[8]+b[13]*b[31]*b[8]+b[1]*b[17]*b[34]-b[13]*b[5]*b[34]+b[26]*b[5]*b[21]-b[0]*b[21]*b[31]-b[26]*b[17]*b[9]-b[1]*b[21]*b[30]+b[27]*b[4]*b[21]+b[0]*b[17]*b[35]-b[0]*b[22]*b[30]+b[13]*b[30]*b[9]+b[0]*b[18]*b[34]-b[27]*b[17]*b[8]-b[14]*b[4]*b[34]-b[13]*b[4]*b[35]-b[26]*b[18]*b[8]);
|
||||||
c[8] = (b[14]*b[30]*b[9]+b[14]*b[31]*b[8]+b[13]*b[31]*b[9]-b[13]*b[4]*b[36]-b[13]*b[5]*b[35]+b[15]*b[30]*b[8]-b[13]*b[6]*b[34]+b[13]*b[30]*b[10]+b[13]*b[32]*b[8]-b[14]*b[4]*b[35]-b[14]*b[5]*b[34]+b[26]*b[4]*b[23]+b[26]*b[5]*b[22]+b[26]*b[6]*b[21]-b[26]*b[17]*b[10]-b[15]*b[4]*b[34]-b[26]*b[18]*b[9]-b[26]*b[19]*b[8]+b[27]*b[4]*b[22]+b[27]*b[5]*b[21]-b[27]*b[17]*b[9]-b[27]*b[18]*b[8]-b[1]*b[21]*b[31]-b[0]*b[23]*b[30]-b[0]*b[21]*b[32]+b[28]*b[4]*b[21]-b[28]*b[17]*b[8]+b[2]*b[17]*b[34]+b[0]*b[18]*b[35]-b[0]*b[22]*b[31]+b[0]*b[17]*b[36]+b[0]*b[19]*b[34]-b[1]*b[22]*b[30]+b[1]*b[18]*b[34]+b[1]*b[17]*b[35]-b[2]*b[21]*b[30]);
|
c[8] = (b[14]*b[30]*b[9]+b[14]*b[31]*b[8]+b[13]*b[31]*b[9]-b[13]*b[4]*b[36]-b[13]*b[5]*b[35]+b[15]*b[30]*b[8]-b[13]*b[6]*b[34]+b[13]*b[30]*b[10]+b[13]*b[32]*b[8]-b[14]*b[4]*b[35]-b[14]*b[5]*b[34]+b[26]*b[4]*b[23]+b[26]*b[5]*b[22]+b[26]*b[6]*b[21]-b[26]*b[17]*b[10]-b[15]*b[4]*b[34]-b[26]*b[18]*b[9]-b[26]*b[19]*b[8]+b[27]*b[4]*b[22]+b[27]*b[5]*b[21]-b[27]*b[17]*b[9]-b[27]*b[18]*b[8]-b[1]*b[21]*b[31]-b[0]*b[23]*b[30]-b[0]*b[21]*b[32]+b[28]*b[4]*b[21]-b[28]*b[17]*b[8]+b[2]*b[17]*b[34]+b[0]*b[18]*b[35]-b[0]*b[22]*b[31]+b[0]*b[17]*b[36]+b[0]*b[19]*b[34]-b[1]*b[22]*b[30]+b[1]*b[18]*b[34]+b[1]*b[17]*b[35]-b[2]*b[21]*b[30]);
|
||||||
c[7] = (b[14]*b[30]*b[10]+b[14]*b[32]*b[8]-b[3]*b[21]*b[30]+b[3]*b[17]*b[34]+b[13]*b[32]*b[9]+b[13]*b[33]*b[8]-b[13]*b[4]*b[37]-b[13]*b[5]*b[36]+b[15]*b[30]*b[9]+b[15]*b[31]*b[8]-b[16]*b[4]*b[34]-b[13]*b[6]*b[35]-b[13]*b[7]*b[34]+b[13]*b[30]*b[11]+b[13]*b[31]*b[10]+b[14]*b[31]*b[9]-b[14]*b[4]*b[36]-b[14]*b[5]*b[35]-b[14]*b[6]*b[34]+b[16]*b[30]*b[8]-b[26]*b[20]*b[8]+b[26]*b[4]*b[24]+b[26]*b[5]*b[23]+b[26]*b[6]*b[22]+b[26]*b[7]*b[21]-b[26]*b[17]*b[11]-b[15]*b[4]*b[35]-b[15]*b[5]*b[34]-b[26]*b[18]*b[10]-b[26]*b[19]*b[9]+b[27]*b[4]*b[23]+b[27]*b[5]*b[22]+b[27]*b[6]*b[21]-b[27]*b[17]*b[10]-b[27]*b[18]*b[9]-b[27]*b[19]*b[8]+b[0]*b[17]*b[37]-b[0]*b[23]*b[31]-b[0]*b[24]*b[30]-b[0]*b[21]*b[33]-b[29]*b[17]*b[8]+b[28]*b[4]*b[22]+b[28]*b[5]*b[21]-b[28]*b[17]*b[9]-b[28]*b[18]*b[8]+b[29]*b[4]*b[21]+b[1]*b[19]*b[34]-b[2]*b[21]*b[31]+b[0]*b[20]*b[34]+b[0]*b[19]*b[35]+b[0]*b[18]*b[36]-b[0]*b[22]*b[32]-b[1]*b[23]*b[30]-b[1]*b[21]*b[32]+b[1]*b[18]*b[35]-b[1]*b[22]*b[31]-b[2]*b[22]*b[30]+b[2]*b[17]*b[35]+b[1]*b[17]*b[36]+b[2]*b[18]*b[34]);
|
c[7] = (b[14]*b[30]*b[10]+b[14]*b[32]*b[8]-b[3]*b[21]*b[30]+b[3]*b[17]*b[34]+b[13]*b[32]*b[9]+b[13]*b[33]*b[8]-b[13]*b[4]*b[37]-b[13]*b[5]*b[36]+b[15]*b[30]*b[9]+b[15]*b[31]*b[8]-b[16]*b[4]*b[34]-b[13]*b[6]*b[35]-b[13]*b[7]*b[34]+b[13]*b[30]*b[11]+b[13]*b[31]*b[10]+b[14]*b[31]*b[9]-b[14]*b[4]*b[36]-b[14]*b[5]*b[35]-b[14]*b[6]*b[34]+b[16]*b[30]*b[8]-b[26]*b[20]*b[8]+b[26]*b[4]*b[24]+b[26]*b[5]*b[23]+b[26]*b[6]*b[22]+b[26]*b[7]*b[21]-b[26]*b[17]*b[11]-b[15]*b[4]*b[35]-b[15]*b[5]*b[34]-b[26]*b[18]*b[10]-b[26]*b[19]*b[9]+b[27]*b[4]*b[23]+b[27]*b[5]*b[22]+b[27]*b[6]*b[21]-b[27]*b[17]*b[10]-b[27]*b[18]*b[9]-b[27]*b[19]*b[8]+b[0]*b[17]*b[37]-b[0]*b[23]*b[31]-b[0]*b[24]*b[30]-b[0]*b[21]*b[33]-b[29]*b[17]*b[8]+b[28]*b[4]*b[22]+b[28]*b[5]*b[21]-b[28]*b[17]*b[9]-b[28]*b[18]*b[8]+b[29]*b[4]*b[21]+b[1]*b[19]*b[34]-b[2]*b[21]*b[31]+b[0]*b[20]*b[34]+b[0]*b[19]*b[35]+b[0]*b[18]*b[36]-b[0]*b[22]*b[32]-b[1]*b[23]*b[30]-b[1]*b[21]*b[32]+b[1]*b[18]*b[35]-b[1]*b[22]*b[31]-b[2]*b[22]*b[30]+b[2]*b[17]*b[35]+b[1]*b[17]*b[36]+b[2]*b[18]*b[34]);
|
||||||
c[6] = (-b[14]*b[6]*b[35]-b[14]*b[7]*b[34]-b[3]*b[22]*b[30]-b[3]*b[21]*b[31]+b[3]*b[17]*b[35]+b[3]*b[18]*b[34]+b[13]*b[32]*b[10]+b[13]*b[33]*b[9]-b[13]*b[4]*b[38]-b[13]*b[5]*b[37]-b[15]*b[6]*b[34]+b[15]*b[30]*b[10]+b[15]*b[32]*b[8]-b[16]*b[4]*b[35]-b[13]*b[6]*b[36]-b[13]*b[7]*b[35]+b[13]*b[31]*b[11]+b[13]*b[30]*b[12]+b[14]*b[32]*b[9]+b[14]*b[33]*b[8]-b[14]*b[4]*b[37]-b[14]*b[5]*b[36]+b[16]*b[30]*b[9]+b[16]*b[31]*b[8]-b[26]*b[20]*b[9]+b[26]*b[4]*b[25]+b[26]*b[5]*b[24]+b[26]*b[6]*b[23]+b[26]*b[7]*b[22]-b[26]*b[17]*b[12]+b[14]*b[30]*b[11]+b[14]*b[31]*b[10]+b[15]*b[31]*b[9]-b[15]*b[4]*b[36]-b[15]*b[5]*b[35]-b[26]*b[18]*b[11]-b[26]*b[19]*b[10]-b[27]*b[20]*b[8]+b[27]*b[4]*b[24]+b[27]*b[5]*b[23]+b[27]*b[6]*b[22]+b[27]*b[7]*b[21]-b[27]*b[17]*b[11]-b[27]*b[18]*b[10]-b[27]*b[19]*b[9]-b[16]*b[5]*b[34]-b[29]*b[17]*b[9]-b[29]*b[18]*b[8]+b[28]*b[4]*b[23]+b[28]*b[5]*b[22]+b[28]*b[6]*b[21]-b[28]*b[17]*b[10]-b[28]*b[18]*b[9]-b[28]*b[19]*b[8]+b[29]*b[4]*b[22]+b[29]*b[5]*b[21]-b[2]*b[23]*b[30]+b[2]*b[18]*b[35]-b[1]*b[22]*b[32]-b[2]*b[21]*b[32]+b[2]*b[19]*b[34]+b[0]*b[19]*b[36]-b[0]*b[22]*b[33]+b[0]*b[20]*b[35]-b[0]*b[23]*b[32]-b[0]*b[25]*b[30]+b[0]*b[17]*b[38]+b[0]*b[18]*b[37]-b[0]*b[24]*b[31]+b[1]*b[17]*b[37]-b[1]*b[23]*b[31]-b[1]*b[24]*b[30]-b[1]*b[21]*b[33]+b[1]*b[20]*b[34]+b[1]*b[19]*b[35]+b[1]*b[18]*b[36]+b[2]*b[17]*b[36]-b[2]*b[22]*b[31]);
|
c[6] = (-b[14]*b[6]*b[35]-b[14]*b[7]*b[34]-b[3]*b[22]*b[30]-b[3]*b[21]*b[31]+b[3]*b[17]*b[35]+b[3]*b[18]*b[34]+b[13]*b[32]*b[10]+b[13]*b[33]*b[9]-b[13]*b[4]*b[38]-b[13]*b[5]*b[37]-b[15]*b[6]*b[34]+b[15]*b[30]*b[10]+b[15]*b[32]*b[8]-b[16]*b[4]*b[35]-b[13]*b[6]*b[36]-b[13]*b[7]*b[35]+b[13]*b[31]*b[11]+b[13]*b[30]*b[12]+b[14]*b[32]*b[9]+b[14]*b[33]*b[8]-b[14]*b[4]*b[37]-b[14]*b[5]*b[36]+b[16]*b[30]*b[9]+b[16]*b[31]*b[8]-b[26]*b[20]*b[9]+b[26]*b[4]*b[25]+b[26]*b[5]*b[24]+b[26]*b[6]*b[23]+b[26]*b[7]*b[22]-b[26]*b[17]*b[12]+b[14]*b[30]*b[11]+b[14]*b[31]*b[10]+b[15]*b[31]*b[9]-b[15]*b[4]*b[36]-b[15]*b[5]*b[35]-b[26]*b[18]*b[11]-b[26]*b[19]*b[10]-b[27]*b[20]*b[8]+b[27]*b[4]*b[24]+b[27]*b[5]*b[23]+b[27]*b[6]*b[22]+b[27]*b[7]*b[21]-b[27]*b[17]*b[11]-b[27]*b[18]*b[10]-b[27]*b[19]*b[9]-b[16]*b[5]*b[34]-b[29]*b[17]*b[9]-b[29]*b[18]*b[8]+b[28]*b[4]*b[23]+b[28]*b[5]*b[22]+b[28]*b[6]*b[21]-b[28]*b[17]*b[10]-b[28]*b[18]*b[9]-b[28]*b[19]*b[8]+b[29]*b[4]*b[22]+b[29]*b[5]*b[21]-b[2]*b[23]*b[30]+b[2]*b[18]*b[35]-b[1]*b[22]*b[32]-b[2]*b[21]*b[32]+b[2]*b[19]*b[34]+b[0]*b[19]*b[36]-b[0]*b[22]*b[33]+b[0]*b[20]*b[35]-b[0]*b[23]*b[32]-b[0]*b[25]*b[30]+b[0]*b[17]*b[38]+b[0]*b[18]*b[37]-b[0]*b[24]*b[31]+b[1]*b[17]*b[37]-b[1]*b[23]*b[31]-b[1]*b[24]*b[30]-b[1]*b[21]*b[33]+b[1]*b[20]*b[34]+b[1]*b[19]*b[35]+b[1]*b[18]*b[36]+b[2]*b[17]*b[36]-b[2]*b[22]*b[31]);
|
||||||
c[5] = (-b[14]*b[6]*b[36]-b[14]*b[7]*b[35]+b[14]*b[31]*b[11]-b[3]*b[23]*b[30]-b[3]*b[21]*b[32]+b[3]*b[18]*b[35]-b[3]*b[22]*b[31]+b[3]*b[17]*b[36]+b[3]*b[19]*b[34]+b[13]*b[32]*b[11]+b[13]*b[33]*b[10]-b[13]*b[5]*b[38]-b[15]*b[6]*b[35]-b[15]*b[7]*b[34]+b[15]*b[30]*b[11]+b[15]*b[31]*b[10]+b[16]*b[31]*b[9]-b[13]*b[6]*b[37]-b[13]*b[7]*b[36]+b[13]*b[31]*b[12]+b[14]*b[32]*b[10]+b[14]*b[33]*b[9]-b[14]*b[4]*b[38]-b[14]*b[5]*b[37]-b[16]*b[6]*b[34]+b[16]*b[30]*b[10]+b[16]*b[32]*b[8]-b[26]*b[20]*b[10]+b[26]*b[5]*b[25]+b[26]*b[6]*b[24]+b[26]*b[7]*b[23]+b[14]*b[30]*b[12]+b[15]*b[32]*b[9]+b[15]*b[33]*b[8]-b[15]*b[4]*b[37]-b[15]*b[5]*b[36]+b[29]*b[5]*b[22]+b[29]*b[6]*b[21]-b[26]*b[18]*b[12]-b[26]*b[19]*b[11]-b[27]*b[20]*b[9]+b[27]*b[4]*b[25]+b[27]*b[5]*b[24]+b[27]*b[6]*b[23]+b[27]*b[7]*b[22]-b[27]*b[17]*b[12]-b[27]*b[18]*b[11]-b[27]*b[19]*b[10]-b[28]*b[20]*b[8]-b[16]*b[4]*b[36]-b[16]*b[5]*b[35]-b[29]*b[17]*b[10]-b[29]*b[18]*b[9]-b[29]*b[19]*b[8]+b[28]*b[4]*b[24]+b[28]*b[5]*b[23]+b[28]*b[6]*b[22]+b[28]*b[7]*b[21]-b[28]*b[17]*b[11]-b[28]*b[18]*b[10]-b[28]*b[19]*b[9]+b[29]*b[4]*b[23]-b[2]*b[22]*b[32]-b[2]*b[21]*b[33]-b[1]*b[24]*b[31]+b[0]*b[18]*b[38]-b[0]*b[24]*b[32]+b[0]*b[19]*b[37]+b[0]*b[20]*b[36]-b[0]*b[25]*b[31]-b[0]*b[23]*b[33]+b[1]*b[19]*b[36]-b[1]*b[22]*b[33]+b[1]*b[20]*b[35]+b[2]*b[19]*b[35]-b[2]*b[24]*b[30]-b[2]*b[23]*b[31]+b[2]*b[20]*b[34]+b[2]*b[17]*b[37]-b[1]*b[25]*b[30]+b[1]*b[18]*b[37]+b[1]*b[17]*b[38]-b[1]*b[23]*b[32]+b[2]*b[18]*b[36]);
|
c[5] = (-b[14]*b[6]*b[36]-b[14]*b[7]*b[35]+b[14]*b[31]*b[11]-b[3]*b[23]*b[30]-b[3]*b[21]*b[32]+b[3]*b[18]*b[35]-b[3]*b[22]*b[31]+b[3]*b[17]*b[36]+b[3]*b[19]*b[34]+b[13]*b[32]*b[11]+b[13]*b[33]*b[10]-b[13]*b[5]*b[38]-b[15]*b[6]*b[35]-b[15]*b[7]*b[34]+b[15]*b[30]*b[11]+b[15]*b[31]*b[10]+b[16]*b[31]*b[9]-b[13]*b[6]*b[37]-b[13]*b[7]*b[36]+b[13]*b[31]*b[12]+b[14]*b[32]*b[10]+b[14]*b[33]*b[9]-b[14]*b[4]*b[38]-b[14]*b[5]*b[37]-b[16]*b[6]*b[34]+b[16]*b[30]*b[10]+b[16]*b[32]*b[8]-b[26]*b[20]*b[10]+b[26]*b[5]*b[25]+b[26]*b[6]*b[24]+b[26]*b[7]*b[23]+b[14]*b[30]*b[12]+b[15]*b[32]*b[9]+b[15]*b[33]*b[8]-b[15]*b[4]*b[37]-b[15]*b[5]*b[36]+b[29]*b[5]*b[22]+b[29]*b[6]*b[21]-b[26]*b[18]*b[12]-b[26]*b[19]*b[11]-b[27]*b[20]*b[9]+b[27]*b[4]*b[25]+b[27]*b[5]*b[24]+b[27]*b[6]*b[23]+b[27]*b[7]*b[22]-b[27]*b[17]*b[12]-b[27]*b[18]*b[11]-b[27]*b[19]*b[10]-b[28]*b[20]*b[8]-b[16]*b[4]*b[36]-b[16]*b[5]*b[35]-b[29]*b[17]*b[10]-b[29]*b[18]*b[9]-b[29]*b[19]*b[8]+b[28]*b[4]*b[24]+b[28]*b[5]*b[23]+b[28]*b[6]*b[22]+b[28]*b[7]*b[21]-b[28]*b[17]*b[11]-b[28]*b[18]*b[10]-b[28]*b[19]*b[9]+b[29]*b[4]*b[23]-b[2]*b[22]*b[32]-b[2]*b[21]*b[33]-b[1]*b[24]*b[31]+b[0]*b[18]*b[38]-b[0]*b[24]*b[32]+b[0]*b[19]*b[37]+b[0]*b[20]*b[36]-b[0]*b[25]*b[31]-b[0]*b[23]*b[33]+b[1]*b[19]*b[36]-b[1]*b[22]*b[33]+b[1]*b[20]*b[35]+b[2]*b[19]*b[35]-b[2]*b[24]*b[30]-b[2]*b[23]*b[31]+b[2]*b[20]*b[34]+b[2]*b[17]*b[37]-b[1]*b[25]*b[30]+b[1]*b[18]*b[37]+b[1]*b[17]*b[38]-b[1]*b[23]*b[32]+b[2]*b[18]*b[36]);
|
||||||
c[4] = (-b[14]*b[6]*b[37]-b[14]*b[7]*b[36]+b[14]*b[31]*b[12]+b[3]*b[17]*b[37]-b[3]*b[23]*b[31]-b[3]*b[24]*b[30]-b[3]*b[21]*b[33]+b[3]*b[20]*b[34]+b[3]*b[19]*b[35]+b[3]*b[18]*b[36]-b[3]*b[22]*b[32]+b[13]*b[32]*b[12]+b[13]*b[33]*b[11]-b[15]*b[6]*b[36]-b[15]*b[7]*b[35]+b[15]*b[31]*b[11]+b[15]*b[30]*b[12]+b[16]*b[32]*b[9]+b[16]*b[33]*b[8]-b[13]*b[6]*b[38]-b[13]*b[7]*b[37]+b[14]*b[32]*b[11]+b[14]*b[33]*b[10]-b[14]*b[5]*b[38]-b[16]*b[6]*b[35]-b[16]*b[7]*b[34]+b[16]*b[30]*b[11]+b[16]*b[31]*b[10]-b[26]*b[19]*b[12]-b[26]*b[20]*b[11]+b[26]*b[6]*b[25]+b[26]*b[7]*b[24]+b[15]*b[32]*b[10]+b[15]*b[33]*b[9]-b[15]*b[4]*b[38]-b[15]*b[5]*b[37]+b[29]*b[5]*b[23]+b[29]*b[6]*b[22]+b[29]*b[7]*b[21]-b[27]*b[20]*b[10]+b[27]*b[5]*b[25]+b[27]*b[6]*b[24]+b[27]*b[7]*b[23]-b[27]*b[18]*b[12]-b[27]*b[19]*b[11]-b[28]*b[20]*b[9]-b[16]*b[4]*b[37]-b[16]*b[5]*b[36]+b[0]*b[19]*b[38]-b[0]*b[24]*b[33]+b[0]*b[20]*b[37]-b[29]*b[17]*b[11]-b[29]*b[18]*b[10]-b[29]*b[19]*b[9]+b[28]*b[4]*b[25]+b[28]*b[5]*b[24]+b[28]*b[6]*b[23]+b[28]*b[7]*b[22]-b[28]*b[17]*b[12]-b[28]*b[18]*b[11]-b[28]*b[19]*b[10]-b[29]*b[20]*b[8]+b[29]*b[4]*b[24]+b[2]*b[18]*b[37]-b[0]*b[25]*b[32]+b[1]*b[18]*b[38]-b[1]*b[24]*b[32]+b[1]*b[19]*b[37]+b[1]*b[20]*b[36]-b[1]*b[25]*b[31]+b[2]*b[17]*b[38]+b[2]*b[19]*b[36]-b[2]*b[24]*b[31]-b[2]*b[22]*b[33]-b[2]*b[23]*b[32]+b[2]*b[20]*b[35]-b[1]*b[23]*b[33]-b[2]*b[25]*b[30]);
|
c[4] = (-b[14]*b[6]*b[37]-b[14]*b[7]*b[36]+b[14]*b[31]*b[12]+b[3]*b[17]*b[37]-b[3]*b[23]*b[31]-b[3]*b[24]*b[30]-b[3]*b[21]*b[33]+b[3]*b[20]*b[34]+b[3]*b[19]*b[35]+b[3]*b[18]*b[36]-b[3]*b[22]*b[32]+b[13]*b[32]*b[12]+b[13]*b[33]*b[11]-b[15]*b[6]*b[36]-b[15]*b[7]*b[35]+b[15]*b[31]*b[11]+b[15]*b[30]*b[12]+b[16]*b[32]*b[9]+b[16]*b[33]*b[8]-b[13]*b[6]*b[38]-b[13]*b[7]*b[37]+b[14]*b[32]*b[11]+b[14]*b[33]*b[10]-b[14]*b[5]*b[38]-b[16]*b[6]*b[35]-b[16]*b[7]*b[34]+b[16]*b[30]*b[11]+b[16]*b[31]*b[10]-b[26]*b[19]*b[12]-b[26]*b[20]*b[11]+b[26]*b[6]*b[25]+b[26]*b[7]*b[24]+b[15]*b[32]*b[10]+b[15]*b[33]*b[9]-b[15]*b[4]*b[38]-b[15]*b[5]*b[37]+b[29]*b[5]*b[23]+b[29]*b[6]*b[22]+b[29]*b[7]*b[21]-b[27]*b[20]*b[10]+b[27]*b[5]*b[25]+b[27]*b[6]*b[24]+b[27]*b[7]*b[23]-b[27]*b[18]*b[12]-b[27]*b[19]*b[11]-b[28]*b[20]*b[9]-b[16]*b[4]*b[37]-b[16]*b[5]*b[36]+b[0]*b[19]*b[38]-b[0]*b[24]*b[33]+b[0]*b[20]*b[37]-b[29]*b[17]*b[11]-b[29]*b[18]*b[10]-b[29]*b[19]*b[9]+b[28]*b[4]*b[25]+b[28]*b[5]*b[24]+b[28]*b[6]*b[23]+b[28]*b[7]*b[22]-b[28]*b[17]*b[12]-b[28]*b[18]*b[11]-b[28]*b[19]*b[10]-b[29]*b[20]*b[8]+b[29]*b[4]*b[24]+b[2]*b[18]*b[37]-b[0]*b[25]*b[32]+b[1]*b[18]*b[38]-b[1]*b[24]*b[32]+b[1]*b[19]*b[37]+b[1]*b[20]*b[36]-b[1]*b[25]*b[31]+b[2]*b[17]*b[38]+b[2]*b[19]*b[36]-b[2]*b[24]*b[31]-b[2]*b[22]*b[33]-b[2]*b[23]*b[32]+b[2]*b[20]*b[35]-b[1]*b[23]*b[33]-b[2]*b[25]*b[30]);
|
||||||
c[3] = (-b[14]*b[6]*b[38]-b[14]*b[7]*b[37]+b[3]*b[19]*b[36]-b[3]*b[22]*b[33]+b[3]*b[20]*b[35]-b[3]*b[23]*b[32]-b[3]*b[25]*b[30]+b[3]*b[17]*b[38]+b[3]*b[18]*b[37]-b[3]*b[24]*b[31]-b[15]*b[6]*b[37]-b[15]*b[7]*b[36]+b[15]*b[31]*b[12]+b[16]*b[32]*b[10]+b[16]*b[33]*b[9]+b[13]*b[33]*b[12]-b[13]*b[7]*b[38]+b[14]*b[32]*b[12]+b[14]*b[33]*b[11]-b[16]*b[6]*b[36]-b[16]*b[7]*b[35]+b[16]*b[31]*b[11]+b[16]*b[30]*b[12]+b[15]*b[32]*b[11]+b[15]*b[33]*b[10]-b[15]*b[5]*b[38]+b[29]*b[5]*b[24]+b[29]*b[6]*b[23]-b[26]*b[20]*b[12]+b[26]*b[7]*b[25]-b[27]*b[19]*b[12]-b[27]*b[20]*b[11]+b[27]*b[6]*b[25]+b[27]*b[7]*b[24]-b[28]*b[20]*b[10]-b[16]*b[4]*b[38]-b[16]*b[5]*b[37]+b[29]*b[7]*b[22]-b[29]*b[17]*b[12]-b[29]*b[18]*b[11]-b[29]*b[19]*b[10]+b[28]*b[5]*b[25]+b[28]*b[6]*b[24]+b[28]*b[7]*b[23]-b[28]*b[18]*b[12]-b[28]*b[19]*b[11]-b[29]*b[20]*b[9]+b[29]*b[4]*b[25]-b[2]*b[24]*b[32]+b[0]*b[20]*b[38]-b[0]*b[25]*b[33]+b[1]*b[19]*b[38]-b[1]*b[24]*b[33]+b[1]*b[20]*b[37]-b[2]*b[25]*b[31]+b[2]*b[20]*b[36]-b[1]*b[25]*b[32]+b[2]*b[19]*b[37]+b[2]*b[18]*b[38]-b[2]*b[23]*b[33]);
|
c[3] = (-b[14]*b[6]*b[38]-b[14]*b[7]*b[37]+b[3]*b[19]*b[36]-b[3]*b[22]*b[33]+b[3]*b[20]*b[35]-b[3]*b[23]*b[32]-b[3]*b[25]*b[30]+b[3]*b[17]*b[38]+b[3]*b[18]*b[37]-b[3]*b[24]*b[31]-b[15]*b[6]*b[37]-b[15]*b[7]*b[36]+b[15]*b[31]*b[12]+b[16]*b[32]*b[10]+b[16]*b[33]*b[9]+b[13]*b[33]*b[12]-b[13]*b[7]*b[38]+b[14]*b[32]*b[12]+b[14]*b[33]*b[11]-b[16]*b[6]*b[36]-b[16]*b[7]*b[35]+b[16]*b[31]*b[11]+b[16]*b[30]*b[12]+b[15]*b[32]*b[11]+b[15]*b[33]*b[10]-b[15]*b[5]*b[38]+b[29]*b[5]*b[24]+b[29]*b[6]*b[23]-b[26]*b[20]*b[12]+b[26]*b[7]*b[25]-b[27]*b[19]*b[12]-b[27]*b[20]*b[11]+b[27]*b[6]*b[25]+b[27]*b[7]*b[24]-b[28]*b[20]*b[10]-b[16]*b[4]*b[38]-b[16]*b[5]*b[37]+b[29]*b[7]*b[22]-b[29]*b[17]*b[12]-b[29]*b[18]*b[11]-b[29]*b[19]*b[10]+b[28]*b[5]*b[25]+b[28]*b[6]*b[24]+b[28]*b[7]*b[23]-b[28]*b[18]*b[12]-b[28]*b[19]*b[11]-b[29]*b[20]*b[9]+b[29]*b[4]*b[25]-b[2]*b[24]*b[32]+b[0]*b[20]*b[38]-b[0]*b[25]*b[33]+b[1]*b[19]*b[38]-b[1]*b[24]*b[33]+b[1]*b[20]*b[37]-b[2]*b[25]*b[31]+b[2]*b[20]*b[36]-b[1]*b[25]*b[32]+b[2]*b[19]*b[37]+b[2]*b[18]*b[38]-b[2]*b[23]*b[33]);
|
||||||
c[2] = (b[3]*b[18]*b[38]-b[3]*b[24]*b[32]+b[3]*b[19]*b[37]+b[3]*b[20]*b[36]-b[3]*b[25]*b[31]-b[3]*b[23]*b[33]-b[15]*b[6]*b[38]-b[15]*b[7]*b[37]+b[16]*b[32]*b[11]+b[16]*b[33]*b[10]-b[16]*b[5]*b[38]-b[16]*b[6]*b[37]-b[16]*b[7]*b[36]+b[16]*b[31]*b[12]+b[14]*b[33]*b[12]-b[14]*b[7]*b[38]+b[15]*b[32]*b[12]+b[15]*b[33]*b[11]+b[29]*b[5]*b[25]+b[29]*b[6]*b[24]-b[27]*b[20]*b[12]+b[27]*b[7]*b[25]-b[28]*b[19]*b[12]-b[28]*b[20]*b[11]+b[29]*b[7]*b[23]-b[29]*b[18]*b[12]-b[29]*b[19]*b[11]+b[28]*b[6]*b[25]+b[28]*b[7]*b[24]-b[29]*b[20]*b[10]+b[2]*b[19]*b[38]-b[1]*b[25]*b[33]+b[2]*b[20]*b[37]-b[2]*b[24]*b[33]-b[2]*b[25]*b[32]+b[1]*b[20]*b[38]);
|
c[2] = (b[3]*b[18]*b[38]-b[3]*b[24]*b[32]+b[3]*b[19]*b[37]+b[3]*b[20]*b[36]-b[3]*b[25]*b[31]-b[3]*b[23]*b[33]-b[15]*b[6]*b[38]-b[15]*b[7]*b[37]+b[16]*b[32]*b[11]+b[16]*b[33]*b[10]-b[16]*b[5]*b[38]-b[16]*b[6]*b[37]-b[16]*b[7]*b[36]+b[16]*b[31]*b[12]+b[14]*b[33]*b[12]-b[14]*b[7]*b[38]+b[15]*b[32]*b[12]+b[15]*b[33]*b[11]+b[29]*b[5]*b[25]+b[29]*b[6]*b[24]-b[27]*b[20]*b[12]+b[27]*b[7]*b[25]-b[28]*b[19]*b[12]-b[28]*b[20]*b[11]+b[29]*b[7]*b[23]-b[29]*b[18]*b[12]-b[29]*b[19]*b[11]+b[28]*b[6]*b[25]+b[28]*b[7]*b[24]-b[29]*b[20]*b[10]+b[2]*b[19]*b[38]-b[1]*b[25]*b[33]+b[2]*b[20]*b[37]-b[2]*b[24]*b[33]-b[2]*b[25]*b[32]+b[1]*b[20]*b[38]);
|
||||||
c[1] = (b[29]*b[7]*b[24]-b[29]*b[20]*b[11]+b[2]*b[20]*b[38]-b[2]*b[25]*b[33]-b[28]*b[20]*b[12]+b[28]*b[7]*b[25]-b[29]*b[19]*b[12]-b[3]*b[24]*b[33]+b[15]*b[33]*b[12]+b[3]*b[19]*b[38]-b[16]*b[6]*b[38]+b[3]*b[20]*b[37]+b[16]*b[32]*b[12]+b[29]*b[6]*b[25]-b[16]*b[7]*b[37]-b[3]*b[25]*b[32]-b[15]*b[7]*b[38]+b[16]*b[33]*b[11]);
|
c[1] = (b[29]*b[7]*b[24]-b[29]*b[20]*b[11]+b[2]*b[20]*b[38]-b[2]*b[25]*b[33]-b[28]*b[20]*b[12]+b[28]*b[7]*b[25]-b[29]*b[19]*b[12]-b[3]*b[24]*b[33]+b[15]*b[33]*b[12]+b[3]*b[19]*b[38]-b[16]*b[6]*b[38]+b[3]*b[20]*b[37]+b[16]*b[32]*b[12]+b[29]*b[6]*b[25]-b[16]*b[7]*b[37]-b[3]*b[25]*b[32]-b[15]*b[7]*b[38]+b[16]*b[33]*b[11]);
|
||||||
c[0] = -b[29]*b[20]*b[12]+b[29]*b[7]*b[25]+b[16]*b[33]*b[12]-b[16]*b[7]*b[38]+b[3]*b[20]*b[38]-b[3]*b[25]*b[33];
|
c[0] = -b[29]*b[20]*b[12]+b[29]*b[7]*b[25]+b[16]*b[33]*b[12]-b[16]*b[7]*b[38]+b[3]*b[20]*b[38]-b[3]*b[25]*b[33];
|
||||||
|
|
||||||
std::vector<std::complex<double> > roots;
|
|
||||||
solvePoly(coeffs, roots);
|
|
||||||
|
|
||||||
std::vector<double> xs, ys, zs;
|
std::vector<std::complex<double> > roots;
|
||||||
int count = 0;
|
solvePoly(coeffs, roots);
|
||||||
double * e = ematrix->data.db;
|
|
||||||
|
std::vector<double> xs, ys, zs;
|
||||||
|
int count = 0;
|
||||||
|
double * e = ematrix->data.db;
|
||||||
for (size_t i = 0; i < roots.size(); i++)
|
for (size_t i = 0; i < roots.size(); i++)
|
||||||
{
|
{
|
||||||
if (fabs(roots[i].imag()) > 1e-10) continue;
|
if (fabs(roots[i].imag()) > 1e-10) continue;
|
||||||
double z1 = roots[i].real();
|
double z1 = roots[i].real();
|
||||||
double z2 = z1 * z1;
|
double z2 = z1 * z1;
|
||||||
double z3 = z2 * z1;
|
double z3 = z2 * z1;
|
||||||
double z4 = z3 * z1;
|
double z4 = z3 * z1;
|
||||||
|
|
||||||
double bz[3][3];
|
double bz[3][3];
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
const double * br = b + j * 13;
|
const double * br = b + j * 13;
|
||||||
bz[j][0] = br[0] * z3 + br[1] * z2 + br[2] * z1 + br[3];
|
bz[j][0] = br[0] * z3 + br[1] * z2 + br[2] * z1 + br[3];
|
||||||
bz[j][1] = br[4] * z3 + br[5] * z2 + br[6] * z1 + br[7];
|
bz[j][1] = br[4] * z3 + br[5] * z2 + br[6] * z1 + br[7];
|
||||||
bz[j][2] = br[8] * z4 + br[9] * z3 + br[10] * z2 + br[11] * z1 + br[12];
|
bz[j][2] = br[8] * z4 + br[9] * z3 + br[10] * z2 + br[11] * z1 + br[12];
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat Bz(3, 3, CV_64F, bz);
|
Mat Bz(3, 3, CV_64F, bz);
|
||||||
cv::Mat xy1;
|
cv::Mat xy1;
|
||||||
SVD::solveZ(Bz, xy1);
|
SVD::solveZ(Bz, xy1);
|
||||||
|
|
||||||
if (fabs(xy1.at<double>(2)) < 1e-10) continue;
|
if (fabs(xy1.at<double>(2)) < 1e-10) continue;
|
||||||
xs.push_back(xy1.at<double>(0) / xy1.at<double>(2));
|
xs.push_back(xy1.at<double>(0) / xy1.at<double>(2));
|
||||||
ys.push_back(xy1.at<double>(1) / xy1.at<double>(2));
|
ys.push_back(xy1.at<double>(1) / xy1.at<double>(2));
|
||||||
zs.push_back(z1);
|
zs.push_back(z1);
|
||||||
|
|
||||||
cv::Mat Evec = EE.col(0) * xs.back() + EE.col(1) * ys.back() + EE.col(2) * zs.back() + EE.col(3);
|
cv::Mat Evec = EE.col(0) * xs.back() + EE.col(1) * ys.back() + EE.col(2) * zs.back() + EE.col(3);
|
||||||
Evec /= norm(Evec);
|
Evec /= norm(Evec);
|
||||||
|
|
||||||
memcpy(e + count * 9, Evec.data, 9 * sizeof(double));
|
memcpy(e + count * 9, Evec.data, 9 * sizeof(double));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as the runKernel (run5Point), m1 and m2 should be
|
// Same as the runKernel (run5Point), m1 and m2 should be
|
||||||
// 1 row x n col x 2 channels.
|
// 1 row x n col x 2 channels.
|
||||||
// And also, error has to be of CV_32FC1.
|
// And also, error has to be of CV_32FC1.
|
||||||
void CvEMEstimator::computeReprojError( const CvMat* m1, const CvMat* m2,
|
void CvEMEstimator::computeReprojError( const CvMat* m1, const CvMat* m2,
|
||||||
const CvMat* model, CvMat* error )
|
const CvMat* model, CvMat* error )
|
||||||
{
|
{
|
||||||
Mat X1(m1), X2(m2);
|
Mat X1(m1), X2(m2);
|
||||||
int n = X1.cols;
|
int n = X1.cols;
|
||||||
X1 = X1.reshape(1, n);
|
X1 = X1.reshape(1, n);
|
||||||
X2 = X2.reshape(1, n);
|
X2 = X2.reshape(1, n);
|
||||||
|
|
||||||
X1.convertTo(X1, CV_64F);
|
X1.convertTo(X1, CV_64F);
|
||||||
X2.convertTo(X2, CV_64F);
|
X2.convertTo(X2, CV_64F);
|
||||||
|
|
||||||
Mat E(model);
|
Mat E(model);
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
Mat x1 = (Mat_<double>(3, 1) << X1.at<double>(i, 0), X1.at<double>(i, 1), 1.0);
|
Mat x1 = (Mat_<double>(3, 1) << X1.at<double>(i, 0), X1.at<double>(i, 1), 1.0);
|
||||||
Mat x2 = (Mat_<double>(3, 1) << X2.at<double>(i, 0), X2.at<double>(i, 1), 1.0);
|
Mat x2 = (Mat_<double>(3, 1) << X2.at<double>(i, 0), X2.at<double>(i, 1), 1.0);
|
||||||
double x2tEx1 = x2.dot(E * x1);
|
double x2tEx1 = x2.dot(E * x1);
|
||||||
Mat Ex1 = E * x1;
|
Mat Ex1 = E * x1;
|
||||||
Mat Etx2 = E * x2;
|
Mat Etx2 = E * x2;
|
||||||
double a = Ex1.at<double>(0) * Ex1.at<double>(0);
|
double a = Ex1.at<double>(0) * Ex1.at<double>(0);
|
||||||
double b = Ex1.at<double>(1) * Ex1.at<double>(1);
|
double b = Ex1.at<double>(1) * Ex1.at<double>(1);
|
||||||
double c = Etx2.at<double>(0) * Etx2.at<double>(0);
|
double c = Etx2.at<double>(0) * Etx2.at<double>(0);
|
||||||
double d = Etx2.at<double>(0) * Etx2.at<double>(0);
|
double d = Etx2.at<double>(0) * Etx2.at<double>(0);
|
||||||
|
|
||||||
error->data.fl[i] = (float)(x2tEx1 * x2tEx1 / (a + b + c + d));
|
error->data.fl[i] = (float)(x2tEx1 * x2tEx1 / (a + b + c + d));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -434,7 +433,7 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A )
|
|||||||
double e003,e013,e023,e033,e043,e053,e063,e073,e083;
|
double e003,e013,e023,e033,e043,e053,e063,e073,e083;
|
||||||
double e103,e113,e123,e133,e143,e153,e163,e173,e183;
|
double e103,e113,e123,e133,e143,e153,e163,e173,e183;
|
||||||
double e203,e213,e223,e233,e243,e253,e263,e273,e283;
|
double e203,e213,e223,e233,e243,e253,e263,e273,e283;
|
||||||
double e303,e313,e323,e333,e343,e353,e363,e373,e383;
|
double e303,e313,e323,e333,e343,e353,e363,e373,e383;
|
||||||
e00 = EE[0*9 + 0 ];
|
e00 = EE[0*9 + 0 ];
|
||||||
e10 = EE[1*9 + 0 ];
|
e10 = EE[1*9 + 0 ];
|
||||||
e20 = EE[2*9 + 0 ];
|
e20 = EE[2*9 + 0 ];
|
||||||
@ -471,8 +470,8 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A )
|
|||||||
e18 = EE[1*9 + 8 ];
|
e18 = EE[1*9 + 8 ];
|
||||||
e28 = EE[2*9 + 8 ];
|
e28 = EE[2*9 + 8 ];
|
||||||
e38 = EE[3*9 + 8 ];
|
e38 = EE[3*9 + 8 ];
|
||||||
|
|
||||||
|
|
||||||
e002 =e00*e00;
|
e002 =e00*e00;
|
||||||
e102 =e10*e10;
|
e102 =e10*e10;
|
||||||
e202 =e20*e20;
|
e202 =e20*e20;
|
||||||
@ -509,7 +508,7 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A )
|
|||||||
e182 =e18*e18;
|
e182 =e18*e18;
|
||||||
e282 =e28*e28;
|
e282 =e28*e28;
|
||||||
e382 =e38*e38;
|
e382 =e38*e38;
|
||||||
|
|
||||||
e003 =e00*e00*e00;
|
e003 =e00*e00*e00;
|
||||||
e103 =e10*e10*e10;
|
e103 =e10*e10*e10;
|
||||||
e203 =e20*e20*e20;
|
e203 =e20*e20*e20;
|
||||||
@ -546,8 +545,8 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A )
|
|||||||
e183 =e18*e18*e18;
|
e183 =e18*e18*e18;
|
||||||
e283 =e28*e28*e28;
|
e283 =e28*e28*e28;
|
||||||
e383 =e38*e38*e38;
|
e383 =e38*e38*e38;
|
||||||
|
|
||||||
|
|
||||||
A[0 + 10*0]=0.5*e003+0.5*e00*e012+0.5*e00*e022+0.5*e00*e032+e03*e01*e04+e03*e02*e05+0.5*e00*e062+e06*e01*e07+e06*e02*e08-0.5*e00*e042-0.5*e00*e052-0.5*e00*e072-0.5*e00*e082;
|
A[0 + 10*0]=0.5*e003+0.5*e00*e012+0.5*e00*e022+0.5*e00*e032+e03*e01*e04+e03*e02*e05+0.5*e00*e062+e06*e01*e07+e06*e02*e08-0.5*e00*e042-0.5*e00*e052-0.5*e00*e072-0.5*e00*e082;
|
||||||
A[0 + 10*1]=e00*e11*e01+e00*e12*e02+e03*e00*e13+e03*e11*e04+e03*e01*e14+e03*e12*e05+e03*e02*e15+e13*e01*e04+e13*e02*e05+e06*e00*e16+1.5*e10*e002+0.5*e10*e012+0.5*e10*e022+0.5*e10*e062-0.5*e10*e042-0.5*e10*e052-0.5*e10*e072+0.5*e10*e032+e06*e11*e07+e06*e01*e17+e06*e12*e08+e06*e02*e18+e16*e01*e07+e16*e02*e08-e00*e14*e04-e00*e17*e07-e00*e15*e05-e00*e18*e08-0.5*e10*e082;
|
A[0 + 10*1]=e00*e11*e01+e00*e12*e02+e03*e00*e13+e03*e11*e04+e03*e01*e14+e03*e12*e05+e03*e02*e15+e13*e01*e04+e13*e02*e05+e06*e00*e16+1.5*e10*e002+0.5*e10*e012+0.5*e10*e022+0.5*e10*e062-0.5*e10*e042-0.5*e10*e052-0.5*e10*e072+0.5*e10*e032+e06*e11*e07+e06*e01*e17+e06*e12*e08+e06*e02*e18+e16*e01*e07+e16*e02*e08-e00*e14*e04-e00*e17*e07-e00*e15*e05-e00*e18*e08-0.5*e10*e082;
|
||||||
A[0 + 10*2]=e16*e02*e18+e03*e12*e15+e10*e11*e01+e10*e12*e02+e03*e10*e13+e03*e11*e14+e13*e11*e04+e13*e01*e14+e13*e12*e05+e13*e02*e15+e06*e10*e16+e06*e12*e18+e06*e11*e17+e16*e11*e07+e16*e01*e17+e16*e12*e08-e10*e14*e04-e10*e17*e07-e10*e15*e05-e10*e18*e08+1.5*e00*e102+0.5*e00*e122+0.5*e00*e112+0.5*e00*e132+0.5*e00*e162-0.5*e00*e152-0.5*e00*e172-0.5*e00*e182-0.5*e00*e142;
|
A[0 + 10*2]=e16*e02*e18+e03*e12*e15+e10*e11*e01+e10*e12*e02+e03*e10*e13+e03*e11*e14+e13*e11*e04+e13*e01*e14+e13*e12*e05+e13*e02*e15+e06*e10*e16+e06*e12*e18+e06*e11*e17+e16*e11*e07+e16*e01*e17+e16*e12*e08-e10*e14*e04-e10*e17*e07-e10*e15*e05-e10*e18*e08+1.5*e00*e102+0.5*e00*e122+0.5*e00*e112+0.5*e00*e132+0.5*e00*e162-0.5*e00*e152-0.5*e00*e172-0.5*e00*e182-0.5*e00*e142;
|
||||||
|
@ -45,9 +45,6 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
CvModelEstimator2::CvModelEstimator2(int _modelPoints, CvSize _modelSize, int _maxBasicSolutions)
|
CvModelEstimator2::CvModelEstimator2(int _modelPoints, CvSize _modelSize, int _maxBasicSolutions)
|
||||||
{
|
{
|
||||||
modelPoints = _modelPoints;
|
modelPoints = _modelPoints;
|
||||||
@ -272,7 +269,7 @@ bool CvModelEstimator2::runLMeDS( const CvMat* m1, const CvMat* m2, CvMat* model
|
|||||||
|
|
||||||
if( minMedian < DBL_MAX )
|
if( minMedian < DBL_MAX )
|
||||||
{
|
{
|
||||||
sigma = 2.5*1.4826*(1 + 5./(count - modelPoints))*sqrt(minMedian);
|
sigma = 2.5*1.4826*(1 + 5./(count - modelPoints))*std::sqrt(minMedian);
|
||||||
sigma = MAX( sigma, 0.001 );
|
sigma = MAX( sigma, 0.001 );
|
||||||
|
|
||||||
count = findInliers( m1, m2, model, err, mask, sigma );
|
count = findInliers( m1, m2, model, err, mask, sigma );
|
||||||
@ -433,7 +430,7 @@ void cv::Affine3DEstimator::computeReprojError( const CvMat* m1, const CvMat* m2
|
|||||||
double b = F[4]*f.x + F[5]*f.y + F[ 6]*f.z + F[ 7] - t.y;
|
double b = F[4]*f.x + F[5]*f.y + F[ 6]*f.z + F[ 7] - t.y;
|
||||||
double c = F[8]*f.x + F[9]*f.y + F[10]*f.z + F[11] - t.z;
|
double c = F[8]*f.x + F[9]*f.y + F[10]*f.z + F[11] - t.z;
|
||||||
|
|
||||||
err[i] = (float)sqrt(a*a + b*b + c*c);
|
err[i] = (float)std::sqrt(a*a + b*b + c*c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +490,7 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to,
|
|||||||
CvMat m1 = dFrom;
|
CvMat m1 = dFrom;
|
||||||
CvMat m2 = dTo;
|
CvMat m2 = dTo;
|
||||||
|
|
||||||
const double epsilon = numeric_limits<double>::epsilon();
|
const double epsilon = std::numeric_limits<double>::epsilon();
|
||||||
param1 = param1 <= 0 ? 3 : param1;
|
param1 = param1 <= 0 ? 3 : param1;
|
||||||
param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2;
|
param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2;
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#include "polynom_solver.h"
|
#include "polynom_solver.h"
|
||||||
#include "p3p.h"
|
#include "p3p.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void p3p::init_inverse_parameters()
|
void p3p::init_inverse_parameters()
|
||||||
{
|
{
|
||||||
inv_fx = 1. / fx;
|
inv_fx = 1. / fx;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
#include "precomp.hpp"
|
||||||
|
#include "polynom_solver.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include "precomp.hpp"
|
|
||||||
|
|
||||||
#include "polynom_solver.h"
|
|
||||||
|
|
||||||
int solve_deg2(double a, double b, double c, double & x1, double & x2)
|
int solve_deg2(double a, double b, double c, double & x1, double & x2)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
namespace cv {
|
namespace cv {
|
||||||
|
|
||||||
|
|
||||||
// static void drawCircles(Mat& img, const vector<Point2f>& corners, const vector<float>& radius)
|
// static void drawCircles(Mat& img, const std::vector<Point2f>& corners, const std::vector<float>& radius)
|
||||||
// {
|
// {
|
||||||
// for(size_t i = 0; i < corners.size(); i++)
|
// for(size_t i = 0; i < corners.size(); i++)
|
||||||
// {
|
// {
|
||||||
@ -86,7 +86,7 @@ inline bool is_smaller(const std::pair<int, float>& p1, const std::pair<int, flo
|
|||||||
return p1.second < p2.second;
|
return p1.second < p2.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void orderContours(const vector<vector<Point> >& contours, Point2f point, vector<std::pair<int, float> >& order)
|
static void orderContours(const std::vector<std::vector<Point> >& contours, Point2f point, std::vector<std::pair<int, float> >& order)
|
||||||
{
|
{
|
||||||
order.clear();
|
order.clear();
|
||||||
size_t i, j, n = contours.size();
|
size_t i, j, n = contours.size();
|
||||||
@ -106,12 +106,12 @@ static void orderContours(const vector<vector<Point> >& contours, Point2f point,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fit second order curve to a set of 2D points
|
// fit second order curve to a set of 2D points
|
||||||
inline void fitCurve2Order(const vector<Point2f>& /*points*/, vector<float>& /*curve*/)
|
inline void fitCurve2Order(const std::vector<Point2f>& /*points*/, std::vector<float>& /*curve*/)
|
||||||
{
|
{
|
||||||
// TBD
|
// TBD
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void findCurvesCross(const vector<float>& /*curve1*/, const vector<float>& /*curve2*/, Point2f& /*cross_point*/)
|
inline void findCurvesCross(const std::vector<float>& /*curve1*/, const std::vector<float>& /*curve2*/, Point2f& /*cross_point*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ static void findLinesCrossPoint(Point2f origin1, Point2f dir1, Point2f origin2,
|
|||||||
cross_point = origin1 + dir1*alpha;
|
cross_point = origin1 + dir1*alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static void findCorner(const vector<Point>& contour, Point2f point, Point2f& corner)
|
// static void findCorner(const std::vector<Point>& contour, Point2f point, Point2f& corner)
|
||||||
// {
|
// {
|
||||||
// // find the nearest point
|
// // find the nearest point
|
||||||
// double min_dist = std::numeric_limits<double>::max();
|
// double min_dist = std::numeric_limits<double>::max();
|
||||||
@ -147,7 +147,7 @@ static void findLinesCrossPoint(Point2f origin1, Point2f dir1, Point2f origin2,
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static void findCorner(const vector<Point2f>& contour, Point2f point, Point2f& corner)
|
static void findCorner(const std::vector<Point2f>& contour, Point2f point, Point2f& corner)
|
||||||
{
|
{
|
||||||
// find the nearest point
|
// find the nearest point
|
||||||
double min_dist = std::numeric_limits<double>::max();
|
double min_dist = std::numeric_limits<double>::max();
|
||||||
@ -234,7 +234,7 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size
|
|||||||
Mat hist;
|
Mat hist;
|
||||||
|
|
||||||
#if defined(_SUBPIX_VERBOSE)
|
#if defined(_SUBPIX_VERBOSE)
|
||||||
vector<float> radius;
|
std::vector<float> radius;
|
||||||
radius.assign(corners.size(), 0.0f);
|
radius.assign(corners.size(), 0.0f);
|
||||||
#endif //_SUBPIX_VERBOSE
|
#endif //_SUBPIX_VERBOSE
|
||||||
|
|
||||||
@ -277,15 +277,15 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
vector<vector<Point> > white_contours, black_contours;
|
std::vector<std::vector<Point> > white_contours, black_contours;
|
||||||
vector<Vec4i> white_hierarchy, black_hierarchy;
|
std::vector<Vec4i> white_hierarchy, black_hierarchy;
|
||||||
findContours(black_comp, black_contours, black_hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
|
findContours(black_comp, black_contours, black_hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
|
||||||
findContours(white_comp, white_contours, white_hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
|
findContours(white_comp, white_contours, white_hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
|
||||||
|
|
||||||
if(black_contours.size() < 5 || white_contours.size() < 5) continue;
|
if(black_contours.size() < 5 || white_contours.size() < 5) continue;
|
||||||
|
|
||||||
// find two white and black blobs that are close to the input point
|
// find two white and black blobs that are close to the input point
|
||||||
vector<std::pair<int, float> > white_order, black_order;
|
std::vector<std::pair<int, float> > white_order, black_order;
|
||||||
orderContours(black_contours, corners[i], black_order);
|
orderContours(black_contours, corners[i], black_order);
|
||||||
orderContours(white_contours, corners[i], white_order);
|
orderContours(white_contours, corners[i], white_order);
|
||||||
|
|
||||||
@ -296,14 +296,14 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size
|
|||||||
continue; // there will be no improvement in this corner position
|
continue; // there will be no improvement in this corner position
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<Point>* quads[4] = {&black_contours[black_order[0].first], &black_contours[black_order[1].first],
|
const std::vector<Point>* quads[4] = {&black_contours[black_order[0].first], &black_contours[black_order[1].first],
|
||||||
&white_contours[white_order[0].first], &white_contours[white_order[1].first]};
|
&white_contours[white_order[0].first], &white_contours[white_order[1].first]};
|
||||||
vector<Point2f> quads_approx[4];
|
std::vector<Point2f> quads_approx[4];
|
||||||
Point2f quad_corners[4];
|
Point2f quad_corners[4];
|
||||||
for(int k = 0; k < 4; k++)
|
for(int k = 0; k < 4; k++)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
vector<Point2f> temp;
|
std::vector<Point2f> temp;
|
||||||
for(size_t j = 0; j < quads[k]->size(); j++) temp.push_back((*quads[k])[j]);
|
for(size_t j = 0; j < quads[k]->size(); j++) temp.push_back((*quads[k])[j]);
|
||||||
approxPolyDP(Mat(temp), quads_approx[k], 0.5, true);
|
approxPolyDP(Mat(temp), quads_approx[k], 0.5, true);
|
||||||
|
|
||||||
@ -332,14 +332,14 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size
|
|||||||
cvtColor(img, test, CV_GRAY2RGB);
|
cvtColor(img, test, CV_GRAY2RGB);
|
||||||
// line(test, quad_corners[0] - corners[i] + Point2f(30, 30), quad_corners[1] - corners[i] + Point2f(30, 30), cvScalar(0, 255, 0));
|
// line(test, quad_corners[0] - corners[i] + Point2f(30, 30), quad_corners[1] - corners[i] + Point2f(30, 30), cvScalar(0, 255, 0));
|
||||||
// line(test, quad_corners[2] - corners[i] + Point2f(30, 30), quad_corners[3] - corners[i] + Point2f(30, 30), cvScalar(0, 255, 0));
|
// line(test, quad_corners[2] - corners[i] + Point2f(30, 30), quad_corners[3] - corners[i] + Point2f(30, 30), cvScalar(0, 255, 0));
|
||||||
vector<vector<Point> > contrs;
|
std::vector<std::vector<Point> > contrs;
|
||||||
contrs.resize(1);
|
contrs.resize(1);
|
||||||
for(int k = 0; k < 4; k++)
|
for(int k = 0; k < 4; k++)
|
||||||
{
|
{
|
||||||
//contrs[0] = quads_approx[k];
|
//contrs[0] = quads_approx[k];
|
||||||
contrs[0].clear();
|
contrs[0].clear();
|
||||||
for(size_t j = 0; j < quads_approx[k].size(); j++) contrs[0].push_back(quads_approx[k][j]);
|
for(size_t j = 0; j < quads_approx[k].size(); j++) contrs[0].push_back(quads_approx[k][j]);
|
||||||
drawContours(test, contrs, 0, CV_RGB(0, 0, 255), 1, 1, vector<Vec4i>(), 2);
|
drawContours(test, contrs, 0, CV_RGB(0, 0, 255), 1, 1, std::vector<Vec4i>(), 2);
|
||||||
circle(test, quad_corners[k], 0.5, CV_RGB(255, 0, 0));
|
circle(test, quad_corners[k], 0.5, CV_RGB(255, 0, 0));
|
||||||
}
|
}
|
||||||
Mat test1 = test(Rect(corners[i].x - 30, corners[i].y - 30, 60, 60));
|
Mat test1 = test(Rect(corners[i].x - 30, corners[i].y - 30, 60, 60));
|
||||||
|
@ -162,8 +162,8 @@ namespace cv
|
|||||||
CameraParameters camera;
|
CameraParameters camera;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void pnpTask(const vector<char>& pointsMask, const Mat& objectPoints, const Mat& imagePoints,
|
static void pnpTask(const std::vector<char>& pointsMask, const Mat& objectPoints, const Mat& imagePoints,
|
||||||
const Parameters& params, vector<int>& inliers, Mat& rvec, Mat& tvec,
|
const Parameters& params, std::vector<int>& inliers, Mat& rvec, Mat& tvec,
|
||||||
const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex)
|
const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex)
|
||||||
{
|
{
|
||||||
Mat modelObjectPoints(1, MIN_POINTS_COUNT, CV_32FC3), modelImagePoints(1, MIN_POINTS_COUNT, CV_32FC2);
|
Mat modelObjectPoints(1, MIN_POINTS_COUNT, CV_32FC3), modelImagePoints(1, MIN_POINTS_COUNT, CV_32FC2);
|
||||||
@ -199,14 +199,14 @@ namespace cv
|
|||||||
params.useExtrinsicGuess, params.flags);
|
params.useExtrinsicGuess, params.flags);
|
||||||
|
|
||||||
|
|
||||||
vector<Point2f> projected_points;
|
std::vector<Point2f> projected_points;
|
||||||
projected_points.resize(objectPoints.cols);
|
projected_points.resize(objectPoints.cols);
|
||||||
projectPoints(objectPoints, localRvec, localTvec, params.camera.intrinsics, params.camera.distortion, projected_points);
|
projectPoints(objectPoints, localRvec, localTvec, params.camera.intrinsics, params.camera.distortion, projected_points);
|
||||||
|
|
||||||
Mat rotatedPoints;
|
Mat rotatedPoints;
|
||||||
project3dPoints(objectPoints, localRvec, localTvec, rotatedPoints);
|
project3dPoints(objectPoints, localRvec, localTvec, rotatedPoints);
|
||||||
|
|
||||||
vector<int> localInliers;
|
std::vector<int> localInliers;
|
||||||
for (int i = 0; i < objectPoints.cols; i++)
|
for (int i = 0; i < objectPoints.cols; i++)
|
||||||
{
|
{
|
||||||
Point2f p(imagePoints.at<Vec2f>(0, i)[0], imagePoints.at<Vec2f>(0, i)[1]);
|
Point2f p(imagePoints.at<Vec2f>(0, i)[0], imagePoints.at<Vec2f>(0, i)[1]);
|
||||||
@ -236,7 +236,7 @@ namespace cv
|
|||||||
public:
|
public:
|
||||||
void operator()( const BlockedRange& r ) const
|
void operator()( const BlockedRange& r ) const
|
||||||
{
|
{
|
||||||
vector<char> pointsMask(objectPoints.cols, 0);
|
std::vector<char> pointsMask(objectPoints.cols, 0);
|
||||||
memset(&pointsMask[0], 1, MIN_POINTS_COUNT );
|
memset(&pointsMask[0], 1, MIN_POINTS_COUNT );
|
||||||
for( int i=r.begin(); i!=r.end(); ++i )
|
for( int i=r.begin(); i!=r.end(); ++i )
|
||||||
{
|
{
|
||||||
@ -254,7 +254,7 @@ namespace cv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PnPSolver(const Mat& _objectPoints, const Mat& _imagePoints, const Parameters& _parameters,
|
PnPSolver(const Mat& _objectPoints, const Mat& _imagePoints, const Parameters& _parameters,
|
||||||
Mat& _rvec, Mat& _tvec, vector<int>& _inliers):
|
Mat& _rvec, Mat& _tvec, std::vector<int>& _inliers):
|
||||||
objectPoints(_objectPoints), imagePoints(_imagePoints), parameters(_parameters),
|
objectPoints(_objectPoints), imagePoints(_imagePoints), parameters(_parameters),
|
||||||
rvec(_rvec), tvec(_tvec), inliers(_inliers)
|
rvec(_rvec), tvec(_tvec), inliers(_inliers)
|
||||||
{
|
{
|
||||||
@ -270,13 +270,13 @@ namespace cv
|
|||||||
const Mat& imagePoints;
|
const Mat& imagePoints;
|
||||||
const Parameters& parameters;
|
const Parameters& parameters;
|
||||||
Mat &rvec, &tvec;
|
Mat &rvec, &tvec;
|
||||||
vector<int>& inliers;
|
std::vector<int>& inliers;
|
||||||
Mat initRvec, initTvec;
|
Mat initRvec, initTvec;
|
||||||
|
|
||||||
static RNG generator;
|
static RNG generator;
|
||||||
static Mutex syncMutex;
|
static Mutex syncMutex;
|
||||||
|
|
||||||
void generateVar(vector<char>& mask) const
|
void generateVar(std::vector<char>& mask) const
|
||||||
{
|
{
|
||||||
int size = (int)mask.size();
|
int size = (int)mask.size();
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
@ -329,7 +329,7 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
|||||||
params.camera.init(cameraMatrix, distCoeffs);
|
params.camera.init(cameraMatrix, distCoeffs);
|
||||||
params.flags = flags;
|
params.flags = flags;
|
||||||
|
|
||||||
vector<int> localInliers;
|
std::vector<int> localInliers;
|
||||||
Mat localRvec, localTvec;
|
Mat localRvec, localTvec;
|
||||||
rvec.copyTo(localRvec);
|
rvec.copyTo(localRvec);
|
||||||
tvec.copyTo(localTvec);
|
tvec.copyTo(localTvec);
|
||||||
|
@ -716,8 +716,8 @@ struct FindStereoCorrespInvoker
|
|||||||
void operator()( const BlockedRange& range ) const
|
void operator()( const BlockedRange& range ) const
|
||||||
{
|
{
|
||||||
int cols = left->cols, rows = left->rows;
|
int cols = left->cols, rows = left->rows;
|
||||||
int _row0 = min(cvRound(range.begin() * rows / nstripes), rows);
|
int _row0 = std::min(cvRound(range.begin() * rows / nstripes), rows);
|
||||||
int _row1 = min(cvRound(range.end() * rows / nstripes), rows);
|
int _row1 = std::min(cvRound(range.end() * rows / nstripes), rows);
|
||||||
uchar *ptr = state->slidingSumBuf->data.ptr + range.begin() * stripeBufSize;
|
uchar *ptr = state->slidingSumBuf->data.ptr + range.begin() * stripeBufSize;
|
||||||
int FILTERED = (state->minDisparity - 1)*16;
|
int FILTERED = (state->minDisparity - 1)*16;
|
||||||
|
|
||||||
@ -801,7 +801,7 @@ static void findStereoCorrespondenceBM( const Mat& left0, const Mat& right0, Mat
|
|||||||
CV_Error( CV_StsOutOfRange, "preFilterCap must be within 1..63" );
|
CV_Error( CV_StsOutOfRange, "preFilterCap must be within 1..63" );
|
||||||
|
|
||||||
if( state->SADWindowSize < 5 || state->SADWindowSize > 255 || state->SADWindowSize % 2 == 0 ||
|
if( state->SADWindowSize < 5 || state->SADWindowSize > 255 || state->SADWindowSize % 2 == 0 ||
|
||||||
state->SADWindowSize >= min(left0.cols, left0.rows) )
|
state->SADWindowSize >= std::min(left0.cols, left0.rows) )
|
||||||
CV_Error( CV_StsOutOfRange, "SADWindowSize must be odd, be within 5..255 and be not larger than image width or height" );
|
CV_Error( CV_StsOutOfRange, "SADWindowSize must be odd, be within 5..255 and be not larger than image width or height" );
|
||||||
|
|
||||||
if( state->numberOfDisparities <= 0 || state->numberOfDisparities % 16 != 0 )
|
if( state->numberOfDisparities <= 0 || state->numberOfDisparities % 16 != 0 )
|
||||||
@ -831,8 +831,8 @@ static void findStereoCorrespondenceBM( const Mat& left0, const Mat& right0, Mat
|
|||||||
|
|
||||||
int width = left0.cols;
|
int width = left0.cols;
|
||||||
int height = left0.rows;
|
int height = left0.rows;
|
||||||
int lofs = max(ndisp - 1 + mindisp, 0);
|
int lofs = std::max(ndisp - 1 + mindisp, 0);
|
||||||
int rofs = -min(ndisp - 1 + mindisp, 0);
|
int rofs = -std::min(ndisp - 1 + mindisp, 0);
|
||||||
int width1 = width - rofs - ndisp + 1;
|
int width1 = width - rofs - ndisp + 1;
|
||||||
int FILTERED = (state->minDisparity - 1) << DISPARITY_SHIFT;
|
int FILTERED = (state->minDisparity - 1) << DISPARITY_SHIFT;
|
||||||
|
|
||||||
@ -874,13 +874,13 @@ static void findStereoCorrespondenceBM( const Mat& left0, const Mat& right0, Mat
|
|||||||
#ifdef HAVE_TBB
|
#ifdef HAVE_TBB
|
||||||
const double SAD_overhead_coeff = 10.0;
|
const double SAD_overhead_coeff = 10.0;
|
||||||
double N0 = 8000000 / (useShorts ? 1 : 4); // approx tbb's min number instructions reasonable for one thread
|
double N0 = 8000000 / (useShorts ? 1 : 4); // approx tbb's min number instructions reasonable for one thread
|
||||||
double maxStripeSize = min(max(N0 / (width * ndisp), (wsz-1) * SAD_overhead_coeff), (double)height);
|
double maxStripeSize = std::min(std::max(N0 / (width * ndisp), (wsz-1) * SAD_overhead_coeff), (double)height);
|
||||||
int nstripes = cvCeil(height / maxStripeSize);
|
int nstripes = cvCeil(height / maxStripeSize);
|
||||||
#else
|
#else
|
||||||
const int nstripes = 1;
|
const int nstripes = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int bufSize = max(bufSize0 * nstripes, max(bufSize1 * 2, bufSize2));
|
int bufSize = std::max(bufSize0 * nstripes, std::max(bufSize1 * 2, bufSize2));
|
||||||
|
|
||||||
if( !state->slidingSumBuf || state->slidingSumBuf->cols < bufSize )
|
if( !state->slidingSumBuf || state->slidingSumBuf->cols < bufSize )
|
||||||
{
|
{
|
||||||
|
@ -114,8 +114,8 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
|
|||||||
int tabOfs, int )
|
int tabOfs, int )
|
||||||
{
|
{
|
||||||
int x, c, width = img1.cols, cn = img1.channels();
|
int x, c, width = img1.cols, cn = img1.channels();
|
||||||
int minX1 = max(maxD, 0), maxX1 = width + min(minD, 0);
|
int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
|
||||||
int minX2 = max(minX1 - maxD, 0), maxX2 = min(maxX1 - minD, width);
|
int minX2 = std::max(minX1 - maxD, 0), maxX2 = std::min(maxX1 - minD, width);
|
||||||
int D = maxD - minD, width1 = maxX1 - minX1, width2 = maxX2 - minX2;
|
int D = maxD - minD, width1 = maxX1 - minX1, width2 = maxX2 - minX2;
|
||||||
const PixType *row1 = img1.ptr<PixType>(y), *row2 = img2.ptr<PixType>(y);
|
const PixType *row1 = img1.ptr<PixType>(y), *row2 = img2.ptr<PixType>(y);
|
||||||
PixType *prow1 = buffer + width2*2, *prow2 = prow1 + width*cn*2;
|
PixType *prow1 = buffer + width2*2, *prow2 = prow1 + width*cn*2;
|
||||||
@ -186,8 +186,8 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
|
|||||||
int v = prow2[x];
|
int v = prow2[x];
|
||||||
int vl = x > 0 ? (v + prow2[x-1])/2 : v;
|
int vl = x > 0 ? (v + prow2[x-1])/2 : v;
|
||||||
int vr = x < width-1 ? (v + prow2[x+1])/2 : v;
|
int vr = x < width-1 ? (v + prow2[x+1])/2 : v;
|
||||||
int v0 = min(vl, vr); v0 = min(v0, v);
|
int v0 = std::min(vl, vr); v0 = std::min(v0, v);
|
||||||
int v1 = max(vl, vr); v1 = max(v1, v);
|
int v1 = std::max(vl, vr); v1 = std::max(v1, v);
|
||||||
buffer[x] = (PixType)v0;
|
buffer[x] = (PixType)v0;
|
||||||
buffer[x + width2] = (PixType)v1;
|
buffer[x + width2] = (PixType)v1;
|
||||||
}
|
}
|
||||||
@ -197,8 +197,8 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
|
|||||||
int u = prow1[x];
|
int u = prow1[x];
|
||||||
int ul = x > 0 ? (u + prow1[x-1])/2 : u;
|
int ul = x > 0 ? (u + prow1[x-1])/2 : u;
|
||||||
int ur = x < width-1 ? (u + prow1[x+1])/2 : u;
|
int ur = x < width-1 ? (u + prow1[x+1])/2 : u;
|
||||||
int u0 = min(ul, ur); u0 = min(u0, u);
|
int u0 = std::min(ul, ur); u0 = std::min(u0, u);
|
||||||
int u1 = max(ul, ur); u1 = max(u1, u);
|
int u1 = std::max(ul, ur); u1 = std::max(u1, u);
|
||||||
|
|
||||||
#if CV_SSE2
|
#if CV_SSE2
|
||||||
if( useSIMD )
|
if( useSIMD )
|
||||||
@ -231,10 +231,10 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
|
|||||||
int v = prow2[width-x-1 + d];
|
int v = prow2[width-x-1 + d];
|
||||||
int v0 = buffer[width-x-1 + d];
|
int v0 = buffer[width-x-1 + d];
|
||||||
int v1 = buffer[width-x-1 + d + width2];
|
int v1 = buffer[width-x-1 + d + width2];
|
||||||
int c0 = max(0, u - v1); c0 = max(c0, v0 - u);
|
int c0 = std::max(0, u - v1); c0 = std::max(c0, v0 - u);
|
||||||
int c1 = max(0, v - u1); c1 = max(c1, u0 - v);
|
int c1 = std::max(0, v - u1); c1 = std::max(c1, u0 - v);
|
||||||
|
|
||||||
cost[x*D + d] = (CostType)(cost[x*D+d] + (min(c0, c1) >> diff_scale));
|
cost[x*D + d] = (CostType)(cost[x*D+d] + (std::min(c0, c1) >> diff_scale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,12 +324,12 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
int minD = params.minDisparity, maxD = minD + params.numberOfDisparities;
|
int minD = params.minDisparity, maxD = minD + params.numberOfDisparities;
|
||||||
Size SADWindowSize;
|
Size SADWindowSize;
|
||||||
SADWindowSize.width = SADWindowSize.height = params.SADWindowSize > 0 ? params.SADWindowSize : 5;
|
SADWindowSize.width = SADWindowSize.height = params.SADWindowSize > 0 ? params.SADWindowSize : 5;
|
||||||
int ftzero = max(params.preFilterCap, 15) | 1;
|
int ftzero = std::max(params.preFilterCap, 15) | 1;
|
||||||
int uniquenessRatio = params.uniquenessRatio >= 0 ? params.uniquenessRatio : 10;
|
int uniquenessRatio = params.uniquenessRatio >= 0 ? params.uniquenessRatio : 10;
|
||||||
int disp12MaxDiff = params.disp12MaxDiff > 0 ? params.disp12MaxDiff : 1;
|
int disp12MaxDiff = params.disp12MaxDiff > 0 ? params.disp12MaxDiff : 1;
|
||||||
int P1 = params.P1 > 0 ? params.P1 : 2, P2 = max(params.P2 > 0 ? params.P2 : 5, P1+1);
|
int P1 = params.P1 > 0 ? params.P1 : 2, P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1);
|
||||||
int k, width = disp1.cols, height = disp1.rows;
|
int k, width = disp1.cols, height = disp1.rows;
|
||||||
int minX1 = max(maxD, 0), maxX1 = width + min(minD, 0);
|
int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
|
||||||
int D = maxD - minD, width1 = maxX1 - minX1;
|
int D = maxD - minD, width1 = maxX1 - minX1;
|
||||||
int INVALID_DISP = minD - 1, INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;
|
int INVALID_DISP = minD - 1, INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;
|
||||||
int SW2 = SADWindowSize.width/2, SH2 = SADWindowSize.height/2;
|
int SW2 = SADWindowSize.width/2, SH2 = SADWindowSize.height/2;
|
||||||
@ -338,7 +338,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
PixType clipTab[TAB_SIZE];
|
PixType clipTab[TAB_SIZE];
|
||||||
|
|
||||||
for( k = 0; k < TAB_SIZE; k++ )
|
for( k = 0; k < TAB_SIZE; k++ )
|
||||||
clipTab[k] = (PixType)(min(max(k - TAB_OFS, -ftzero), ftzero) + ftzero);
|
clipTab[k] = (PixType)(std::min(std::max(k - TAB_OFS, -ftzero), ftzero) + ftzero);
|
||||||
|
|
||||||
if( minX1 >= maxX1 )
|
if( minX1 >= maxX1 )
|
||||||
{
|
{
|
||||||
@ -432,7 +432,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
|
|
||||||
for( k = dy1; k <= dy2; k++ )
|
for( k = dy1; k <= dy2; k++ )
|
||||||
{
|
{
|
||||||
CostType* hsumAdd = hsumBuf + (min(k, height-1) % hsumBufNRows)*costBufSize;
|
CostType* hsumAdd = hsumBuf + (std::min(k, height-1) % hsumBufNRows)*costBufSize;
|
||||||
|
|
||||||
if( k < height )
|
if( k < height )
|
||||||
{
|
{
|
||||||
@ -448,13 +448,13 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
|
|
||||||
if( y > 0 )
|
if( y > 0 )
|
||||||
{
|
{
|
||||||
const CostType* hsumSub = hsumBuf + (max(y - SH2 - 1, 0) % hsumBufNRows)*costBufSize;
|
const CostType* hsumSub = hsumBuf + (std::max(y - SH2 - 1, 0) % hsumBufNRows)*costBufSize;
|
||||||
const CostType* Cprev = !params.fullDP || y == 0 ? C : C - costBufSize;
|
const CostType* Cprev = !params.fullDP || y == 0 ? C : C - costBufSize;
|
||||||
|
|
||||||
for( x = D; x < width1*D; x += D )
|
for( x = D; x < width1*D; x += D )
|
||||||
{
|
{
|
||||||
const CostType* pixAdd = pixDiff + min(x + SW2*D, (width1-1)*D);
|
const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D);
|
||||||
const CostType* pixSub = pixDiff + max(x - (SW2+1)*D, 0);
|
const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0);
|
||||||
|
|
||||||
#if CV_SSE2
|
#if CV_SSE2
|
||||||
if( useSIMD )
|
if( useSIMD )
|
||||||
@ -488,8 +488,8 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
{
|
{
|
||||||
for( x = D; x < width1*D; x += D )
|
for( x = D; x < width1*D; x += D )
|
||||||
{
|
{
|
||||||
const CostType* pixAdd = pixDiff + min(x + SW2*D, (width1-1)*D);
|
const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D);
|
||||||
const CostType* pixSub = pixDiff + max(x - (SW2+1)*D, 0);
|
const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0);
|
||||||
|
|
||||||
for( d = 0; d < D; d++ )
|
for( d = 0; d < D; d++ )
|
||||||
hsumAdd[x + d] = (CostType)(hsumAdd[x - D + d] + pixAdd[d] - pixSub[d]);
|
hsumAdd[x + d] = (CostType)(hsumAdd[x - D + d] + pixAdd[d] - pixSub[d]);
|
||||||
@ -630,22 +630,22 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
{
|
{
|
||||||
int Cpd = Cp[d], L0, L1, L2, L3;
|
int Cpd = Cp[d], L0, L1, L2, L3;
|
||||||
|
|
||||||
L0 = Cpd + min((int)Lr_p0[d], min(Lr_p0[d-1] + P1, min(Lr_p0[d+1] + P1, delta0))) - delta0;
|
L0 = Cpd + std::min((int)Lr_p0[d], std::min(Lr_p0[d-1] + P1, std::min(Lr_p0[d+1] + P1, delta0))) - delta0;
|
||||||
L1 = Cpd + min((int)Lr_p1[d], min(Lr_p1[d-1] + P1, min(Lr_p1[d+1] + P1, delta1))) - delta1;
|
L1 = Cpd + std::min((int)Lr_p1[d], std::min(Lr_p1[d-1] + P1, std::min(Lr_p1[d+1] + P1, delta1))) - delta1;
|
||||||
L2 = Cpd + min((int)Lr_p2[d], min(Lr_p2[d-1] + P1, min(Lr_p2[d+1] + P1, delta2))) - delta2;
|
L2 = Cpd + std::min((int)Lr_p2[d], std::min(Lr_p2[d-1] + P1, std::min(Lr_p2[d+1] + P1, delta2))) - delta2;
|
||||||
L3 = Cpd + min((int)Lr_p3[d], min(Lr_p3[d-1] + P1, min(Lr_p3[d+1] + P1, delta3))) - delta3;
|
L3 = Cpd + std::min((int)Lr_p3[d], std::min(Lr_p3[d-1] + P1, std::min(Lr_p3[d+1] + P1, delta3))) - delta3;
|
||||||
|
|
||||||
Lr_p[d] = (CostType)L0;
|
Lr_p[d] = (CostType)L0;
|
||||||
minL0 = min(minL0, L0);
|
minL0 = std::min(minL0, L0);
|
||||||
|
|
||||||
Lr_p[d + D2] = (CostType)L1;
|
Lr_p[d + D2] = (CostType)L1;
|
||||||
minL1 = min(minL1, L1);
|
minL1 = std::min(minL1, L1);
|
||||||
|
|
||||||
Lr_p[d + D2*2] = (CostType)L2;
|
Lr_p[d + D2*2] = (CostType)L2;
|
||||||
minL2 = min(minL2, L2);
|
minL2 = std::min(minL2, L2);
|
||||||
|
|
||||||
Lr_p[d + D2*3] = (CostType)L3;
|
Lr_p[d + D2*3] = (CostType)L3;
|
||||||
minL3 = min(minL3, L3);
|
minL3 = std::min(minL3, L3);
|
||||||
|
|
||||||
Sp[d] = saturate_cast<CostType>(Sp[d] + L0 + L1 + L2 + L3);
|
Sp[d] = saturate_cast<CostType>(Sp[d] + L0 + L1 + L2 + L3);
|
||||||
}
|
}
|
||||||
@ -737,10 +737,10 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
{
|
{
|
||||||
for( d = 0; d < D; d++ )
|
for( d = 0; d < D; d++ )
|
||||||
{
|
{
|
||||||
int L0 = Cp[d] + min((int)Lr_p0[d], min(Lr_p0[d-1] + P1, min(Lr_p0[d+1] + P1, delta0))) - delta0;
|
int L0 = Cp[d] + std::min((int)Lr_p0[d], std::min(Lr_p0[d-1] + P1, std::min(Lr_p0[d+1] + P1, delta0))) - delta0;
|
||||||
|
|
||||||
Lr_p[d] = (CostType)L0;
|
Lr_p[d] = (CostType)L0;
|
||||||
minL0 = min(minL0, L0);
|
minL0 = std::min(minL0, L0);
|
||||||
|
|
||||||
int Sval = Sp[d] = saturate_cast<CostType>(Sp[d] + L0);
|
int Sval = Sp[d] = saturate_cast<CostType>(Sp[d] + L0);
|
||||||
if( Sval < minS )
|
if( Sval < minS )
|
||||||
@ -785,7 +785,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
|||||||
// do subpixel quadratic interpolation:
|
// do subpixel quadratic interpolation:
|
||||||
// fit parabola into (x1=d-1, y1=Sp[d-1]), (x2=d, y2=Sp[d]), (x3=d+1, y3=Sp[d+1])
|
// fit parabola into (x1=d-1, y1=Sp[d-1]), (x2=d, y2=Sp[d]), (x3=d+1, y3=Sp[d+1])
|
||||||
// then find minimum of the parabola.
|
// then find minimum of the parabola.
|
||||||
int denom2 = max(Sp[d-1] + Sp[d+1] - 2*Sp[d], 1);
|
int denom2 = std::max(Sp[d-1] + Sp[d+1] - 2*Sp[d], 1);
|
||||||
d = d*DISP_SCALE + ((Sp[d-1] - Sp[d+1])*DISP_SCALE + denom2)/(denom2*2);
|
d = d*DISP_SCALE + ((Sp[d-1] - Sp[d+1])*DISP_SCALE + denom2)/(denom2*2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -845,10 +845,10 @@ Rect getValidDisparityROI( Rect roi1, Rect roi2,
|
|||||||
int SW2 = SADWindowSize/2;
|
int SW2 = SADWindowSize/2;
|
||||||
int minD = minDisparity, maxD = minDisparity + numberOfDisparities - 1;
|
int minD = minDisparity, maxD = minDisparity + numberOfDisparities - 1;
|
||||||
|
|
||||||
int xmin = max(roi1.x, roi2.x + maxD) + SW2;
|
int xmin = std::max(roi1.x, roi2.x + maxD) + SW2;
|
||||||
int xmax = min(roi1.x + roi1.width, roi2.x + roi2.width - minD) - SW2;
|
int xmax = std::min(roi1.x + roi1.width, roi2.x + roi2.width - minD) - SW2;
|
||||||
int ymin = max(roi1.y, roi2.y) + SW2;
|
int ymin = std::max(roi1.y, roi2.y) + SW2;
|
||||||
int ymax = min(roi1.y + roi1.height, roi2.y + roi2.height) - SW2;
|
int ymax = std::min(roi1.y + roi1.height, roi2.y + roi2.height) - SW2;
|
||||||
|
|
||||||
Rect r(xmin, ymin, xmax - xmin, ymax - ymin);
|
Rect r(xmin, ymin, xmax - xmin, ymax - ymin);
|
||||||
|
|
||||||
@ -979,7 +979,7 @@ void cv::validateDisparity( InputOutputArray _disp, InputArray _cost, int minDis
|
|||||||
Mat disp = _disp.getMat(), cost = _cost.getMat();
|
Mat disp = _disp.getMat(), cost = _cost.getMat();
|
||||||
int cols = disp.cols, rows = disp.rows;
|
int cols = disp.cols, rows = disp.rows;
|
||||||
int minD = minDisparity, maxD = minDisparity + numberOfDisparities;
|
int minD = minDisparity, maxD = minDisparity + numberOfDisparities;
|
||||||
int x, minX1 = max(maxD, 0), maxX1 = cols + min(minD, 0);
|
int x, minX1 = std::max(maxD, 0), maxX1 = cols + std::min(minD, 0);
|
||||||
AutoBuffer<int> _disp2buf(cols*2);
|
AutoBuffer<int> _disp2buf(cols*2);
|
||||||
int* disp2buf = _disp2buf;
|
int* disp2buf = _disp2buf;
|
||||||
int* disp2cost = disp2buf + cols;
|
int* disp2cost = disp2buf + cols;
|
||||||
|
@ -43,6 +43,9 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace cv;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
class CV_ProjectPointsTest : public cvtest::ArrayTest
|
class CV_ProjectPointsTest : public cvtest::ArrayTest
|
||||||
{
|
{
|
||||||
@ -241,8 +244,6 @@ CV_ProjectPointsTest ProjectPoints_test;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace cv;
|
|
||||||
|
|
||||||
// --------------------------------- CV_CameraCalibrationTest --------------------------------------------
|
// --------------------------------- CV_CameraCalibrationTest --------------------------------------------
|
||||||
|
|
||||||
class CV_CameraCalibrationTest : public cvtest::BaseTest
|
class CV_CameraCalibrationTest : public cvtest::BaseTest
|
||||||
|
@ -51,7 +51,7 @@ using namespace cv;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ChessBoardGenerator::ChessBoardGenerator(const Size& _patternSize) : sensorWidth(32), sensorHeight(24),
|
ChessBoardGenerator::ChessBoardGenerator(const Size& _patternSize) : sensorWidth(32), sensorHeight(24),
|
||||||
squareEdgePointsNum(200), min_cos(sqrt(2.f)*0.5f), cov(0.5),
|
squareEdgePointsNum(200), min_cos(std::sqrt(2.f)*0.5f), cov(0.5),
|
||||||
patternSize(_patternSize), rendererResolutionMultiplier(4), tvec(Mat::zeros(1, 3, CV_32F))
|
patternSize(_patternSize), rendererResolutionMultiplier(4), tvec(Mat::zeros(1, 3, CV_32F))
|
||||||
{
|
{
|
||||||
Rodrigues(Mat::eye(3, 3, CV_32F), rvec);
|
Rodrigues(Mat::eye(3, 3, CV_32F), rvec);
|
||||||
@ -178,7 +178,7 @@ Mat cv::ChessBoardGenerator::generateChessBoard(const Mat& bg, const Mat& camMat
|
|||||||
|
|
||||||
Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector<Point2f>& corners) const
|
Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector<Point2f>& corners) const
|
||||||
{
|
{
|
||||||
cov = min(cov, 0.8);
|
cov = std::min(cov, 0.8);
|
||||||
double fovx, fovy, focalLen;
|
double fovx, fovy, focalLen;
|
||||||
Point2d principalPoint;
|
Point2d principalPoint;
|
||||||
double aspect;
|
double aspect;
|
||||||
@ -199,7 +199,7 @@ Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const
|
|||||||
Point3f pb1, pb2;
|
Point3f pb1, pb2;
|
||||||
generateBasis(pb1, pb2);
|
generateBasis(pb1, pb2);
|
||||||
|
|
||||||
float cbHalfWidth = static_cast<float>(norm(p) * sin( min(fovx, fovy) * 0.5 * CV_PI / 180));
|
float cbHalfWidth = static_cast<float>(norm(p) * sin( std::min(fovx, fovy) * 0.5 * CV_PI / 180));
|
||||||
float cbHalfHeight = cbHalfWidth * patternSize.height / patternSize.width;
|
float cbHalfHeight = cbHalfWidth * patternSize.height / patternSize.width;
|
||||||
|
|
||||||
float cbHalfWidthEx = cbHalfWidth * ( patternSize.width + 1) / patternSize.width;
|
float cbHalfWidthEx = cbHalfWidth * ( patternSize.width + 1) / patternSize.width;
|
||||||
@ -243,7 +243,7 @@ Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const
|
|||||||
Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
|
Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
|
||||||
const Size2f& squareSize, vector<Point2f>& corners) const
|
const Size2f& squareSize, vector<Point2f>& corners) const
|
||||||
{
|
{
|
||||||
cov = min(cov, 0.8);
|
cov = std::min(cov, 0.8);
|
||||||
double fovx, fovy, focalLen;
|
double fovx, fovy, focalLen;
|
||||||
Point2d principalPoint;
|
Point2d principalPoint;
|
||||||
double aspect;
|
double aspect;
|
||||||
@ -302,7 +302,7 @@ Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const
|
|||||||
Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
|
Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
|
||||||
const Size2f& squareSize, const Point3f& pos, vector<Point2f>& corners) const
|
const Size2f& squareSize, const Point3f& pos, vector<Point2f>& corners) const
|
||||||
{
|
{
|
||||||
cov = min(cov, 0.8);
|
cov = std::min(cov, 0.8);
|
||||||
Point3f p = pos;
|
Point3f p = pos;
|
||||||
Point3f pb1, pb2;
|
Point3f pb1, pb2;
|
||||||
generateBasis(pb1, pb2);
|
generateBasis(pb1, pb2);
|
||||||
|
@ -18,17 +18,17 @@ public:
|
|||||||
int rendererResolutionMultiplier;
|
int rendererResolutionMultiplier;
|
||||||
|
|
||||||
ChessBoardGenerator(const Size& patternSize = Size(8, 6));
|
ChessBoardGenerator(const Size& patternSize = Size(8, 6));
|
||||||
Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector<Point2f>& corners) const;
|
Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, std::vector<Point2f>& corners) const;
|
||||||
Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, vector<Point2f>& corners) const;
|
Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, std::vector<Point2f>& corners) const;
|
||||||
Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, const Point3f& pos, vector<Point2f>& corners) const;
|
Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, const Point3f& pos, std::vector<Point2f>& corners) const;
|
||||||
Size cornersSize() const;
|
Size cornersSize() const;
|
||||||
|
|
||||||
mutable vector<Point3f> corners3d;
|
mutable std::vector<Point3f> corners3d;
|
||||||
private:
|
private:
|
||||||
void generateEdge(const Point3f& p1, const Point3f& p2, vector<Point3f>& out) const;
|
void generateEdge(const Point3f& p1, const Point3f& p2, std::vector<Point3f>& out) const;
|
||||||
Mat generateChessBoard(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
|
Mat generateChessBoard(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
|
||||||
const Point3f& zero, const Point3f& pb1, const Point3f& pb2,
|
const Point3f& zero, const Point3f& pb1, const Point3f& pb2,
|
||||||
float sqWidth, float sqHeight, const vector<Point3f>& whole, vector<Point2f>& corners) const;
|
float sqWidth, float sqHeight, const std::vector<Point3f>& whole, std::vector<Point2f>& corners) const;
|
||||||
void generateBasis(Point3f& pb1, Point3f& pb2) const;
|
void generateBasis(Point3f& pb1, Point3f& pb2) const;
|
||||||
|
|
||||||
Mat rvec, tvec;
|
Mat rvec, tvec;
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include "test_chessboardgenerator.hpp"
|
#include "test_chessboardgenerator.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
class CV_ChessboardSubpixelTest : public cvtest::BaseTest
|
class CV_ChessboardSubpixelTest : public cvtest::BaseTest
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "test_precomp.hpp"
|
#include "test_precomp.hpp"
|
||||||
#include "_modelest.h"
|
#include "_modelest.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
class BareModelEstimator : public CvModelEstimator2
|
class BareModelEstimator : public CvModelEstimator2
|
||||||
|
@ -270,17 +270,17 @@ namespace cv
|
|||||||
};
|
};
|
||||||
|
|
||||||
Octree();
|
Octree();
|
||||||
Octree( const vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
|
Octree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
|
||||||
virtual ~Octree();
|
virtual ~Octree();
|
||||||
|
|
||||||
virtual void buildTree( const vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
|
virtual void buildTree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
|
||||||
virtual void getPointsWithinSphere( const Point3f& center, float radius,
|
virtual void getPointsWithinSphere( const Point3f& center, float radius,
|
||||||
vector<Point3f>& points ) const;
|
std::vector<Point3f>& points ) const;
|
||||||
const vector<Node>& getNodes() const { return nodes; }
|
const std::vector<Node>& getNodes() const { return nodes; }
|
||||||
private:
|
private:
|
||||||
int minPoints;
|
int minPoints;
|
||||||
vector<Point3f> points;
|
std::vector<Point3f> points;
|
||||||
vector<Node> nodes;
|
std::vector<Node> nodes;
|
||||||
|
|
||||||
virtual void buildNext(size_t node_ind);
|
virtual void buildNext(size_t node_ind);
|
||||||
};
|
};
|
||||||
@ -292,19 +292,19 @@ namespace cv
|
|||||||
struct EmptyMeshException {};
|
struct EmptyMeshException {};
|
||||||
|
|
||||||
Mesh3D();
|
Mesh3D();
|
||||||
Mesh3D(const vector<Point3f>& vtx);
|
Mesh3D(const std::vector<Point3f>& vtx);
|
||||||
~Mesh3D();
|
~Mesh3D();
|
||||||
|
|
||||||
void buildOctree();
|
void buildOctree();
|
||||||
void clearOctree();
|
void clearOctree();
|
||||||
float estimateResolution(float tryRatio = 0.1f);
|
float estimateResolution(float tryRatio = 0.1f);
|
||||||
void computeNormals(float normalRadius, int minNeighbors = 20);
|
void computeNormals(float normalRadius, int minNeighbors = 20);
|
||||||
void computeNormals(const vector<int>& subset, float normalRadius, int minNeighbors = 20);
|
void computeNormals(const std::vector<int>& subset, float normalRadius, int minNeighbors = 20);
|
||||||
|
|
||||||
void writeAsVrml(const String& file, const vector<Scalar>& colors = vector<Scalar>()) const;
|
void writeAsVrml(const std::string& file, const std::vector<Scalar>& colors = std::vector<Scalar>()) const;
|
||||||
|
|
||||||
vector<Point3f> vtx;
|
std::vector<Point3f> vtx;
|
||||||
vector<Point3f> normals;
|
std::vector<Point3f> normals;
|
||||||
float resolution;
|
float resolution;
|
||||||
Octree octree;
|
Octree octree;
|
||||||
|
|
||||||
@ -335,10 +335,10 @@ namespace cv
|
|||||||
|
|
||||||
void setLogger(std::ostream* log);
|
void setLogger(std::ostream* log);
|
||||||
void selectRandomSubset(float ratio);
|
void selectRandomSubset(float ratio);
|
||||||
void setSubset(const vector<int>& subset);
|
void setSubset(const std::vector<int>& subset);
|
||||||
void compute();
|
void compute();
|
||||||
|
|
||||||
void match(const SpinImageModel& scene, vector< vector<Vec2i> >& result);
|
void match(const SpinImageModel& scene, std::vector< std::vector<Vec2i> >& result);
|
||||||
|
|
||||||
Mat packRandomScaledSpins(bool separateScale = false, size_t xCount = 10, size_t yCount = 10) const;
|
Mat packRandomScaledSpins(bool separateScale = false, size_t xCount = 10, size_t yCount = 10) const;
|
||||||
|
|
||||||
@ -368,12 +368,12 @@ namespace cv
|
|||||||
protected:
|
protected:
|
||||||
void defaultParams();
|
void defaultParams();
|
||||||
|
|
||||||
void matchSpinToModel(const Mat& spin, vector<int>& indeces,
|
void matchSpinToModel(const Mat& spin, std::vector<int>& indeces,
|
||||||
vector<float>& corrCoeffs, bool useExtremeOutliers = true) const;
|
std::vector<float>& corrCoeffs, bool useExtremeOutliers = true) const;
|
||||||
|
|
||||||
void repackSpinImages(const vector<uchar>& mask, Mat& spinImages, bool reAlloc = true) const;
|
void repackSpinImages(const std::vector<uchar>& mask, Mat& spinImages, bool reAlloc = true) const;
|
||||||
|
|
||||||
vector<int> subset;
|
std::vector<int> subset;
|
||||||
Mesh3D mesh;
|
Mesh3D mesh;
|
||||||
Mat spinImages;
|
Mat spinImages;
|
||||||
std::ostream* out;
|
std::ostream* out;
|
||||||
@ -416,8 +416,8 @@ namespace cv
|
|||||||
size_t getDescriptorSize() const;
|
size_t getDescriptorSize() const;
|
||||||
Size getGridSize( Size imgsize, Size winStride ) const;
|
Size getGridSize( Size imgsize, Size winStride ) const;
|
||||||
|
|
||||||
virtual void compute(const Mat& img, vector<float>& descriptors, Size winStride=Size(),
|
virtual void compute(const Mat& img, std::vector<float>& descriptors, Size winStride=Size(),
|
||||||
const vector<Point>& locations=vector<Point>()) const;
|
const std::vector<Point>& locations=std::vector<Point>()) const;
|
||||||
virtual void computeLogPolarMapping(Mat& mappingMask) const;
|
virtual void computeLogPolarMapping(Mat& mappingMask) const;
|
||||||
virtual void SSD(const Mat& img, Point pt, Mat& ssd) const;
|
virtual void SSD(const Mat& img, Point pt, Mat& ssd) const;
|
||||||
|
|
||||||
@ -486,13 +486,13 @@ namespace cv
|
|||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
// useful function to do simple bundle adjustment tasks
|
// useful function to do simple bundle adjustment tasks
|
||||||
static void bundleAdjust(vector<Point3d>& points, // positions of points in global coordinate system (input and output)
|
static void bundleAdjust(std::vector<Point3d>& points, // positions of points in global coordinate system (input and output)
|
||||||
const vector<vector<Point2d> >& imagePoints, // projections of 3d points for every camera
|
const std::vector<std::vector<Point2d> >& imagePoints, // projections of 3d points for every camera
|
||||||
const vector<vector<int> >& visibility, // visibility of 3d points for every camera
|
const std::vector<std::vector<int> >& visibility, // visibility of 3d points for every camera
|
||||||
vector<Mat>& cameraMatrix, // intrinsic matrices of all cameras (input and output)
|
std::vector<Mat>& cameraMatrix, // intrinsic matrices of all cameras (input and output)
|
||||||
vector<Mat>& R, // rotation matrices of all cameras (input and output)
|
std::vector<Mat>& R, // rotation matrices of all cameras (input and output)
|
||||||
vector<Mat>& T, // translation vector of all cameras (input and output)
|
std::vector<Mat>& T, // translation vector of all cameras (input and output)
|
||||||
vector<Mat>& distCoeffs, // distortion coefficients of all cameras (input and output)
|
std::vector<Mat>& distCoeffs, // distortion coefficients of all cameras (input and output)
|
||||||
const TermCriteria& criteria=
|
const TermCriteria& criteria=
|
||||||
TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON),
|
TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON),
|
||||||
BundleAdjustCallback cb = 0, void* user_data = 0);
|
BundleAdjustCallback cb = 0, void* user_data = 0);
|
||||||
@ -558,7 +558,7 @@ namespace cv
|
|||||||
};
|
};
|
||||||
|
|
||||||
CV_EXPORTS_W int chamerMatching( Mat& img, Mat& templ,
|
CV_EXPORTS_W int chamerMatching( Mat& img, Mat& templ,
|
||||||
CV_OUT vector<vector<Point> >& results, CV_OUT vector<float>& cost,
|
CV_OUT std::vector<std::vector<Point> >& results, CV_OUT std::vector<float>& cost,
|
||||||
double templScale=1, int maxMatches = 20,
|
double templScale=1, int maxMatches = 20,
|
||||||
double minMatchDistance = 1.0, int padX = 3,
|
double minMatchDistance = 1.0, int padX = 3,
|
||||||
int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6,
|
int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6,
|
||||||
@ -757,9 +757,9 @@ namespace cv
|
|||||||
|
|
||||||
Mat Rsri;
|
Mat Rsri;
|
||||||
Mat Csri;
|
Mat Csri;
|
||||||
vector<int> Rsr;
|
std::vector<int> Rsr;
|
||||||
vector<int> Csr;
|
std::vector<int> Csr;
|
||||||
vector<double> Wsr;
|
std::vector<double> Wsr;
|
||||||
|
|
||||||
int S, R, M, N, ind1;
|
int S, R, M, N, ind1;
|
||||||
int top, bottom,left,right;
|
int top, bottom,left,right;
|
||||||
@ -768,13 +768,13 @@ namespace cv
|
|||||||
struct kernel
|
struct kernel
|
||||||
{
|
{
|
||||||
kernel() { w = 0; }
|
kernel() { w = 0; }
|
||||||
vector<double> weights;
|
std::vector<double> weights;
|
||||||
int w;
|
int w;
|
||||||
};
|
};
|
||||||
|
|
||||||
Mat ETAyx;
|
Mat ETAyx;
|
||||||
Mat CSIyx;
|
Mat CSIyx;
|
||||||
vector<kernel> w_ker_2D;
|
std::vector<kernel> w_ker_2D;
|
||||||
|
|
||||||
void create_map(int M, int N, int R, int S, double ro0);
|
void create_map(int M, int N, int R, int S, double ro0);
|
||||||
};
|
};
|
||||||
@ -838,8 +838,8 @@ namespace cv
|
|||||||
int S, R, M, N;
|
int S, R, M, N;
|
||||||
int top, bottom,left,right;
|
int top, bottom,left,right;
|
||||||
double ro0, romax, a, q;
|
double ro0, romax, a, q;
|
||||||
vector<vector<pixel> > L;
|
std::vector<std::vector<pixel> > L;
|
||||||
vector<double> A;
|
std::vector<double> A;
|
||||||
|
|
||||||
void subdivide_recursively(double x, double y, int i, int j, double length, double smin);
|
void subdivide_recursively(double x, double y, int i, int j, double length, double smin);
|
||||||
bool get_uv(double x, double y, int&u, int&v);
|
bool get_uv(double x, double y, int&u, int&v);
|
||||||
@ -869,10 +869,10 @@ namespace cv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Serializes this object to a given filename.
|
// Serializes this object to a given filename.
|
||||||
void save(const string& filename) const;
|
void save(const std::string& filename) const;
|
||||||
|
|
||||||
// Deserializes this object from a given filename.
|
// Deserializes this object from a given filename.
|
||||||
void load(const string& filename);
|
void load(const std::string& filename);
|
||||||
|
|
||||||
// Serializes this object to a given cv::FileStorage.
|
// Serializes this object to a given cv::FileStorage.
|
||||||
void save(FileStorage& fs) const;
|
void save(FileStorage& fs) const;
|
||||||
@ -926,10 +926,10 @@ namespace cv
|
|||||||
CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const = 0;
|
CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const = 0;
|
||||||
|
|
||||||
// Serializes this object to a given filename.
|
// Serializes this object to a given filename.
|
||||||
CV_WRAP virtual void save(const string& filename) const;
|
CV_WRAP virtual void save(const std::string& filename) const;
|
||||||
|
|
||||||
// Deserializes this object from a given filename.
|
// Deserializes this object from a given filename.
|
||||||
CV_WRAP virtual void load(const string& filename);
|
CV_WRAP virtual void load(const std::string& filename);
|
||||||
|
|
||||||
// Serializes this object to a given cv::FileStorage.
|
// Serializes this object to a given cv::FileStorage.
|
||||||
virtual void save(FileStorage& fs) const = 0;
|
virtual void save(FileStorage& fs) const = 0;
|
||||||
|
@ -76,9 +76,9 @@ struct CV_EXPORTS CvMeanShiftTrackerParams
|
|||||||
CvTermCriteria term_crit = CvTermCriteria());
|
CvTermCriteria term_crit = CvTermCriteria());
|
||||||
|
|
||||||
int tracking_type;
|
int tracking_type;
|
||||||
vector<float> h_range;
|
std::vector<float> h_range;
|
||||||
vector<float> s_range;
|
std::vector<float> s_range;
|
||||||
vector<float> v_range;
|
std::vector<float> v_range;
|
||||||
CvTermCriteria term_crit;
|
CvTermCriteria term_crit;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ class CV_EXPORTS CvFeatureTracker
|
|||||||
private:
|
private:
|
||||||
Ptr<Feature2D> dd;
|
Ptr<Feature2D> dd;
|
||||||
Ptr<DescriptorMatcher> matcher;
|
Ptr<DescriptorMatcher> matcher;
|
||||||
vector<DMatch> matches;
|
std::vector<DMatch> matches;
|
||||||
|
|
||||||
Mat prev_image;
|
Mat prev_image;
|
||||||
Mat prev_image_bw;
|
Mat prev_image_bw;
|
||||||
@ -153,7 +153,7 @@ private:
|
|||||||
Point2d prev_center;
|
Point2d prev_center;
|
||||||
|
|
||||||
int ittr;
|
int ittr;
|
||||||
vector<Point2f> features[2];
|
std::vector<Point2f> features[2];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Mat disp_matches;
|
Mat disp_matches;
|
||||||
|
@ -65,10 +65,6 @@ namespace cv {
|
|||||||
|
|
||||||
namespace of2 {
|
namespace of2 {
|
||||||
|
|
||||||
using std::list;
|
|
||||||
using std::map;
|
|
||||||
using std::multiset;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return data format of a FABMAP compare call
|
Return data format of a FABMAP compare call
|
||||||
*/
|
*/
|
||||||
@ -115,50 +111,50 @@ public:
|
|||||||
|
|
||||||
//methods to add training data for sampling method
|
//methods to add training data for sampling method
|
||||||
virtual void addTraining(const Mat& queryImgDescriptor);
|
virtual void addTraining(const Mat& queryImgDescriptor);
|
||||||
virtual void addTraining(const vector<Mat>& queryImgDescriptors);
|
virtual void addTraining(const std::vector<Mat>& queryImgDescriptors);
|
||||||
|
|
||||||
//methods to add to the test data
|
//methods to add to the test data
|
||||||
virtual void add(const Mat& queryImgDescriptor);
|
virtual void add(const Mat& queryImgDescriptor);
|
||||||
virtual void add(const vector<Mat>& queryImgDescriptors);
|
virtual void add(const std::vector<Mat>& queryImgDescriptors);
|
||||||
|
|
||||||
//accessors
|
//accessors
|
||||||
const vector<Mat>& getTrainingImgDescriptors() const;
|
const std::vector<Mat>& getTrainingImgDescriptors() const;
|
||||||
const vector<Mat>& getTestImgDescriptors() const;
|
const std::vector<Mat>& getTestImgDescriptors() const;
|
||||||
|
|
||||||
//Main FabMap image comparison
|
//Main FabMap image comparison
|
||||||
void compare(const Mat& queryImgDescriptor,
|
void compare(const Mat& queryImgDescriptor,
|
||||||
vector<IMatch>& matches, bool addQuery = false,
|
std::vector<IMatch>& matches, bool addQuery = false,
|
||||||
const Mat& mask = Mat());
|
const Mat& mask = Mat());
|
||||||
void compare(const Mat& queryImgDescriptor,
|
void compare(const Mat& queryImgDescriptor,
|
||||||
const Mat& testImgDescriptors, vector<IMatch>& matches,
|
const Mat& testImgDescriptors, std::vector<IMatch>& matches,
|
||||||
const Mat& mask = Mat());
|
const Mat& mask = Mat());
|
||||||
void compare(const Mat& queryImgDescriptor,
|
void compare(const Mat& queryImgDescriptor,
|
||||||
const vector<Mat>& testImgDescriptors,
|
const std::vector<Mat>& testImgDescriptors,
|
||||||
vector<IMatch>& matches, const Mat& mask = Mat());
|
std::vector<IMatch>& matches, const Mat& mask = Mat());
|
||||||
void compare(const vector<Mat>& queryImgDescriptors, vector<
|
void compare(const std::vector<Mat>& queryImgDescriptors, std::vector<
|
||||||
IMatch>& matches, bool addQuery = false, const Mat& mask =
|
IMatch>& matches, bool addQuery = false, const Mat& mask =
|
||||||
Mat());
|
Mat());
|
||||||
void compare(const vector<Mat>& queryImgDescriptors,
|
void compare(const std::vector<Mat>& queryImgDescriptors,
|
||||||
const vector<Mat>& testImgDescriptors,
|
const std::vector<Mat>& testImgDescriptors,
|
||||||
vector<IMatch>& matches, const Mat& mask = Mat());
|
std::vector<IMatch>& matches, const Mat& mask = Mat());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void compareImgDescriptor(const Mat& queryImgDescriptor,
|
void compareImgDescriptor(const Mat& queryImgDescriptor,
|
||||||
int queryIndex, const vector<Mat>& testImgDescriptors,
|
int queryIndex, const std::vector<Mat>& testImgDescriptors,
|
||||||
vector<IMatch>& matches);
|
std::vector<IMatch>& matches);
|
||||||
|
|
||||||
void addImgDescriptor(const Mat& queryImgDescriptor);
|
void addImgDescriptor(const Mat& queryImgDescriptor);
|
||||||
|
|
||||||
//the getLikelihoods method is overwritten for each different FabMap
|
//the getLikelihoods method is overwritten for each different FabMap
|
||||||
//method.
|
//method.
|
||||||
virtual void getLikelihoods(const Mat& queryImgDescriptor,
|
virtual void getLikelihoods(const Mat& queryImgDescriptor,
|
||||||
const vector<Mat>& testImgDescriptors,
|
const std::vector<Mat>& testImgDescriptors,
|
||||||
vector<IMatch>& matches);
|
std::vector<IMatch>& matches);
|
||||||
virtual double getNewPlaceLikelihood(const Mat& queryImgDescriptor);
|
virtual double getNewPlaceLikelihood(const Mat& queryImgDescriptor);
|
||||||
|
|
||||||
//turn likelihoods into probabilities (also add in motion model if used)
|
//turn likelihoods into probabilities (also add in motion model if used)
|
||||||
void normaliseDistribution(vector<IMatch>& matches);
|
void normaliseDistribution(std::vector<IMatch>& matches);
|
||||||
|
|
||||||
//Chow-Liu Tree
|
//Chow-Liu Tree
|
||||||
int pq(int q);
|
int pq(int q);
|
||||||
@ -174,9 +170,9 @@ protected:
|
|||||||
|
|
||||||
//data
|
//data
|
||||||
Mat clTree;
|
Mat clTree;
|
||||||
vector<Mat> trainingImgDescriptors;
|
std::vector<Mat> trainingImgDescriptors;
|
||||||
vector<Mat> testImgDescriptors;
|
std::vector<Mat> testImgDescriptors;
|
||||||
vector<IMatch> priorMatches;
|
std::vector<IMatch> priorMatches;
|
||||||
|
|
||||||
//parameters
|
//parameters
|
||||||
double PzGe;
|
double PzGe;
|
||||||
@ -203,8 +199,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
//FabMap1 implementation of likelihood comparison
|
//FabMap1 implementation of likelihood comparison
|
||||||
void getLikelihoods(const Mat& queryImgDescriptor, const vector<
|
void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
|
||||||
Mat>& testImgDescriptors, vector<IMatch>& matches);
|
Mat>& testImgDescriptors, std::vector<IMatch>& matches);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -219,8 +215,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
//FabMap look-up-table implementation of the likelihood comparison
|
//FabMap look-up-table implementation of the likelihood comparison
|
||||||
void getLikelihoods(const Mat& queryImgDescriptor, const vector<
|
void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
|
||||||
Mat>& testImgDescriptors, vector<IMatch>& matches);
|
Mat>& testImgDescriptors, std::vector<IMatch>& matches);
|
||||||
|
|
||||||
//precomputed data
|
//precomputed data
|
||||||
int (*table)[8];
|
int (*table)[8];
|
||||||
@ -243,8 +239,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
//FabMap Fast Bail-out implementation of the likelihood comparison
|
//FabMap Fast Bail-out implementation of the likelihood comparison
|
||||||
void getLikelihoods(const Mat& queryImgDescriptor, const vector<
|
void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
|
||||||
Mat>& testImgDescriptors, vector<IMatch>& matches);
|
Mat>& testImgDescriptors, std::vector<IMatch>& matches);
|
||||||
|
|
||||||
//stucture used to determine word comparison order
|
//stucture used to determine word comparison order
|
||||||
struct WordStats {
|
struct WordStats {
|
||||||
@ -268,7 +264,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//private fast bail-out necessary functions
|
//private fast bail-out necessary functions
|
||||||
void setWordStatistics(const Mat& queryImgDescriptor, multiset<WordStats>& wordData);
|
void setWordStatistics(const Mat& queryImgDescriptor, std::multiset<WordStats>& wordData);
|
||||||
double limitbisection(double v, double m);
|
double limitbisection(double v, double m);
|
||||||
double bennettInequality(double v, double m, double delta);
|
double bennettInequality(double v, double m, double delta);
|
||||||
static bool compInfo(const WordStats& first, const WordStats& second);
|
static bool compInfo(const WordStats& first, const WordStats& second);
|
||||||
@ -295,39 +291,39 @@ public:
|
|||||||
void addTraining(const Mat& queryImgDescriptors) {
|
void addTraining(const Mat& queryImgDescriptors) {
|
||||||
FabMap::addTraining(queryImgDescriptors);
|
FabMap::addTraining(queryImgDescriptors);
|
||||||
}
|
}
|
||||||
void addTraining(const vector<Mat>& queryImgDescriptors);
|
void addTraining(const std::vector<Mat>& queryImgDescriptors);
|
||||||
|
|
||||||
void add(const Mat& queryImgDescriptors) {
|
void add(const Mat& queryImgDescriptors) {
|
||||||
FabMap::add(queryImgDescriptors);
|
FabMap::add(queryImgDescriptors);
|
||||||
}
|
}
|
||||||
void add(const vector<Mat>& queryImgDescriptors);
|
void add(const std::vector<Mat>& queryImgDescriptors);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//FabMap2 implementation of the likelihood comparison
|
//FabMap2 implementation of the likelihood comparison
|
||||||
void getLikelihoods(const Mat& queryImgDescriptor, const vector<
|
void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
|
||||||
Mat>& testImgDescriptors, vector<IMatch>& matches);
|
Mat>& testImgDescriptors, std::vector<IMatch>& matches);
|
||||||
double getNewPlaceLikelihood(const Mat& queryImgDescriptor);
|
double getNewPlaceLikelihood(const Mat& queryImgDescriptor);
|
||||||
|
|
||||||
//the likelihood function using the inverted index
|
//the likelihood function using the inverted index
|
||||||
void getIndexLikelihoods(const Mat& queryImgDescriptor, vector<
|
void getIndexLikelihoods(const Mat& queryImgDescriptor, std::vector<
|
||||||
double>& defaults, map<int, vector<int> >& invertedMap,
|
double>& defaults, std::map<int, std::vector<int> >& invertedMap,
|
||||||
vector<IMatch>& matches);
|
std::vector<IMatch>& matches);
|
||||||
void addToIndex(const Mat& queryImgDescriptor,
|
void addToIndex(const Mat& queryImgDescriptor,
|
||||||
vector<double>& defaults,
|
std::vector<double>& defaults,
|
||||||
map<int, vector<int> >& invertedMap);
|
std::map<int, std::vector<int> >& invertedMap);
|
||||||
|
|
||||||
//data
|
//data
|
||||||
vector<double> d1, d2, d3, d4;
|
std::vector<double> d1, d2, d3, d4;
|
||||||
vector<vector<int> > children;
|
std::vector<std::vector<int> > children;
|
||||||
|
|
||||||
// TODO: inverted map a vector?
|
// TODO: inverted map a vector?
|
||||||
|
|
||||||
vector<double> trainingDefaults;
|
std::vector<double> trainingDefaults;
|
||||||
map<int, vector<int> > trainingInvertedMap;
|
std::map<int, std::vector<int> > trainingInvertedMap;
|
||||||
|
|
||||||
vector<double> testDefaults;
|
std::vector<double> testDefaults;
|
||||||
map<int, vector<int> > testInvertedMap;
|
std::map<int, std::vector<int> > testInvertedMap;
|
||||||
|
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
@ -342,14 +338,14 @@ public:
|
|||||||
|
|
||||||
//add data to the chow-liu tree before calling make
|
//add data to the chow-liu tree before calling make
|
||||||
void add(const Mat& imgDescriptor);
|
void add(const Mat& imgDescriptor);
|
||||||
void add(const vector<Mat>& imgDescriptors);
|
void add(const std::vector<Mat>& imgDescriptors);
|
||||||
|
|
||||||
const vector<Mat>& getImgDescriptors() const;
|
const std::vector<Mat>& getImgDescriptors() const;
|
||||||
|
|
||||||
Mat make(double infoThreshold = 0.0);
|
Mat make(double infoThreshold = 0.0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<Mat> imgDescriptors;
|
std::vector<Mat> imgDescriptors;
|
||||||
Mat mergedImgDescriptors;
|
Mat mergedImgDescriptors;
|
||||||
|
|
||||||
typedef struct info {
|
typedef struct info {
|
||||||
@ -364,18 +360,18 @@ private:
|
|||||||
double CP(int a, bool za, int b, bool zb); // a | b
|
double CP(int a, bool za, int b, bool zb); // a | b
|
||||||
|
|
||||||
//calculating mutual information of all edges
|
//calculating mutual information of all edges
|
||||||
void createBaseEdges(list<info>& edges, double infoThreshold);
|
void createBaseEdges(std::list<info>& edges, double infoThreshold);
|
||||||
double calcMutInfo(int word1, int word2);
|
double calcMutInfo(int word1, int word2);
|
||||||
static bool sortInfoScores(const info& first, const info& second);
|
static bool sortInfoScores(const info& first, const info& second);
|
||||||
|
|
||||||
//selecting minimum spanning egdges with maximum information
|
//selecting minimum spanning egdges with maximum information
|
||||||
bool reduceEdgesToMinSpan(list<info>& edges);
|
bool reduceEdgesToMinSpan(std::list<info>& edges);
|
||||||
|
|
||||||
//building the tree sctructure
|
//building the tree sctructure
|
||||||
Mat buildTree(int root_word, list<info> &edges);
|
Mat buildTree(int root_word, std::list<info> &edges);
|
||||||
void recAddToTree(Mat &cltree, int q, int pq,
|
void recAddToTree(Mat &cltree, int q, int pq,
|
||||||
list<info> &remaining_edges);
|
std::list<info> &remaining_edges);
|
||||||
vector<int> extractChildren(list<info> &remaining_edges, int q);
|
std::vector<int> extractChildren(std::list<info> &remaining_edges, int q);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -989,13 +989,13 @@ static void func_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& esti
|
|||||||
func(i,j,&_point_params,&_cam_params,&_estim,data);
|
func(i,j,&_point_params,&_cam_params,&_estim,data);
|
||||||
};
|
};
|
||||||
|
|
||||||
void LevMarqSparse::bundleAdjust( vector<Point3d>& points, //positions of points in global coordinate system (input and output)
|
void LevMarqSparse::bundleAdjust( std::vector<Point3d>& points, //positions of points in global coordinate system (input and output)
|
||||||
const vector<vector<Point2d> >& imagePoints, //projections of 3d points for every camera
|
const std::vector<std::vector<Point2d> >& imagePoints, //projections of 3d points for every camera
|
||||||
const vector<vector<int> >& visibility, //visibility of 3d points for every camera
|
const std::vector<std::vector<int> >& visibility, //visibility of 3d points for every camera
|
||||||
vector<Mat>& cameraMatrix, //intrinsic matrices of all cameras (input and output)
|
std::vector<Mat>& cameraMatrix, //intrinsic matrices of all cameras (input and output)
|
||||||
vector<Mat>& R, //rotation matrices of all cameras (input and output)
|
std::vector<Mat>& R, //rotation matrices of all cameras (input and output)
|
||||||
vector<Mat>& T, //translation vector of all cameras (input and output)
|
std::vector<Mat>& T, //translation vector of all cameras (input and output)
|
||||||
vector<Mat>& distCoeffs, //distortion coefficients of all cameras (input and output)
|
std::vector<Mat>& distCoeffs, //distortion coefficients of all cameras (input and output)
|
||||||
const TermCriteria& criteria,
|
const TermCriteria& criteria,
|
||||||
BundleAdjustCallback cb, void* user_data) {
|
BundleAdjustCallback cb, void* user_data) {
|
||||||
//,enum{MOTION_AND_STRUCTURE,MOTION,STRUCTURE})
|
//,enum{MOTION_AND_STRUCTURE,MOTION,STRUCTURE})
|
||||||
|
@ -180,7 +180,7 @@ void BasicRetinaFilter::setLPfilterParameters(const float beta, const float tau,
|
|||||||
}
|
}
|
||||||
|
|
||||||
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
|
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
|
||||||
float a = _filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
|
float a = _filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)std::sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
|
||||||
_filteringCoeficientsTable[1+tableOffset]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
|
_filteringCoeficientsTable[1+tableOffset]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
|
||||||
_filteringCoeficientsTable[2+tableOffset] =tau;
|
_filteringCoeficientsTable[2+tableOffset] =tau;
|
||||||
|
|
||||||
@ -210,17 +210,17 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const floa
|
|||||||
|
|
||||||
float _alpha=0.8f;
|
float _alpha=0.8f;
|
||||||
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
|
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
|
||||||
float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
|
float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)std::sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
|
||||||
_filteringCoeficientsTable[tableOffset+1]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
|
_filteringCoeficientsTable[tableOffset+1]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
|
||||||
_filteringCoeficientsTable[tableOffset+2] =tau;
|
_filteringCoeficientsTable[tableOffset+2] =tau;
|
||||||
|
|
||||||
float commonFactor=alpha0/(float)sqrt(_halfNBcolumns*_halfNBcolumns+_halfNBrows*_halfNBrows+1.0f);
|
float commonFactor=alpha0/(float)std::sqrt(_halfNBcolumns*_halfNBcolumns+_halfNBrows*_halfNBrows+1.0f);
|
||||||
//memset(_progressiveSpatialConstant, 255, _filterOutput.getNBpixels());
|
//memset(_progressiveSpatialConstant, 255, _filterOutput.getNBpixels());
|
||||||
for (unsigned int idColumn=0;idColumn<_halfNBcolumns; ++idColumn)
|
for (unsigned int idColumn=0;idColumn<_halfNBcolumns; ++idColumn)
|
||||||
for (unsigned int idRow=0;idRow<_halfNBrows; ++idRow)
|
for (unsigned int idRow=0;idRow<_halfNBrows; ++idRow)
|
||||||
{
|
{
|
||||||
// computing local spatial constant
|
// computing local spatial constant
|
||||||
float localSpatialConstantValue=commonFactor*sqrt((float)(idColumn*idColumn)+(float)(idRow*idRow));
|
float localSpatialConstantValue=commonFactor*std::sqrt((float)(idColumn*idColumn)+(float)(idRow*idRow));
|
||||||
if (localSpatialConstantValue>1.0f)
|
if (localSpatialConstantValue>1.0f)
|
||||||
localSpatialConstantValue=1.0f;
|
localSpatialConstantValue=1.0f;
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const floa
|
|||||||
_progressiveGain[_halfNBcolumns-1+idColumn+_filterOutput.getNBcolumns()*(_halfNBrows-1-idRow)]=localGain;
|
_progressiveGain[_halfNBcolumns-1+idColumn+_filterOutput.getNBcolumns()*(_halfNBrows-1-idRow)]=localGain;
|
||||||
_progressiveGain[_halfNBcolumns-1-idColumn+_filterOutput.getNBcolumns()*(_halfNBrows-1-idRow)]=localGain;
|
_progressiveGain[_halfNBcolumns-1-idColumn+_filterOutput.getNBcolumns()*(_halfNBrows-1-idRow)]=localGain;
|
||||||
|
|
||||||
//std::cout<<commonFactor<<", "<<sqrt((_halfNBcolumns-1-idColumn)+(_halfNBrows-idRow-1))<<", "<<(_halfNBcolumns-1-idColumn)<<", "<<(_halfNBrows-idRow-1)<<", "<<localSpatialConstantValue<<std::endl;
|
//std::cout<<commonFactor<<", "<<std::sqrt((_halfNBcolumns-1-idColumn)+(_halfNBrows-idRow-1))<<", "<<(_halfNBcolumns-1-idColumn)<<", "<<(_halfNBrows-idRow-1)<<", "<<localSpatialConstantValue<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CustomAccuracy(const float
|
|||||||
}
|
}
|
||||||
unsigned int tableOffset=filterIndex*3;
|
unsigned int tableOffset=filterIndex*3;
|
||||||
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
|
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
|
||||||
float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
|
float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)std::sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
|
||||||
_filteringCoeficientsTable[tableOffset+1]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
|
_filteringCoeficientsTable[tableOffset+1]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
|
||||||
_filteringCoeficientsTable[tableOffset+2] =tau;
|
_filteringCoeficientsTable[tableOffset+2] =tau;
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CustomAccuracy(const float
|
|||||||
float localGain=(1.0f-localSpatialConstantValue)*(1.0f-localSpatialConstantValue)*(1.0f-localSpatialConstantValue)*(1.0f-localSpatialConstantValue)/(1.0f+_beta);
|
float localGain=(1.0f-localSpatialConstantValue)*(1.0f-localSpatialConstantValue)*(1.0f-localSpatialConstantValue)*(1.0f-localSpatialConstantValue)/(1.0f+_beta);
|
||||||
_progressiveGain[index]=localGain;
|
_progressiveGain[index]=localGain;
|
||||||
|
|
||||||
//std::cout<<commonFactor<<", "<<sqrt((_halfNBcolumns-1-idColumn)+(_halfNBrows-idRow-1))<<", "<<(_halfNBcolumns-1-idColumn)<<", "<<(_halfNBrows-idRow-1)<<", "<<localSpatialConstantValue<<std::endl;
|
//std::cout<<commonFactor<<", "<<std::sqrt((_halfNBcolumns-1-idColumn)+(_halfNBrows-idRow-1))<<", "<<(_halfNBcolumns-1-idColumn)<<", "<<(_halfNBrows-idRow-1)<<", "<<localSpatialConstantValue<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,6 @@
|
|||||||
|
|
||||||
//#define __BASIC_RETINA_ELEMENT_DEBUG
|
//#define __BASIC_RETINA_ELEMENT_DEBUG
|
||||||
|
|
||||||
//using namespace std;
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
class BasicRetinaFilter
|
class BasicRetinaFilter
|
||||||
|
@ -90,7 +90,7 @@ Mat BOWMSCTrainer::cluster(const Mat& _descriptors) const {
|
|||||||
|
|
||||||
Mat icovar = Mat::eye(_descriptors.cols,_descriptors.cols,_descriptors.type());
|
Mat icovar = Mat::eye(_descriptors.cols,_descriptors.cols,_descriptors.type());
|
||||||
|
|
||||||
vector<Mat> initialCentres;
|
std::vector<Mat> initialCentres;
|
||||||
initialCentres.push_back(_descriptors.row(0));
|
initialCentres.push_back(_descriptors.row(0));
|
||||||
for (int i = 1; i < _descriptors.rows; i++) {
|
for (int i = 1; i < _descriptors.rows; i++) {
|
||||||
double minDist = DBL_MAX;
|
double minDist = DBL_MAX;
|
||||||
|
@ -54,8 +54,6 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
using std::queue;
|
|
||||||
|
|
||||||
typedef std::pair<int,int> coordinate_t;
|
typedef std::pair<int,int> coordinate_t;
|
||||||
typedef float orientation_t;
|
typedef float orientation_t;
|
||||||
typedef std::vector<coordinate_t> template_coords_t;
|
typedef std::vector<coordinate_t> template_coords_t;
|
||||||
@ -824,7 +822,7 @@ ChamferMatcher::Template::Template(Mat& edge_image, float scale_) : addr_width(-
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<int>& ChamferMatcher::Template::getTemplateAddresses(int width)
|
std::vector<int>& ChamferMatcher::Template::getTemplateAddresses(int width)
|
||||||
{
|
{
|
||||||
if (addr_width!=width) {
|
if (addr_width!=width) {
|
||||||
addr.resize(coords.size());
|
addr.resize(coords.size());
|
||||||
|
@ -73,7 +73,7 @@ void ChowLiuTree::add(const Mat& imgDescriptor) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChowLiuTree::add(const vector<Mat>& _imgDescriptors) {
|
void ChowLiuTree::add(const std::vector<Mat>& _imgDescriptors) {
|
||||||
for (size_t i = 0; i < _imgDescriptors.size(); i++) {
|
for (size_t i = 0; i < _imgDescriptors.size(); i++) {
|
||||||
add(_imgDescriptors[i]);
|
add(_imgDescriptors[i]);
|
||||||
}
|
}
|
||||||
@ -164,10 +164,10 @@ cv::Mat ChowLiuTree::buildTree(int root_word, std::list<info> &edges) {
|
|||||||
//independence from a parent node.
|
//independence from a parent node.
|
||||||
|
|
||||||
//find all children and do the same
|
//find all children and do the same
|
||||||
vector<int> nextqs = extractChildren(edges, q);
|
std::vector<int> nextqs = extractChildren(edges, q);
|
||||||
|
|
||||||
int pq = q;
|
int pq = q;
|
||||||
vector<int>::iterator nextq;
|
std::vector<int>::iterator nextq;
|
||||||
for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) {
|
for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) {
|
||||||
recAddToTree(cltree, *nextq, pq, edges);
|
recAddToTree(cltree, *nextq, pq, edges);
|
||||||
}
|
}
|
||||||
@ -186,16 +186,16 @@ void ChowLiuTree::recAddToTree(cv::Mat &cltree, int q, int pq,
|
|||||||
cltree.at<double>(3, q) = CP(q, true, pq, false);
|
cltree.at<double>(3, q) = CP(q, true, pq, false);
|
||||||
|
|
||||||
//find all children and do the same
|
//find all children and do the same
|
||||||
vector<int> nextqs = extractChildren(remaining_edges, q);
|
std::vector<int> nextqs = extractChildren(remaining_edges, q);
|
||||||
|
|
||||||
pq = q;
|
pq = q;
|
||||||
vector<int>::iterator nextq;
|
std::vector<int>::iterator nextq;
|
||||||
for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) {
|
for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) {
|
||||||
recAddToTree(cltree, *nextq, pq, remaining_edges);
|
recAddToTree(cltree, *nextq, pq, remaining_edges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> ChowLiuTree::extractChildren(std::list<info> &remaining_edges, int q) {
|
std::vector<int> ChowLiuTree::extractChildren(std::list<info> &remaining_edges, int q) {
|
||||||
|
|
||||||
std::vector<int> children;
|
std::vector<int> children;
|
||||||
std::list<info>::iterator edge = remaining_edges.begin();
|
std::list<info>::iterator edge = remaining_edges.begin();
|
||||||
@ -225,16 +225,16 @@ double ChowLiuTree::calcMutInfo(int word1, int word2) {
|
|||||||
double accumulation = 0;
|
double accumulation = 0;
|
||||||
|
|
||||||
double P00 = JP(word1, false, word2, false);
|
double P00 = JP(word1, false, word2, false);
|
||||||
if(P00) accumulation += P00 * log(P00 / (P(word1, false)*P(word2, false)));
|
if(P00) accumulation += P00 * std::log(P00 / (P(word1, false)*P(word2, false)));
|
||||||
|
|
||||||
double P01 = JP(word1, false, word2, true);
|
double P01 = JP(word1, false, word2, true);
|
||||||
if(P01) accumulation += P01 * log(P01 / (P(word1, false)*P(word2, true)));
|
if(P01) accumulation += P01 * std::log(P01 / (P(word1, false)*P(word2, true)));
|
||||||
|
|
||||||
double P10 = JP(word1, true, word2, false);
|
double P10 = JP(word1, true, word2, false);
|
||||||
if(P10) accumulation += P10 * log(P10 / (P(word1, true)*P(word2, false)));
|
if(P10) accumulation += P10 * std::log(P10 / (P(word1, true)*P(word2, false)));
|
||||||
|
|
||||||
double P11 = JP(word1, true, word2, true);
|
double P11 = JP(word1, true, word2, true);
|
||||||
if(P11) accumulation += P11 * log(P11 / (P(word1, true)*P(word2, true)));
|
if(P11) accumulation += P11 * std::log(P11 / (P(word1, true)*P(word2, true)));
|
||||||
|
|
||||||
return accumulation;
|
return accumulation;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, Output
|
|||||||
if(_indices.getMat().type() != CV_32SC1)
|
if(_indices.getMat().type() != CV_32SC1)
|
||||||
CV_Error(CV_StsUnsupportedFormat, "cv::sortRowsByIndices only works on integer indices!");
|
CV_Error(CV_StsUnsupportedFormat, "cv::sortRowsByIndices only works on integer indices!");
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
vector<int> indices = _indices.getMat();
|
std::vector<int> indices = _indices.getMat();
|
||||||
_dst.create(src.rows, src.cols, src.type());
|
_dst.create(src.rows, src.cols, src.type());
|
||||||
Mat dst = _dst.getMat();
|
Mat dst = _dst.getMat();
|
||||||
for(size_t idx = 0; idx < indices.size(); idx++) {
|
for(size_t idx = 0; idx < indices.size(); idx++) {
|
||||||
@ -76,7 +76,7 @@ Mat interp1_(const Mat& X_, const Mat& Y_, const Mat& XI)
|
|||||||
{
|
{
|
||||||
int n = XI.rows;
|
int n = XI.rows;
|
||||||
// sort input table
|
// sort input table
|
||||||
vector<int> sort_indices = argsort(X_);
|
std::vector<int> sort_indices = argsort(X_);
|
||||||
|
|
||||||
Mat X = sortMatrixRowsByIndices(X_,sort_indices);
|
Mat X = sortMatrixRowsByIndices(X_,sort_indices);
|
||||||
Mat Y = sortMatrixRowsByIndices(Y_,sort_indices);
|
Mat Y = sortMatrixRowsByIndices(Y_,sort_indices);
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include "opencv2/contrib/hybridtracker.hpp"
|
#include "opencv2/contrib/hybridtracker.hpp"
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
CvMeanShiftTracker::CvMeanShiftTracker(CvMeanShiftTrackerParams _params) : params(_params)
|
CvMeanShiftTracker::CvMeanShiftTracker(CvMeanShiftTrackerParams _params) : params(_params)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
|
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
static inline cv::Point2f centerRect(const cv::Rect& r)
|
static inline cv::Point2f centerRect(const cv::Rect& r)
|
||||||
{
|
{
|
||||||
@ -71,7 +70,7 @@ class cv::DetectionBasedTracker::SeparateDetectionWork
|
|||||||
public:
|
public:
|
||||||
SeparateDetectionWork(cv::DetectionBasedTracker& _detectionBasedTracker, cv::Ptr<DetectionBasedTracker::IDetector> _detector);
|
SeparateDetectionWork(cv::DetectionBasedTracker& _detectionBasedTracker, cv::Ptr<DetectionBasedTracker::IDetector> _detector);
|
||||||
virtual ~SeparateDetectionWork();
|
virtual ~SeparateDetectionWork();
|
||||||
bool communicateWithDetectingThread(const Mat& imageGray, vector<Rect>& rectsWhereRegions);
|
bool communicateWithDetectingThread(const Mat& imageGray, std::vector<Rect>& rectsWhereRegions);
|
||||||
bool run();
|
bool run();
|
||||||
void stop();
|
void stop();
|
||||||
void resetTracking();
|
void resetTracking();
|
||||||
@ -227,7 +226,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
|
|||||||
{
|
{
|
||||||
static double freq = getTickFrequency();
|
static double freq = getTickFrequency();
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- start");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- start");
|
||||||
vector<Rect> objects;
|
std::vector<Rect> objects;
|
||||||
|
|
||||||
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
@ -385,7 +384,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, vector<Rect>& rectsWhereRegions)
|
bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, std::vector<Rect>& rectsWhereRegions)
|
||||||
{
|
{
|
||||||
static double freq = getTickFrequency();
|
static double freq = getTickFrequency();
|
||||||
|
|
||||||
@ -499,7 +498,7 @@ void DetectionBasedTracker::process(const Mat& imageGray)
|
|||||||
|
|
||||||
Mat imageDetect=imageGray;
|
Mat imageDetect=imageGray;
|
||||||
|
|
||||||
vector<Rect> rectsWhereRegions;
|
std::vector<Rect> rectsWhereRegions;
|
||||||
bool shouldHandleResult=false;
|
bool shouldHandleResult=false;
|
||||||
if (!separateDetectionWork.empty()) {
|
if (!separateDetectionWork.empty()) {
|
||||||
shouldHandleResult = separateDetectionWork->communicateWithDetectingThread(imageGray, rectsWhereRegions);
|
shouldHandleResult = separateDetectionWork->communicateWithDetectingThread(imageGray, rectsWhereRegions);
|
||||||
@ -535,7 +534,7 @@ void DetectionBasedTracker::process(const Mat& imageGray)
|
|||||||
}
|
}
|
||||||
LOGI("DetectionBasedTracker::process: tracked objects num==%d", (int)trackedObjects.size());
|
LOGI("DetectionBasedTracker::process: tracked objects num==%d", (int)trackedObjects.size());
|
||||||
|
|
||||||
vector<Rect> detectedObjectsInRegions;
|
std::vector<Rect> detectedObjectsInRegions;
|
||||||
|
|
||||||
LOGD("DetectionBasedTracker::process: rectsWhereRegions.size()=%d", (int)rectsWhereRegions.size());
|
LOGD("DetectionBasedTracker::process: rectsWhereRegions.size()=%d", (int)rectsWhereRegions.size());
|
||||||
for(size_t i=0; i < rectsWhereRegions.size(); i++) {
|
for(size_t i=0; i < rectsWhereRegions.size(); i++) {
|
||||||
@ -610,7 +609,7 @@ void cv::DetectionBasedTracker::resetTracking()
|
|||||||
trackedObjects.clear();
|
trackedObjects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::DetectionBasedTracker::updateTrackedObjects(const vector<Rect>& detectedObjects)
|
void cv::DetectionBasedTracker::updateTrackedObjects(const std::vector<Rect>& detectedObjects)
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
NEW_RECTANGLE=-1,
|
NEW_RECTANGLE=-1,
|
||||||
@ -625,7 +624,7 @@ void cv::DetectionBasedTracker::updateTrackedObjects(const vector<Rect>& detecte
|
|||||||
trackedObjects[i].numDetectedFrames++;
|
trackedObjects[i].numDetectedFrames++;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> correspondence(detectedObjects.size(), NEW_RECTANGLE);
|
std::vector<int> correspondence(detectedObjects.size(), NEW_RECTANGLE);
|
||||||
correspondence.clear();
|
correspondence.clear();
|
||||||
correspondence.resize(detectedObjects.size(), NEW_RECTANGLE);
|
correspondence.resize(detectedObjects.size(), NEW_RECTANGLE);
|
||||||
|
|
||||||
@ -831,7 +830,7 @@ Rect cv::DetectionBasedTracker::calcTrackedObjectPositionToShow(int i, ObjectSta
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::DetectionBasedTracker::detectInRegion(const Mat& img, const Rect& r, vector<Rect>& detectedObjectsInRegions)
|
void cv::DetectionBasedTracker::detectInRegion(const Mat& img, const Rect& r, std::vector<Rect>& detectedObjectsInRegions)
|
||||||
{
|
{
|
||||||
Rect r0(Point(), img.size());
|
Rect r0(Point(), img.size());
|
||||||
Rect r1 = scale_rect(r, innerParameters.coeffTrackingWindowSize);
|
Rect r1 = scale_rect(r, innerParameters.coeffTrackingWindowSize);
|
||||||
@ -844,7 +843,7 @@ void cv::DetectionBasedTracker::detectInRegion(const Mat& img, const Rect& r, ve
|
|||||||
|
|
||||||
int d = cvRound(std::min(r.width, r.height) * innerParameters.coeffObjectSizeToTrack);
|
int d = cvRound(std::min(r.width, r.height) * innerParameters.coeffObjectSizeToTrack);
|
||||||
|
|
||||||
vector<Rect> tmpobjects;
|
std::vector<Rect> tmpobjects;
|
||||||
|
|
||||||
Mat img1(img, r1);//subimage for rectangle -- without data copying
|
Mat img1(img, r1);//subimage for rectangle -- without data copying
|
||||||
LOGD("DetectionBasedTracker::detectInRegion: img1.size()=%d x %d, d=%d",
|
LOGD("DetectionBasedTracker::detectInRegion: img1.size()=%d x %d, d=%d",
|
||||||
|
@ -21,11 +21,9 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
using std::set;
|
|
||||||
|
|
||||||
// Reads a sequence from a FileNode::SEQ with type _Tp into a result vector.
|
// Reads a sequence from a FileNode::SEQ with type _Tp into a result vector.
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline void readFileNodeList(const FileNode& fn, vector<_Tp>& result) {
|
inline void readFileNodeList(const FileNode& fn, std::vector<_Tp>& result) {
|
||||||
if (fn.type() == FileNode::SEQ) {
|
if (fn.type() == FileNode::SEQ) {
|
||||||
for (FileNodeIterator it = fn.begin(); it != fn.end();) {
|
for (FileNodeIterator it = fn.begin(); it != fn.end();) {
|
||||||
_Tp item;
|
_Tp item;
|
||||||
@ -37,10 +35,10 @@ inline void readFileNodeList(const FileNode& fn, vector<_Tp>& result) {
|
|||||||
|
|
||||||
// Writes the a list of given items to a cv::FileStorage.
|
// Writes the a list of given items to a cv::FileStorage.
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline void writeFileNodeList(FileStorage& fs, const string& name,
|
inline void writeFileNodeList(FileStorage& fs, const std::string& name,
|
||||||
const vector<_Tp>& items) {
|
const std::vector<_Tp>& items) {
|
||||||
// typedefs
|
// typedefs
|
||||||
typedef typename vector<_Tp>::const_iterator constVecIterator;
|
typedef typename std::vector<_Tp>::const_iterator constVecIterator;
|
||||||
// write the elements in item to fs
|
// write the elements in item to fs
|
||||||
fs << name << "[";
|
fs << name << "[";
|
||||||
for (constVecIterator it = items.begin(); it != items.end(); ++it) {
|
for (constVecIterator it = items.begin(); it != items.end(); ++it) {
|
||||||
@ -52,7 +50,7 @@ inline void writeFileNodeList(FileStorage& fs, const string& name,
|
|||||||
static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
|
static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
|
||||||
// make sure the input data is a vector of matrices or vector of vector
|
// make sure the input data is a vector of matrices or vector of vector
|
||||||
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
|
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
|
||||||
string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >).";
|
std::string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// number of samples
|
// number of samples
|
||||||
@ -68,7 +66,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
|
|||||||
for(unsigned int i = 0; i < n; i++) {
|
for(unsigned int i = 0; i < n; i++) {
|
||||||
// make sure data can be reshaped, throw exception if not!
|
// make sure data can be reshaped, throw exception if not!
|
||||||
if(src.getMat(i).total() != d) {
|
if(src.getMat(i).total() != d) {
|
||||||
string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total());
|
std::string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// get a hold of the current row
|
// get a hold of the current row
|
||||||
@ -86,13 +84,13 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
|
|||||||
|
|
||||||
// Removes duplicate elements in a given vector.
|
// Removes duplicate elements in a given vector.
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
|
inline std::vector<_Tp> remove_dups(const std::vector<_Tp>& src) {
|
||||||
typedef typename set<_Tp>::const_iterator constSetIterator;
|
typedef typename std::set<_Tp>::const_iterator constSetIterator;
|
||||||
typedef typename vector<_Tp>::const_iterator constVecIterator;
|
typedef typename std::vector<_Tp>::const_iterator constVecIterator;
|
||||||
set<_Tp> set_elems;
|
std::set<_Tp> set_elems;
|
||||||
for (constVecIterator it = src.begin(); it != src.end(); ++it)
|
for (constVecIterator it = src.begin(); it != src.end(); ++it)
|
||||||
set_elems.insert(*it);
|
set_elems.insert(*it);
|
||||||
vector<_Tp> elems;
|
std::vector<_Tp> elems;
|
||||||
for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it)
|
for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it)
|
||||||
elems.push_back(*it);
|
elems.push_back(*it);
|
||||||
return elems;
|
return elems;
|
||||||
@ -106,7 +104,7 @@ class Eigenfaces : public FaceRecognizer
|
|||||||
private:
|
private:
|
||||||
int _num_components;
|
int _num_components;
|
||||||
double _threshold;
|
double _threshold;
|
||||||
vector<Mat> _projections;
|
std::vector<Mat> _projections;
|
||||||
Mat _labels;
|
Mat _labels;
|
||||||
Mat _eigenvectors;
|
Mat _eigenvectors;
|
||||||
Mat _eigenvalues;
|
Mat _eigenvalues;
|
||||||
@ -162,7 +160,7 @@ private:
|
|||||||
Mat _eigenvectors;
|
Mat _eigenvectors;
|
||||||
Mat _eigenvalues;
|
Mat _eigenvalues;
|
||||||
Mat _mean;
|
Mat _mean;
|
||||||
vector<Mat> _projections;
|
std::vector<Mat> _projections;
|
||||||
Mat _labels;
|
Mat _labels;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -220,7 +218,7 @@ private:
|
|||||||
int _neighbors;
|
int _neighbors;
|
||||||
double _threshold;
|
double _threshold;
|
||||||
|
|
||||||
vector<Mat> _histograms;
|
std::vector<Mat> _histograms;
|
||||||
Mat _labels;
|
Mat _labels;
|
||||||
|
|
||||||
// Computes a LBPH model with images in src and
|
// Computes a LBPH model with images in src and
|
||||||
@ -307,11 +305,11 @@ void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str());
|
std::string error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str());
|
||||||
CV_Error(CV_StsNotImplemented, error_msg);
|
CV_Error(CV_StsNotImplemented, error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceRecognizer::save(const string& filename) const {
|
void FaceRecognizer::save(const std::string& filename) const {
|
||||||
FileStorage fs(filename, FileStorage::WRITE);
|
FileStorage fs(filename, FileStorage::WRITE);
|
||||||
if (!fs.isOpened())
|
if (!fs.isOpened())
|
||||||
CV_Error(CV_StsError, "File can't be opened for writing!");
|
CV_Error(CV_StsError, "File can't be opened for writing!");
|
||||||
@ -319,7 +317,7 @@ void FaceRecognizer::save(const string& filename) const {
|
|||||||
fs.release();
|
fs.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceRecognizer::load(const string& filename) {
|
void FaceRecognizer::load(const std::string& filename) {
|
||||||
FileStorage fs(filename, FileStorage::READ);
|
FileStorage fs(filename, FileStorage::READ);
|
||||||
if (!fs.isOpened())
|
if (!fs.isOpened())
|
||||||
CV_Error(CV_StsError, "File can't be opened for writing!");
|
CV_Error(CV_StsError, "File can't be opened for writing!");
|
||||||
@ -332,17 +330,17 @@ void FaceRecognizer::load(const string& filename) {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
|
void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
|
||||||
if(_src.total() == 0) {
|
if(_src.total() == 0) {
|
||||||
string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
|
std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
} else if(_local_labels.getMat().type() != CV_32SC1) {
|
} else if(_local_labels.getMat().type() != CV_32SC1) {
|
||||||
string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type());
|
std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// make sure data has correct size
|
// make sure data has correct size
|
||||||
if(_src.total() > 1) {
|
if(_src.total() > 1) {
|
||||||
for(int i = 1; i < static_cast<int>(_src.total()); i++) {
|
for(int i = 1; i < static_cast<int>(_src.total()); i++) {
|
||||||
if(_src.getMat(i-1).total() != _src.getMat(i).total()) {
|
if(_src.getMat(i-1).total() != _src.getMat(i).total()) {
|
||||||
string error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total());
|
std::string error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total());
|
||||||
CV_Error(CV_StsUnsupportedFormat, error_message);
|
CV_Error(CV_StsUnsupportedFormat, error_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -356,7 +354,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
|
|||||||
int n = data.rows;
|
int n = data.rows;
|
||||||
// assert there are as much samples as labels
|
// assert there are as much samples as labels
|
||||||
if(static_cast<int>(labels.total()) != n) {
|
if(static_cast<int>(labels.total()) != n) {
|
||||||
string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total());
|
std::string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// clear existing model data
|
// clear existing model data
|
||||||
@ -387,11 +385,11 @@ void Eigenfaces::predict(InputArray _src, int &minClass, double &minDist) const
|
|||||||
// make sure the user is passing correct data
|
// make sure the user is passing correct data
|
||||||
if(_projections.empty()) {
|
if(_projections.empty()) {
|
||||||
// throw error if no data (or simply return -1?)
|
// throw error if no data (or simply return -1?)
|
||||||
string error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?";
|
std::string error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?";
|
||||||
CV_Error(CV_StsError, error_message);
|
CV_Error(CV_StsError, error_message);
|
||||||
} else if(_eigenvectors.rows != static_cast<int>(src.total())) {
|
} else if(_eigenvectors.rows != static_cast<int>(src.total())) {
|
||||||
// check data alignment just for clearer exception messages
|
// check data alignment just for clearer exception messages
|
||||||
string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
|
std::string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// project into PCA subspace
|
// project into PCA subspace
|
||||||
@ -441,17 +439,17 @@ void Eigenfaces::save(FileStorage& fs) const {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
|
void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
|
||||||
if(src.total() == 0) {
|
if(src.total() == 0) {
|
||||||
string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
|
std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
} else if(_lbls.getMat().type() != CV_32SC1) {
|
} else if(_lbls.getMat().type() != CV_32SC1) {
|
||||||
string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type());
|
std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// make sure data has correct size
|
// make sure data has correct size
|
||||||
if(src.total() > 1) {
|
if(src.total() > 1) {
|
||||||
for(int i = 1; i < static_cast<int>(src.total()); i++) {
|
for(int i = 1; i < static_cast<int>(src.total()); i++) {
|
||||||
if(src.getMat(i-1).total() != src.getMat(i).total()) {
|
if(src.getMat(i-1).total() != src.getMat(i).total()) {
|
||||||
string error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total());
|
std::string error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total());
|
||||||
CV_Error(CV_StsUnsupportedFormat, error_message);
|
CV_Error(CV_StsUnsupportedFormat, error_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -463,17 +461,17 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
|
|||||||
int N = data.rows;
|
int N = data.rows;
|
||||||
// make sure labels are passed in correct shape
|
// make sure labels are passed in correct shape
|
||||||
if(labels.total() != (size_t) N) {
|
if(labels.total() != (size_t) N) {
|
||||||
string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total());
|
std::string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
} else if(labels.rows != 1 && labels.cols != 1) {
|
} else if(labels.rows != 1 && labels.cols != 1) {
|
||||||
string error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols);
|
std::string error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols);
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// clear existing model data
|
// clear existing model data
|
||||||
_labels.release();
|
_labels.release();
|
||||||
_projections.clear();
|
_projections.clear();
|
||||||
// safely copy from cv::Mat to std::vector
|
// safely copy from cv::Mat to std::vector
|
||||||
vector<int> ll;
|
std::vector<int> ll;
|
||||||
for(unsigned int i = 0; i < labels.total(); i++) {
|
for(unsigned int i = 0; i < labels.total(); i++) {
|
||||||
ll.push_back(labels.at<int>(i));
|
ll.push_back(labels.at<int>(i));
|
||||||
}
|
}
|
||||||
@ -507,10 +505,10 @@ void Fisherfaces::predict(InputArray _src, int &minClass, double &minDist) const
|
|||||||
// check data alignment just for clearer exception messages
|
// check data alignment just for clearer exception messages
|
||||||
if(_projections.empty()) {
|
if(_projections.empty()) {
|
||||||
// throw error if no data (or simply return -1?)
|
// throw error if no data (or simply return -1?)
|
||||||
string error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?";
|
std::string error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?";
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
} else if(src.total() != (size_t) _eigenvectors.rows) {
|
} else if(src.total() != (size_t) _eigenvectors.rows) {
|
||||||
string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
|
std::string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// project into LDA subspace
|
// project into LDA subspace
|
||||||
@ -642,7 +640,7 @@ static void elbp(InputArray src, OutputArray dst, int radius, int neighbors)
|
|||||||
case CV_32FC1: elbp_<float>(src,dst, radius, neighbors); break;
|
case CV_32FC1: elbp_<float>(src,dst, radius, neighbors); break;
|
||||||
case CV_64FC1: elbp_<double>(src,dst, radius, neighbors); break;
|
case CV_64FC1: elbp_<double>(src,dst, radius, neighbors); break;
|
||||||
default:
|
default:
|
||||||
string error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type);
|
std::string error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type);
|
||||||
CV_Error(CV_StsNotImplemented, error_msg);
|
CV_Error(CV_StsNotImplemented, error_msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -770,24 +768,24 @@ void LBPH::update(InputArrayOfArrays _in_src, InputArray _in_labels) {
|
|||||||
|
|
||||||
void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) {
|
void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) {
|
||||||
if(_in_src.kind() != _InputArray::STD_VECTOR_MAT && _in_src.kind() != _InputArray::STD_VECTOR_VECTOR) {
|
if(_in_src.kind() != _InputArray::STD_VECTOR_MAT && _in_src.kind() != _InputArray::STD_VECTOR_VECTOR) {
|
||||||
string error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >).";
|
std::string error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
if(_in_src.total() == 0) {
|
if(_in_src.total() == 0) {
|
||||||
string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
|
std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
|
||||||
CV_Error(CV_StsUnsupportedFormat, error_message);
|
CV_Error(CV_StsUnsupportedFormat, error_message);
|
||||||
} else if(_in_labels.getMat().type() != CV_32SC1) {
|
} else if(_in_labels.getMat().type() != CV_32SC1) {
|
||||||
string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type());
|
std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type());
|
||||||
CV_Error(CV_StsUnsupportedFormat, error_message);
|
CV_Error(CV_StsUnsupportedFormat, error_message);
|
||||||
}
|
}
|
||||||
// get the vector of matrices
|
// get the vector of matrices
|
||||||
vector<Mat> src;
|
std::vector<Mat> src;
|
||||||
_in_src.getMatVector(src);
|
_in_src.getMatVector(src);
|
||||||
// get the label matrix
|
// get the label matrix
|
||||||
Mat labels = _in_labels.getMat();
|
Mat labels = _in_labels.getMat();
|
||||||
// check if data is well- aligned
|
// check if data is well- aligned
|
||||||
if(labels.total() != src.size()) {
|
if(labels.total() != src.size()) {
|
||||||
string error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total());
|
std::string error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// if this model should be trained without preserving old data, delete old model data
|
// if this model should be trained without preserving old data, delete old model data
|
||||||
@ -818,7 +816,7 @@ void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserv
|
|||||||
void LBPH::predict(InputArray _src, int &minClass, double &minDist) const {
|
void LBPH::predict(InputArray _src, int &minClass, double &minDist) const {
|
||||||
if(_histograms.empty()) {
|
if(_histograms.empty()) {
|
||||||
// throw error if no data (or simply return -1?)
|
// throw error if no data (or simply return -1?)
|
||||||
string error_message = "This LBPH model is not computed yet. Did you call the train method?";
|
std::string error_message = "This LBPH model is not computed yet. Did you call the train method?";
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
|
@ -98,8 +98,8 @@ Rect CvFeatureTracker::updateTrackingWindow(Mat image)
|
|||||||
Rect CvFeatureTracker::updateTrackingWindowWithSIFT(Mat image)
|
Rect CvFeatureTracker::updateTrackingWindowWithSIFT(Mat image)
|
||||||
{
|
{
|
||||||
ittr++;
|
ittr++;
|
||||||
vector<KeyPoint> prev_keypoints, curr_keypoints;
|
std::vector<KeyPoint> prev_keypoints, curr_keypoints;
|
||||||
vector<Point2f> prev_keys, curr_keys;
|
std::vector<Point2f> prev_keys, curr_keys;
|
||||||
Mat prev_desc, curr_desc;
|
Mat prev_desc, curr_desc;
|
||||||
|
|
||||||
Rect window = prev_trackwindow;
|
Rect window = prev_trackwindow;
|
||||||
@ -149,8 +149,8 @@ Rect CvFeatureTracker::updateTrackingWindowWithFlow(Mat image)
|
|||||||
Size subPixWinSize(10,10), winSize(31,31);
|
Size subPixWinSize(10,10), winSize(31,31);
|
||||||
Mat image_bw;
|
Mat image_bw;
|
||||||
TermCriteria termcrit(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, 0.03);
|
TermCriteria termcrit(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, 0.03);
|
||||||
vector<uchar> status;
|
std::vector<uchar> status;
|
||||||
vector<float> err;
|
std::vector<float> err;
|
||||||
|
|
||||||
cvtColor(image, image_bw, CV_BGR2GRAY);
|
cvtColor(image, image_bw, CV_BGR2GRAY);
|
||||||
cvtColor(prev_image, prev_image_bw, CV_BGR2GRAY);
|
cvtColor(prev_image, prev_image_bw, CV_BGR2GRAY);
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include "opencv2/contrib/hybridtracker.hpp"
|
#include "opencv2/contrib/hybridtracker.hpp"
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
CvHybridTrackerParams::CvHybridTrackerParams(float _ft_tracker_weight, float _ms_tracker_weight,
|
CvHybridTrackerParams::CvHybridTrackerParams(float _ft_tracker_weight, float _ms_tracker_weight,
|
||||||
CvFeatureTrackerParams _ft_params,
|
CvFeatureTrackerParams _ft_params,
|
||||||
@ -83,7 +82,7 @@ CvHybridTracker::~CvHybridTracker() {
|
|||||||
inline float CvHybridTracker::getL2Norm(Point2f p1, Point2f p2) {
|
inline float CvHybridTracker::getL2Norm(Point2f p1, Point2f p2) {
|
||||||
float distance = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y
|
float distance = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y
|
||||||
- p2.y);
|
- p2.y);
|
||||||
return sqrt(distance);
|
return std::sqrt(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat CvHybridTracker::getDistanceProjection(Mat image, Point2f center) {
|
Mat CvHybridTracker::getDistanceProjection(Mat image, Point2f center) {
|
||||||
|
@ -193,7 +193,7 @@ bool ImageLogPolProjection::_initLogRetinaSampling(const double reductionFactor,
|
|||||||
//double rlim=1.0/reductionFactor*(minDimension/2.0+samplingStrenght);
|
//double rlim=1.0/reductionFactor*(minDimension/2.0+samplingStrenght);
|
||||||
|
|
||||||
// input frame dimensions INdependent log sampling:
|
// input frame dimensions INdependent log sampling:
|
||||||
_azero=(1.0+reductionFactor*sqrt(samplingStrenght))/(reductionFactor*reductionFactor*samplingStrenght-1.0);
|
_azero=(1.0+reductionFactor*std::sqrt(samplingStrenght))/(reductionFactor*reductionFactor*samplingStrenght-1.0);
|
||||||
_alim=(1.0+_azero)/reductionFactor;
|
_alim=(1.0+_azero)/reductionFactor;
|
||||||
#ifdef IMAGELOGPOLPROJECTION_DEBUG
|
#ifdef IMAGELOGPOLPROJECTION_DEBUG
|
||||||
std::cout<<"ImageLogPolProjection::initLogRetinaSampling: rlim= "<<rlim<<std::endl;
|
std::cout<<"ImageLogPolProjection::initLogRetinaSampling: rlim= "<<rlim<<std::endl;
|
||||||
@ -223,10 +223,10 @@ bool ImageLogPolProjection::_initLogRetinaSampling(const double reductionFactor,
|
|||||||
// get the pixel position in the original picture
|
// get the pixel position in the original picture
|
||||||
|
|
||||||
// -> input frame dimensions dependent log sampling:
|
// -> input frame dimensions dependent log sampling:
|
||||||
//double scale = samplingStrenght/(rlim-(double)sqrt(idRow*idRow+idColumn*idColumn));
|
//double scale = samplingStrenght/(rlim-(double)std::sqrt(idRow*idRow+idColumn*idColumn));
|
||||||
|
|
||||||
// -> input frame dimensions INdependent log sampling:
|
// -> input frame dimensions INdependent log sampling:
|
||||||
double scale=getOriginalRadiusLength((double)sqrt((double)(idRow*idRow+idColumn*idColumn)));
|
double scale=getOriginalRadiusLength((double)std::sqrt((double)(idRow*idRow+idColumn*idColumn)));
|
||||||
#ifdef IMAGELOGPOLPROJECTION_DEBUG
|
#ifdef IMAGELOGPOLPROJECTION_DEBUG
|
||||||
std::cout<<"ImageLogPolProjection::initLogRetinaSampling: scale= "<<scale<<std::endl;
|
std::cout<<"ImageLogPolProjection::initLogRetinaSampling: scale= "<<scale<<std::endl;
|
||||||
std::cout<<"ImageLogPolProjection::initLogRetinaSampling: scale2= "<<scale2<<std::endl;
|
std::cout<<"ImageLogPolProjection::initLogRetinaSampling: scale2= "<<scale2<<std::endl;
|
||||||
@ -243,7 +243,7 @@ bool ImageLogPolProjection::_initLogRetinaSampling(const double reductionFactor,
|
|||||||
|
|
||||||
// manage border effects
|
// manage border effects
|
||||||
double length=u*u+v*v;
|
double length=u*u+v*v;
|
||||||
double radiusRatio=sqrt(rMax/length);
|
double radiusRatio=std::sqrt(rMax/length);
|
||||||
|
|
||||||
#ifdef IMAGELOGPOLPROJECTION_DEBUG
|
#ifdef IMAGELOGPOLPROJECTION_DEBUG
|
||||||
std::cout<<"ImageLogPolProjection::(inputH, inputW)="<<halfInputRows<<", "<<halfInputColumns<<", Rmax2="<<rMax<<std::endl;
|
std::cout<<"ImageLogPolProjection::(inputH, inputW)="<<halfInputRows<<", "<<halfInputColumns<<", Rmax2="<<rMax<<std::endl;
|
||||||
@ -362,14 +362,14 @@ bool ImageLogPolProjection::_initLogPolarCortexSampling(const double reductionFa
|
|||||||
|
|
||||||
//std::cout<<"ImageLogPolProjection::Starting cortex projection"<<std::endl;
|
//std::cout<<"ImageLogPolProjection::Starting cortex projection"<<std::endl;
|
||||||
// compute transformation, get theta and Radius in reagrd of the output sampled pixel
|
// compute transformation, get theta and Radius in reagrd of the output sampled pixel
|
||||||
double diagonalLenght=sqrt((double)(_outputNBcolumns*_outputNBcolumns+_outputNBrows*_outputNBrows));
|
double diagonalLenght=std::sqrt((double)(_outputNBcolumns*_outputNBcolumns+_outputNBrows*_outputNBrows));
|
||||||
for (unsigned int radiusIndex=0;radiusIndex<_outputNBcolumns;++radiusIndex)
|
for (unsigned int radiusIndex=0;radiusIndex<_outputNBcolumns;++radiusIndex)
|
||||||
for(unsigned int orientationIndex=0;orientationIndex<_outputNBrows;++orientationIndex)
|
for(unsigned int orientationIndex=0;orientationIndex<_outputNBrows;++orientationIndex)
|
||||||
{
|
{
|
||||||
double x=1.0+sinh(radiusAxis[radiusIndex])*cos(orientationAxis[orientationIndex]);
|
double x=1.0+sinh(radiusAxis[radiusIndex])*cos(orientationAxis[orientationIndex]);
|
||||||
double y=sinh(radiusAxis[radiusIndex])*sin(orientationAxis[orientationIndex]);
|
double y=sinh(radiusAxis[radiusIndex])*sin(orientationAxis[orientationIndex]);
|
||||||
// get the input picture coordinate
|
// get the input picture coordinate
|
||||||
double R=diagonalLenght*sqrt(x*x+y*y)/(5.0+sqrt(x*x+y*y));
|
double R=diagonalLenght*std::sqrt(x*x+y*y)/(5.0+std::sqrt(x*x+y*y));
|
||||||
double theta=atan2(y,x);
|
double theta=atan2(y,x);
|
||||||
// convert input polar coord into cartesian/C compatble coordinate
|
// convert input polar coord into cartesian/C compatble coordinate
|
||||||
unsigned int columnIndex=(unsigned int)(cos(theta)*R)+halfInputColumns;
|
unsigned int columnIndex=(unsigned int)(cos(theta)*R)+halfInputColumns;
|
||||||
|
@ -24,20 +24,15 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::set;
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
// Removes duplicate elements in a given vector.
|
// Removes duplicate elements in a given vector.
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
|
inline std::vector<_Tp> remove_dups(const std::vector<_Tp>& src) {
|
||||||
typedef typename set<_Tp>::const_iterator constSetIterator;
|
typedef typename std::set<_Tp>::const_iterator constSetIterator;
|
||||||
typedef typename vector<_Tp>::const_iterator constVecIterator;
|
typedef typename std::vector<_Tp>::const_iterator constVecIterator;
|
||||||
set<_Tp> set_elems;
|
std::set<_Tp> set_elems;
|
||||||
for (constVecIterator it = src.begin(); it != src.end(); ++it)
|
for (constVecIterator it = src.begin(); it != src.end(); ++it)
|
||||||
set_elems.insert(*it);
|
set_elems.insert(*it);
|
||||||
vector<_Tp> elems;
|
std::vector<_Tp> elems;
|
||||||
for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it)
|
for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it)
|
||||||
elems.push_back(*it);
|
elems.push_back(*it);
|
||||||
return elems;
|
return elems;
|
||||||
@ -47,7 +42,7 @@ static Mat argsort(InputArray _src, bool ascending=true)
|
|||||||
{
|
{
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
if (src.rows != 1 && src.cols != 1) {
|
if (src.rows != 1 && src.cols != 1) {
|
||||||
string error_message = "Wrong shape of input matrix! Expected a matrix with one row or column.";
|
std::string error_message = "Wrong shape of input matrix! Expected a matrix with one row or column.";
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
int flags = CV_SORT_EVERY_ROW+(ascending ? CV_SORT_ASCENDING : CV_SORT_DESCENDING);
|
int flags = CV_SORT_EVERY_ROW+(ascending ? CV_SORT_ASCENDING : CV_SORT_DESCENDING);
|
||||||
@ -59,7 +54,7 @@ static Mat argsort(InputArray _src, bool ascending=true)
|
|||||||
static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
|
static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
|
||||||
// make sure the input data is a vector of matrices or vector of vector
|
// make sure the input data is a vector of matrices or vector of vector
|
||||||
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
|
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
|
||||||
string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >).";
|
std::string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// number of samples
|
// number of samples
|
||||||
@ -75,7 +70,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
|
|||||||
for(int i = 0; i < (int)n; i++) {
|
for(int i = 0; i < (int)n; i++) {
|
||||||
// make sure data can be reshaped, throw exception if not!
|
// make sure data can be reshaped, throw exception if not!
|
||||||
if(src.getMat(i).total() != d) {
|
if(src.getMat(i).total() != d) {
|
||||||
string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total());
|
std::string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// get a hold of the current row
|
// get a hold of the current row
|
||||||
@ -95,7 +90,7 @@ static void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, Out
|
|||||||
CV_Error(CV_StsUnsupportedFormat, "cv::sortColumnsByIndices only works on integer indices!");
|
CV_Error(CV_StsUnsupportedFormat, "cv::sortColumnsByIndices only works on integer indices!");
|
||||||
}
|
}
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
vector<int> indices = _indices.getMat();
|
std::vector<int> indices = _indices.getMat();
|
||||||
_dst.create(src.rows, src.cols, src.type());
|
_dst.create(src.rows, src.cols, src.type());
|
||||||
Mat dst = _dst.getMat();
|
Mat dst = _dst.getMat();
|
||||||
for(size_t idx = 0; idx < indices.size(); idx++) {
|
for(size_t idx = 0; idx < indices.size(); idx++) {
|
||||||
@ -183,12 +178,12 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src) {
|
|||||||
int d = src.cols;
|
int d = src.cols;
|
||||||
// make sure the data has the correct shape
|
// make sure the data has the correct shape
|
||||||
if(W.rows != d) {
|
if(W.rows != d) {
|
||||||
string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
|
std::string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// make sure mean is correct if not empty
|
// make sure mean is correct if not empty
|
||||||
if(!mean.empty() && (mean.total() != (size_t) d)) {
|
if(!mean.empty() && (mean.total() != (size_t) d)) {
|
||||||
string error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total());
|
std::string error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// create temporary matrices
|
// create temporary matrices
|
||||||
@ -221,12 +216,12 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src)
|
|||||||
int d = src.cols;
|
int d = src.cols;
|
||||||
// make sure the data has the correct shape
|
// make sure the data has the correct shape
|
||||||
if(W.cols != d) {
|
if(W.cols != d) {
|
||||||
string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
|
std::string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// make sure mean is correct if not empty
|
// make sure mean is correct if not empty
|
||||||
if(!mean.empty() && (mean.total() != (size_t) W.rows)) {
|
if(!mean.empty() && (mean.total() != (size_t) W.rows)) {
|
||||||
string error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total());
|
std::string error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// initalize temporary matrices
|
// initalize temporary matrices
|
||||||
@ -330,7 +325,7 @@ private:
|
|||||||
int n1 = nn - 1;
|
int n1 = nn - 1;
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int high = nn - 1;
|
int high = nn - 1;
|
||||||
double eps = pow(2.0, -52.0);
|
double eps = std::pow(2.0, -52.0);
|
||||||
double exshift = 0.0;
|
double exshift = 0.0;
|
||||||
double p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y;
|
double p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y;
|
||||||
|
|
||||||
@ -342,7 +337,7 @@ private:
|
|||||||
d[i] = H[i][i];
|
d[i] = H[i][i];
|
||||||
e[i] = 0.0;
|
e[i] = 0.0;
|
||||||
}
|
}
|
||||||
for (int j = max(i - 1, 0); j < nn; j++) {
|
for (int j = std::max(i - 1, 0); j < nn; j++) {
|
||||||
norm = norm + std::abs(H[i][j]);
|
norm = norm + std::abs(H[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,7 +375,7 @@ private:
|
|||||||
w = H[n1][n1 - 1] * H[n1 - 1][n1];
|
w = H[n1][n1 - 1] * H[n1 - 1][n1];
|
||||||
p = (H[n1 - 1][n1 - 1] - H[n1][n1]) / 2.0;
|
p = (H[n1 - 1][n1 - 1] - H[n1][n1]) / 2.0;
|
||||||
q = p * p + w;
|
q = p * p + w;
|
||||||
z = sqrt(std::abs(q));
|
z = std::sqrt(std::abs(q));
|
||||||
H[n1][n1] = H[n1][n1] + exshift;
|
H[n1][n1] = H[n1][n1] + exshift;
|
||||||
H[n1 - 1][n1 - 1] = H[n1 - 1][n1 - 1] + exshift;
|
H[n1 - 1][n1 - 1] = H[n1 - 1][n1 - 1] + exshift;
|
||||||
x = H[n1][n1];
|
x = H[n1][n1];
|
||||||
@ -404,7 +399,7 @@ private:
|
|||||||
s = std::abs(x) + std::abs(z);
|
s = std::abs(x) + std::abs(z);
|
||||||
p = x / s;
|
p = x / s;
|
||||||
q = z / s;
|
q = z / s;
|
||||||
r = sqrt(p * p + q * q);
|
r = std::sqrt(p * p + q * q);
|
||||||
p = p / r;
|
p = p / r;
|
||||||
q = q / r;
|
q = q / r;
|
||||||
|
|
||||||
@ -475,7 +470,7 @@ private:
|
|||||||
s = (y - x) / 2.0;
|
s = (y - x) / 2.0;
|
||||||
s = s * s + w;
|
s = s * s + w;
|
||||||
if (s > 0) {
|
if (s > 0) {
|
||||||
s = sqrt(s);
|
s = std::sqrt(s);
|
||||||
if (y < x) {
|
if (y < x) {
|
||||||
s = -s;
|
s = -s;
|
||||||
}
|
}
|
||||||
@ -539,7 +534,7 @@ private:
|
|||||||
if (x == 0.0) {
|
if (x == 0.0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s = sqrt(p * p + q * q + r * r);
|
s = std::sqrt(p * p + q * q + r * r);
|
||||||
if (p < 0) {
|
if (p < 0) {
|
||||||
s = -s;
|
s = -s;
|
||||||
}
|
}
|
||||||
@ -570,7 +565,7 @@ private:
|
|||||||
|
|
||||||
// Column modification
|
// Column modification
|
||||||
|
|
||||||
for (int i = 0; i <= min(n1, k + 3); i++) {
|
for (int i = 0; i <= std::min(n1, k + 3); i++) {
|
||||||
p = x * H[i][k] + y * H[i][k + 1];
|
p = x * H[i][k] + y * H[i][k + 1];
|
||||||
if (notlast) {
|
if (notlast) {
|
||||||
p = p + z * H[i][k + 2];
|
p = p + z * H[i][k + 2];
|
||||||
@ -721,7 +716,7 @@ private:
|
|||||||
|
|
||||||
// Overflow control
|
// Overflow control
|
||||||
|
|
||||||
t = max(std::abs(H[i][n1 - 1]), std::abs(H[i][n1]));
|
t = std::max(std::abs(H[i][n1 - 1]), std::abs(H[i][n1]));
|
||||||
if ((eps * t) * t > 1) {
|
if ((eps * t) * t > 1) {
|
||||||
for (int j = i; j <= n1; j++) {
|
for (int j = i; j <= n1; j++) {
|
||||||
H[j][n1 - 1] = H[j][n1 - 1] / t;
|
H[j][n1 - 1] = H[j][n1 - 1] / t;
|
||||||
@ -748,7 +743,7 @@ private:
|
|||||||
for (int j = nn - 1; j >= low; j--) {
|
for (int j = nn - 1; j >= low; j--) {
|
||||||
for (int i = low; i <= high; i++) {
|
for (int i = low; i <= high; i++) {
|
||||||
z = 0.0;
|
z = 0.0;
|
||||||
for (int k = low; k <= min(j, high); k++) {
|
for (int k = low; k <= std::min(j, high); k++) {
|
||||||
z = z + V[i][k] * H[k][j];
|
z = z + V[i][k] * H[k][j];
|
||||||
}
|
}
|
||||||
V[i][j] = z;
|
V[i][j] = z;
|
||||||
@ -782,7 +777,7 @@ private:
|
|||||||
ort[i] = H[i][m - 1] / scale;
|
ort[i] = H[i][m - 1] / scale;
|
||||||
h += ort[i] * ort[i];
|
h += ort[i] * ort[i];
|
||||||
}
|
}
|
||||||
double g = sqrt(h);
|
double g = std::sqrt(h);
|
||||||
if (ort[m] > 0) {
|
if (ort[m] > 0) {
|
||||||
g = -g;
|
g = -g;
|
||||||
}
|
}
|
||||||
@ -941,7 +936,7 @@ public:
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Linear Discriminant Analysis implementation
|
// Linear Discriminant Analysis implementation
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void LDA::save(const string& filename) const {
|
void LDA::save(const std::string& filename) const {
|
||||||
FileStorage fs(filename, FileStorage::WRITE);
|
FileStorage fs(filename, FileStorage::WRITE);
|
||||||
if (!fs.isOpened()) {
|
if (!fs.isOpened()) {
|
||||||
CV_Error(CV_StsError, "File can't be opened for writing!");
|
CV_Error(CV_StsError, "File can't be opened for writing!");
|
||||||
@ -951,7 +946,7 @@ void LDA::save(const string& filename) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deserializes this object from a given filename.
|
// Deserializes this object from a given filename.
|
||||||
void LDA::load(const string& filename) {
|
void LDA::load(const std::string& filename) {
|
||||||
FileStorage fs(filename, FileStorage::READ);
|
FileStorage fs(filename, FileStorage::READ);
|
||||||
if (!fs.isOpened())
|
if (!fs.isOpened())
|
||||||
CV_Error(CV_StsError, "File can't be opened for writing!");
|
CV_Error(CV_StsError, "File can't be opened for writing!");
|
||||||
@ -978,7 +973,7 @@ void LDA::load(const FileStorage& fs) {
|
|||||||
void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
|
void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
|
||||||
// get data
|
// get data
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
vector<int> labels;
|
std::vector<int> labels;
|
||||||
// safely copy the labels
|
// safely copy the labels
|
||||||
{
|
{
|
||||||
Mat tmp = _lbls.getMat();
|
Mat tmp = _lbls.getMat();
|
||||||
@ -991,9 +986,9 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
|
|||||||
// ensure working matrix is double precision
|
// ensure working matrix is double precision
|
||||||
src.convertTo(data, CV_64FC1);
|
src.convertTo(data, CV_64FC1);
|
||||||
// maps the labels, so they're ascending: [0,1,...,C]
|
// maps the labels, so they're ascending: [0,1,...,C]
|
||||||
vector<int> mapped_labels(labels.size());
|
std::vector<int> mapped_labels(labels.size());
|
||||||
vector<int> num2label = remove_dups(labels);
|
std::vector<int> num2label = remove_dups(labels);
|
||||||
map<int, int> label2num;
|
std::map<int, int> label2num;
|
||||||
for (int i = 0; i < (int)num2label.size(); i++)
|
for (int i = 0; i < (int)num2label.size(); i++)
|
||||||
label2num[num2label[i]] = i;
|
label2num[num2label[i]] = i;
|
||||||
for (size_t i = 0; i < labels.size(); i++)
|
for (size_t i = 0; i < labels.size(); i++)
|
||||||
@ -1006,19 +1001,19 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
|
|||||||
// we can't do a LDA on one class, what do you
|
// we can't do a LDA on one class, what do you
|
||||||
// want to separate from each other then?
|
// want to separate from each other then?
|
||||||
if(C == 1) {
|
if(C == 1) {
|
||||||
string error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!";
|
std::string error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!";
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// throw error if less labels, than samples
|
// throw error if less labels, than samples
|
||||||
if (labels.size() != static_cast<size_t>(N)) {
|
if (labels.size() != static_cast<size_t>(N)) {
|
||||||
string error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N);
|
std::string error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N);
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
}
|
}
|
||||||
// warn if within-classes scatter matrix becomes singular
|
// warn if within-classes scatter matrix becomes singular
|
||||||
if (N < D) {
|
if (N < D) {
|
||||||
cout << "Warning: Less observations than feature dimension given!"
|
std::cout << "Warning: Less observations than feature dimension given!"
|
||||||
<< "Computation will probably fail."
|
<< "Computation will probably fail."
|
||||||
<< endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
// clip number of components to be a valid number
|
// clip number of components to be a valid number
|
||||||
if ((_num_components <= 0) || (_num_components > (C - 1))) {
|
if ((_num_components <= 0) || (_num_components > (C - 1))) {
|
||||||
@ -1027,8 +1022,8 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
|
|||||||
// holds the mean over all classes
|
// holds the mean over all classes
|
||||||
Mat meanTotal = Mat::zeros(1, D, data.type());
|
Mat meanTotal = Mat::zeros(1, D, data.type());
|
||||||
// holds the mean for each class
|
// holds the mean for each class
|
||||||
vector<Mat> meanClass(C);
|
std::vector<Mat> meanClass(C);
|
||||||
vector<int> numClass(C);
|
std::vector<int> numClass(C);
|
||||||
// initialize
|
// initialize
|
||||||
for (int i = 0; i < C; i++) {
|
for (int i = 0; i < C; i++) {
|
||||||
numClass[i] = 0;
|
numClass[i] = 0;
|
||||||
@ -1076,7 +1071,7 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
|
|||||||
// reshape eigenvalues, so they are stored by column
|
// reshape eigenvalues, so they are stored by column
|
||||||
_eigenvalues = _eigenvalues.reshape(1, 1);
|
_eigenvalues = _eigenvalues.reshape(1, 1);
|
||||||
// get sorted indices descending by their eigenvalue
|
// get sorted indices descending by their eigenvalue
|
||||||
vector<int> sorted_indices = argsort(_eigenvalues, false);
|
std::vector<int> sorted_indices = argsort(_eigenvalues, false);
|
||||||
// now sort eigenvalues and eigenvectors accordingly
|
// now sort eigenvalues and eigenvectors accordingly
|
||||||
_eigenvalues = sortMatrixColumnsByIndices(_eigenvalues, sorted_indices);
|
_eigenvalues = sortMatrixColumnsByIndices(_eigenvalues, sorted_indices);
|
||||||
_eigenvectors = sortMatrixColumnsByIndices(_eigenvectors, sorted_indices);
|
_eigenvectors = sortMatrixColumnsByIndices(_eigenvectors, sorted_indices);
|
||||||
@ -1094,7 +1089,7 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
|
|||||||
lda(_src.getMat(), _lbls);
|
lda(_src.getMat(), _lbls);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
string error_message= format("InputArray Datatype %d is not supported.", _src.kind());
|
std::string error_message= format("InputArray Datatype %d is not supported.", _src.kind());
|
||||||
CV_Error(CV_StsBadArg, error_message);
|
CV_Error(CV_StsBadArg, error_message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -75,13 +75,13 @@ LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int _R, double _r
|
|||||||
int rtmp;
|
int rtmp;
|
||||||
|
|
||||||
if (center.x<=w/2 && center.y>=h/2)
|
if (center.x<=w/2 && center.y>=h/2)
|
||||||
rtmp=(int)sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
|
rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
|
||||||
else if (center.x>=w/2 && center.y>=h/2)
|
else if (center.x>=w/2 && center.y>=h/2)
|
||||||
rtmp=(int)sqrt((float)center.y*center.y + (float)center.x*center.x);
|
rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x);
|
||||||
else if (center.x>=w/2 && center.y<=h/2)
|
else if (center.x>=w/2 && center.y<=h/2)
|
||||||
rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
|
rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
|
||||||
else //if (center.x<=w/2 && center.y<=h/2)
|
else //if (center.x<=w/2 && center.y<=h/2)
|
||||||
rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
|
rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
|
||||||
|
|
||||||
M=2*rtmp; N=2*rtmp;
|
M=2*rtmp; N=2*rtmp;
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int _R, double _r
|
|||||||
|
|
||||||
if (sp){
|
if (sp){
|
||||||
int jc=M/2-1, ic=N/2-1;
|
int jc=M/2-1, ic=N/2-1;
|
||||||
int _romax=min(ic, jc);
|
int _romax=std::min(ic, jc);
|
||||||
double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R);
|
double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R);
|
||||||
S=(int) floor(2*CV_PI/(_a-1)+0.5);
|
S=(int) floor(2*CV_PI/(_a-1)+0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +116,8 @@ void LogPolar_Interp::create_map(int _M, int _n, int _R, int _s, double _ro0)
|
|||||||
ro0=_ro0;
|
ro0=_ro0;
|
||||||
|
|
||||||
int jc=N/2-1, ic=M/2-1;
|
int jc=N/2-1, ic=M/2-1;
|
||||||
romax=min(ic, jc);
|
romax=std::min(ic, jc);
|
||||||
a=exp(log((double)romax/(double)ro0)/(double)R);
|
a=std::exp(std::log((double)romax/(double)ro0)/(double)R);
|
||||||
q=((double)S)/(2*CV_PI);
|
q=((double)S)/(2*CV_PI);
|
||||||
|
|
||||||
Rsri = Mat::zeros(S,R,CV_32FC1);
|
Rsri = Mat::zeros(S,R,CV_32FC1);
|
||||||
@ -129,8 +129,8 @@ void LogPolar_Interp::create_map(int _M, int _n, int _R, int _s, double _ro0)
|
|||||||
{
|
{
|
||||||
for(int u=0; u<R; u++)
|
for(int u=0; u<R; u++)
|
||||||
{
|
{
|
||||||
Rsri.at<float>(v,u)=(float)(ro0*pow(a,u)*sin(v/q)+jc);
|
Rsri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*sin(v/q)+jc);
|
||||||
Csri.at<float>(v,u)=(float)(ro0*pow(a,u)*cos(v/q)+ic);
|
Csri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*cos(v/q)+ic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ void LogPolar_Interp::create_map(int _M, int _n, int _R, int _s, double _ro0)
|
|||||||
ETAyx.at<float>(j,i)=(float)(q*theta);
|
ETAyx.at<float>(j,i)=(float)(q*theta);
|
||||||
|
|
||||||
double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic);
|
double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic);
|
||||||
CSIyx.at<float>(j,i)=(float)(0.5*log(ro2/(ro0*ro0))/log(a));
|
CSIyx.at<float>(j,i)=(float)(0.5*std::log(ro2/(ro0*ro0))/std::log(a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,13 +221,13 @@ LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int _R,
|
|||||||
int rtmp;
|
int rtmp;
|
||||||
|
|
||||||
if (center.x<=w/2 && center.y>=h/2)
|
if (center.x<=w/2 && center.y>=h/2)
|
||||||
rtmp=(int)sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
|
rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
|
||||||
else if (center.x>=w/2 && center.y>=h/2)
|
else if (center.x>=w/2 && center.y>=h/2)
|
||||||
rtmp=(int)sqrt((float)center.y*center.y + (float)center.x*center.x);
|
rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x);
|
||||||
else if (center.x>=w/2 && center.y<=h/2)
|
else if (center.x>=w/2 && center.y<=h/2)
|
||||||
rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
|
rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
|
||||||
else //if (center.x<=w/2 && center.y<=h/2)
|
else //if (center.x<=w/2 && center.y<=h/2)
|
||||||
rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
|
rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
|
||||||
|
|
||||||
M=2*rtmp; N=2*rtmp;
|
M=2*rtmp; N=2*rtmp;
|
||||||
|
|
||||||
@ -244,8 +244,8 @@ LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int _R,
|
|||||||
|
|
||||||
if (sp){
|
if (sp){
|
||||||
int jc=M/2-1, ic=N/2-1;
|
int jc=M/2-1, ic=N/2-1;
|
||||||
int _romax=min(ic, jc);
|
int _romax=std::min(ic, jc);
|
||||||
double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R);
|
double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R);
|
||||||
S=(int) floor(2*CV_PI/(_a-1)+0.5);
|
S=(int) floor(2*CV_PI/(_a-1)+0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +261,8 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro
|
|||||||
ro0=_ro0;
|
ro0=_ro0;
|
||||||
|
|
||||||
int jc=N/2-1, ic=M/2-1;
|
int jc=N/2-1, ic=M/2-1;
|
||||||
romax=min(ic, jc);
|
romax=std::min(ic, jc);
|
||||||
a=exp(log((double)romax/(double)ro0)/(double)R);
|
a=std::exp(std::log((double)romax/(double)ro0)/(double)R);
|
||||||
q=((double)S)/(2*CV_PI);
|
q=((double)S)/(2*CV_PI);
|
||||||
ind1=0;
|
ind1=0;
|
||||||
|
|
||||||
@ -279,8 +279,8 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro
|
|||||||
{
|
{
|
||||||
for(int u=0; u<R; u++)
|
for(int u=0; u<R; u++)
|
||||||
{
|
{
|
||||||
Rsri.at<float>(v,u)=(float)(ro0*pow(a,u)*sin(v/q)+jc);
|
Rsri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*sin(v/q)+jc);
|
||||||
Csri.at<float>(v,u)=(float)(ro0*pow(a,u)*cos(v/q)+ic);
|
Csri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*cos(v/q)+ic);
|
||||||
Rsr[v*R+u]=(int)floor(Rsri.at<float>(v,u));
|
Rsr[v*R+u]=(int)floor(Rsri.at<float>(v,u));
|
||||||
Csr[v*R+u]=(int)floor(Csri.at<float>(v,u));
|
Csr[v*R+u]=(int)floor(Csri.at<float>(v,u));
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro
|
|||||||
|
|
||||||
for(int i=0; i<R; i++)
|
for(int i=0; i<R; i++)
|
||||||
{
|
{
|
||||||
Wsr[i]=ro0*(a-1)*pow(a,i-1);
|
Wsr[i]=ro0*(a-1)*std::pow(a,i-1);
|
||||||
if((Wsr[i]>1)&&(done==false))
|
if((Wsr[i]>1)&&(done==false))
|
||||||
{
|
{
|
||||||
ind1=i;
|
ind1=i;
|
||||||
@ -314,7 +314,7 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro
|
|||||||
ETAyx.at<float>(j,i)=(float)(q*theta);
|
ETAyx.at<float>(j,i)=(float)(q*theta);
|
||||||
|
|
||||||
double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic);
|
double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic);
|
||||||
CSIyx.at<float>(j,i)=(float)(0.5*log(ro2/(ro0*ro0))/log(a));
|
CSIyx.at<float>(j,i)=(float)(0.5*std::log(ro2/(ro0*ro0))/std::log(a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro
|
|||||||
for(int j=0; j<2*w+1; j++)
|
for(int j=0; j<2*w+1; j++)
|
||||||
for(int i=0; i<2*w+1; i++)
|
for(int i=0; i<2*w+1; i++)
|
||||||
{
|
{
|
||||||
(w_ker_2D[v*R+u].weights)[j*(2*w+1)+i]=exp(-(pow(i-w-dx, 2)+pow(j-w-dy, 2))/(2*sigma*sigma));
|
(w_ker_2D[v*R+u].weights)[j*(2*w+1)+i]=std::exp(-(std::pow(i-w-dx, 2)+std::pow(j-w-dy, 2))/(2*sigma*sigma));
|
||||||
tot+=(w_ker_2D[v*R+u].weights)[j*(2*w+1)+i];
|
tot+=(w_ker_2D[v*R+u].weights)[j*(2*w+1)+i];
|
||||||
}
|
}
|
||||||
for(int j=0; j<(2*w+1); j++)
|
for(int j=0; j<(2*w+1); j++)
|
||||||
@ -351,7 +351,7 @@ const Mat LogPolar_Overlapping::to_cortical(const Mat &source)
|
|||||||
remap(source_border,out,Csri,Rsri,INTER_LINEAR);
|
remap(source_border,out,Csri,Rsri,INTER_LINEAR);
|
||||||
|
|
||||||
int wm=w_ker_2D[R-1].w;
|
int wm=w_ker_2D[R-1].w;
|
||||||
vector<int> IMG((M+2*wm+1)*(N+2*wm+1), 0);
|
std::vector<int> IMG((M+2*wm+1)*(N+2*wm+1), 0);
|
||||||
|
|
||||||
for(int j=0; j<N; j++)
|
for(int j=0; j<N; j++)
|
||||||
for(int i=0; i<M; i++)
|
for(int i=0; i<M; i++)
|
||||||
@ -388,8 +388,8 @@ const Mat LogPolar_Overlapping::to_cartesian(const Mat &source)
|
|||||||
|
|
||||||
int wm=w_ker_2D[R-1].w;
|
int wm=w_ker_2D[R-1].w;
|
||||||
|
|
||||||
vector<double> IMG((N+2*wm+1)*(M+2*wm+1), 0.);
|
std::vector<double> IMG((N+2*wm+1)*(M+2*wm+1), 0.);
|
||||||
vector<double> NOR((N+2*wm+1)*(M+2*wm+1), 0.);
|
std::vector<double> NOR((N+2*wm+1)*(M+2*wm+1), 0.);
|
||||||
|
|
||||||
for(int v=0; v<S; v++)
|
for(int v=0; v<S; v++)
|
||||||
for(int u=ind1; u<R; u++)
|
for(int u=ind1; u<R; u++)
|
||||||
@ -416,7 +416,7 @@ const Mat LogPolar_Overlapping::to_cartesian(const Mat &source)
|
|||||||
{
|
{
|
||||||
/*if(NOR[(M+2*wm+1)*j+i]>0)
|
/*if(NOR[(M+2*wm+1)*j+i]>0)
|
||||||
ret[M*(j-wm)+i-wm]=(int) floor(IMG[(M+2*wm+1)*j+i]+0.5);*/
|
ret[M*(j-wm)+i-wm]=(int) floor(IMG[(M+2*wm+1)*j+i]+0.5);*/
|
||||||
//int ro=(int)floor(sqrt((double)((j-wm-yc)*(j-wm-yc)+(i-wm-xc)*(i-wm-xc))));
|
//int ro=(int)floor(std::sqrt((double)((j-wm-yc)*(j-wm-yc)+(i-wm-xc)*(i-wm-xc))));
|
||||||
int csi=(int) floor(CSIyx.at<float>(j-wm,i-wm));
|
int csi=(int) floor(CSIyx.at<float>(j-wm,i-wm));
|
||||||
|
|
||||||
if((csi>=(ind1-(w_ker_2D[ind1]).w))&&(csi<R))
|
if((csi>=(ind1-(w_ker_2D[ind1]).w))&&(csi<R))
|
||||||
@ -446,13 +446,13 @@ LogPolar_Adjacent::LogPolar_Adjacent(int w, int h, Point2i center, int _R, doubl
|
|||||||
int rtmp;
|
int rtmp;
|
||||||
|
|
||||||
if (center.x<=w/2 && center.y>=h/2)
|
if (center.x<=w/2 && center.y>=h/2)
|
||||||
rtmp=(int)sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
|
rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
|
||||||
else if (center.x>=w/2 && center.y>=h/2)
|
else if (center.x>=w/2 && center.y>=h/2)
|
||||||
rtmp=(int)sqrt((float)center.y*center.y + (float)center.x*center.x);
|
rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x);
|
||||||
else if (center.x>=w/2 && center.y<=h/2)
|
else if (center.x>=w/2 && center.y<=h/2)
|
||||||
rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
|
rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
|
||||||
else //if (center.x<=w/2 && center.y<=h/2)
|
else //if (center.x<=w/2 && center.y<=h/2)
|
||||||
rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
|
rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
|
||||||
|
|
||||||
M=2*rtmp; N=2*rtmp;
|
M=2*rtmp; N=2*rtmp;
|
||||||
|
|
||||||
@ -468,8 +468,8 @@ LogPolar_Adjacent::LogPolar_Adjacent(int w, int h, Point2i center, int _R, doubl
|
|||||||
|
|
||||||
if (sp){
|
if (sp){
|
||||||
int jc=M/2-1, ic=N/2-1;
|
int jc=M/2-1, ic=N/2-1;
|
||||||
int _romax=min(ic, jc);
|
int _romax=std::min(ic, jc);
|
||||||
double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R);
|
double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R);
|
||||||
S=(int) floor(2*CV_PI/(_a-1)+0.5);
|
S=(int) floor(2*CV_PI/(_a-1)+0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,9 +484,9 @@ void LogPolar_Adjacent::create_map(int _M, int _n, int _R, int _s, double _ro0,
|
|||||||
R=_R;
|
R=_R;
|
||||||
S=_s;
|
S=_s;
|
||||||
ro0=_ro0;
|
ro0=_ro0;
|
||||||
romax=min(M/2.0, N/2.0);
|
romax=std::min(M/2.0, N/2.0);
|
||||||
|
|
||||||
a=exp(log(romax/ro0)/(double)R);
|
a=std::exp(std::log(romax/ro0)/(double)R);
|
||||||
q=S/(2*CV_PI);
|
q=S/(2*CV_PI);
|
||||||
|
|
||||||
A.resize(R*S);
|
A.resize(R*S);
|
||||||
@ -572,7 +572,7 @@ const Mat LogPolar_Adjacent::to_cortical(const Mat &source)
|
|||||||
Mat source_border;
|
Mat source_border;
|
||||||
copyMakeBorder(source,source_border,top,bottom,left,right,BORDER_CONSTANT,Scalar(0));
|
copyMakeBorder(source,source_border,top,bottom,left,right,BORDER_CONSTANT,Scalar(0));
|
||||||
|
|
||||||
vector<double> map(R*S, 0.);
|
std::vector<double> map(R*S, 0.);
|
||||||
|
|
||||||
for(int j=0; j<N; j++)
|
for(int j=0; j<N; j++)
|
||||||
for(int i=0; i<M; i++)
|
for(int i=0; i<M; i++)
|
||||||
@ -597,7 +597,7 @@ const Mat LogPolar_Adjacent::to_cortical(const Mat &source)
|
|||||||
|
|
||||||
const Mat LogPolar_Adjacent::to_cartesian(const Mat &source)
|
const Mat LogPolar_Adjacent::to_cartesian(const Mat &source)
|
||||||
{
|
{
|
||||||
vector<double> map(M*N, 0.);
|
std::vector<double> map(M*N, 0.);
|
||||||
|
|
||||||
for(int j=0; j<N; j++)
|
for(int j=0; j<N; j++)
|
||||||
for(int i=0; i<M; i++)
|
for(int i=0; i<M; i++)
|
||||||
@ -621,7 +621,7 @@ const Mat LogPolar_Adjacent::to_cartesian(const Mat &source)
|
|||||||
|
|
||||||
bool LogPolar_Adjacent::get_uv(double x, double y, int&u, int&v)
|
bool LogPolar_Adjacent::get_uv(double x, double y, int&u, int&v)
|
||||||
{
|
{
|
||||||
double ro=sqrt(x*x+y*y), theta;
|
double ro=std::sqrt(x*x+y*y), theta;
|
||||||
if(x>0)
|
if(x>0)
|
||||||
theta=atan(y/x);
|
theta=atan(y/x);
|
||||||
else
|
else
|
||||||
@ -635,7 +635,7 @@ bool LogPolar_Adjacent::get_uv(double x, double y, int&u, int&v)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u= (int) floor(log(ro/ro0)/log(a));
|
u= (int) floor(std::log(ro/ro0)/std::log(a));
|
||||||
if(theta>=0)
|
if(theta>=0)
|
||||||
v= (int) floor(q*theta);
|
v= (int) floor(q*theta);
|
||||||
else
|
else
|
||||||
|
@ -144,7 +144,7 @@ void MagnoRetinaFilter::resize(const unsigned int NBrows, const unsigned int NBc
|
|||||||
|
|
||||||
void MagnoRetinaFilter::setCoefficientsTable(const float parasolCells_beta, const float parasolCells_tau, const float parasolCells_k, const float amacrinCellsTemporalCutFrequency, const float localAdaptIntegration_tau, const float localAdaptIntegration_k )
|
void MagnoRetinaFilter::setCoefficientsTable(const float parasolCells_beta, const float parasolCells_tau, const float parasolCells_k, const float amacrinCellsTemporalCutFrequency, const float localAdaptIntegration_tau, const float localAdaptIntegration_k )
|
||||||
{
|
{
|
||||||
_temporalCoefficient=(float)exp(-1.0f/amacrinCellsTemporalCutFrequency);
|
_temporalCoefficient=(float)std::exp(-1.0f/amacrinCellsTemporalCutFrequency);
|
||||||
// the first set of parameters is dedicated to the low pass filtering property of the ganglion cells
|
// the first set of parameters is dedicated to the low pass filtering property of the ganglion cells
|
||||||
BasicRetinaFilter::setLPfilterParameters(parasolCells_beta, parasolCells_tau, parasolCells_k, 0);
|
BasicRetinaFilter::setLPfilterParameters(parasolCells_beta, parasolCells_tau, parasolCells_k, 0);
|
||||||
// the second set of parameters is dedicated to the ganglion cells output intergartion for their local adaptation property
|
// the second set of parameters is dedicated to the ganglion cells output intergartion for their local adaptation property
|
||||||
|
@ -101,7 +101,7 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillMinMax(const vector<Point3f>& points, Octree::Node& node)
|
void fillMinMax(const std::vector<Point3f>& points, Octree::Node& node)
|
||||||
{
|
{
|
||||||
node.x_max = node.y_max = node.z_max = std::numeric_limits<float>::min();
|
node.x_max = node.y_max = node.z_max = std::numeric_limits<float>::min();
|
||||||
node.x_min = node.y_min = node.z_min = std::numeric_limits<float>::max();
|
node.x_min = node.y_min = node.z_min = std::numeric_limits<float>::max();
|
||||||
@ -171,7 +171,7 @@ namespace cv
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Octree::Octree(const vector<Point3f>& points3d, int maxLevels, int _minPoints)
|
Octree::Octree(const std::vector<Point3f>& points3d, int maxLevels, int _minPoints)
|
||||||
{
|
{
|
||||||
buildTree(points3d, maxLevels, _minPoints);
|
buildTree(points3d, maxLevels, _minPoints);
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ namespace cv
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::getPointsWithinSphere(const Point3f& center, float radius, vector<Point3f>& out) const
|
void Octree::getPointsWithinSphere(const Point3f& center, float radius, std::vector<Point3f>& out) const
|
||||||
{
|
{
|
||||||
out.clear();
|
out.clear();
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ namespace cv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::buildTree(const vector<Point3f>& points3d, int maxLevels, int _minPoints)
|
void Octree::buildTree(const std::vector<Point3f>& points3d, int maxLevels, int _minPoints)
|
||||||
{
|
{
|
||||||
assert((size_t)maxLevels * 8 < MAX_STACK_SIZE);
|
assert((size_t)maxLevels * 8 < MAX_STACK_SIZE);
|
||||||
points.resize(points3d.size());
|
points.resize(points3d.size());
|
||||||
@ -286,9 +286,9 @@ namespace cv
|
|||||||
{
|
{
|
||||||
size_t size = nodes[nodeInd].end - nodes[nodeInd].begin;
|
size_t size = nodes[nodeInd].end - nodes[nodeInd].begin;
|
||||||
|
|
||||||
vector<size_t> boxBorders(MAX_LEAFS+1, 0);
|
std::vector<size_t> boxBorders(MAX_LEAFS+1, 0);
|
||||||
vector<size_t> boxIndices(size);
|
std::vector<size_t> boxIndices(size);
|
||||||
vector<Point3f> tempPoints(size);
|
std::vector<Point3f> tempPoints(size);
|
||||||
|
|
||||||
for (int i = nodes[nodeInd].begin, j = 0; i < nodes[nodeInd].end; ++i, ++j)
|
for (int i = nodes[nodeInd].begin, j = 0; i < nodes[nodeInd].end; ++i, ++j)
|
||||||
{
|
{
|
||||||
@ -304,7 +304,7 @@ namespace cv
|
|||||||
for (size_t i = 1; i < boxBorders.size(); ++i)
|
for (size_t i = 1; i < boxBorders.size(); ++i)
|
||||||
boxBorders[i] += boxBorders[i-1];
|
boxBorders[i] += boxBorders[i-1];
|
||||||
|
|
||||||
vector<size_t> writeInds(boxBorders.begin(), boxBorders.end());
|
std::vector<size_t> writeInds(boxBorders.begin(), boxBorders.end());
|
||||||
|
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ namespace cv {
|
|||||||
namespace of2 {
|
namespace of2 {
|
||||||
|
|
||||||
static double logsumexp(double a, double b) {
|
static double logsumexp(double a, double b) {
|
||||||
return a > b ? log(1 + exp(b - a)) + a : log(1 + exp(a - b)) + b;
|
return a > b ? std::log(1 + std::exp(b - a)) + a : std::log(1 + std::exp(a - b)) + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
FabMap::FabMap(const Mat& _clTree, double _PzGe,
|
FabMap::FabMap(const Mat& _clTree, double _PzGe,
|
||||||
@ -103,14 +103,14 @@ const std::vector<cv::Mat>& FabMap::getTestImgDescriptors() const {
|
|||||||
|
|
||||||
void FabMap::addTraining(const Mat& queryImgDescriptor) {
|
void FabMap::addTraining(const Mat& queryImgDescriptor) {
|
||||||
CV_Assert(!queryImgDescriptor.empty());
|
CV_Assert(!queryImgDescriptor.empty());
|
||||||
vector<Mat> queryImgDescriptors;
|
std::vector<Mat> queryImgDescriptors;
|
||||||
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
||||||
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
||||||
}
|
}
|
||||||
addTraining(queryImgDescriptors);
|
addTraining(queryImgDescriptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::addTraining(const vector<Mat>& queryImgDescriptors) {
|
void FabMap::addTraining(const std::vector<Mat>& queryImgDescriptors) {
|
||||||
for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
|
for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
|
||||||
CV_Assert(!queryImgDescriptors[i].empty());
|
CV_Assert(!queryImgDescriptors[i].empty());
|
||||||
CV_Assert(queryImgDescriptors[i].rows == 1);
|
CV_Assert(queryImgDescriptors[i].rows == 1);
|
||||||
@ -122,7 +122,7 @@ void FabMap::addTraining(const vector<Mat>& queryImgDescriptors) {
|
|||||||
|
|
||||||
void FabMap::add(const cv::Mat& queryImgDescriptor) {
|
void FabMap::add(const cv::Mat& queryImgDescriptor) {
|
||||||
CV_Assert(!queryImgDescriptor.empty());
|
CV_Assert(!queryImgDescriptor.empty());
|
||||||
vector<Mat> queryImgDescriptors;
|
std::vector<Mat> queryImgDescriptors;
|
||||||
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
||||||
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
||||||
}
|
}
|
||||||
@ -140,10 +140,10 @@ void FabMap::add(const std::vector<cv::Mat>& queryImgDescriptors) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::compare(const Mat& queryImgDescriptor,
|
void FabMap::compare(const Mat& queryImgDescriptor,
|
||||||
vector<IMatch>& matches, bool addQuery,
|
std::vector<IMatch>& matches, bool addQuery,
|
||||||
const Mat& mask) {
|
const Mat& mask) {
|
||||||
CV_Assert(!queryImgDescriptor.empty());
|
CV_Assert(!queryImgDescriptor.empty());
|
||||||
vector<Mat> queryImgDescriptors;
|
std::vector<Mat> queryImgDescriptors;
|
||||||
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
||||||
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
||||||
}
|
}
|
||||||
@ -151,16 +151,16 @@ void FabMap::compare(const Mat& queryImgDescriptor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::compare(const Mat& queryImgDescriptor,
|
void FabMap::compare(const Mat& queryImgDescriptor,
|
||||||
const Mat& testImgDescriptor, vector<IMatch>& matches,
|
const Mat& testImgDescriptor, std::vector<IMatch>& matches,
|
||||||
const Mat& mask) {
|
const Mat& mask) {
|
||||||
CV_Assert(!queryImgDescriptor.empty());
|
CV_Assert(!queryImgDescriptor.empty());
|
||||||
vector<Mat> queryImgDescriptors;
|
std::vector<Mat> queryImgDescriptors;
|
||||||
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
||||||
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_Assert(!testImgDescriptor.empty());
|
CV_Assert(!testImgDescriptor.empty());
|
||||||
vector<Mat> _testImgDescriptors;
|
std::vector<Mat> _testImgDescriptors;
|
||||||
for (int i = 0; i < testImgDescriptor.rows; i++) {
|
for (int i = 0; i < testImgDescriptor.rows; i++) {
|
||||||
_testImgDescriptors.push_back(testImgDescriptor.row(i));
|
_testImgDescriptors.push_back(testImgDescriptor.row(i));
|
||||||
}
|
}
|
||||||
@ -169,18 +169,18 @@ void FabMap::compare(const Mat& queryImgDescriptor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::compare(const Mat& queryImgDescriptor,
|
void FabMap::compare(const Mat& queryImgDescriptor,
|
||||||
const vector<Mat>& _testImgDescriptors,
|
const std::vector<Mat>& _testImgDescriptors,
|
||||||
vector<IMatch>& matches, const Mat& mask) {
|
std::vector<IMatch>& matches, const Mat& mask) {
|
||||||
CV_Assert(!queryImgDescriptor.empty());
|
CV_Assert(!queryImgDescriptor.empty());
|
||||||
vector<Mat> queryImgDescriptors;
|
std::vector<Mat> queryImgDescriptors;
|
||||||
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
for (int i = 0; i < queryImgDescriptor.rows; i++) {
|
||||||
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
queryImgDescriptors.push_back(queryImgDescriptor.row(i));
|
||||||
}
|
}
|
||||||
compare(queryImgDescriptors,_testImgDescriptors,matches,mask);
|
compare(queryImgDescriptors,_testImgDescriptors,matches,mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::compare(const vector<Mat>& queryImgDescriptors,
|
void FabMap::compare(const std::vector<Mat>& queryImgDescriptors,
|
||||||
vector<IMatch>& matches, bool addQuery, const Mat& /*mask*/) {
|
std::vector<IMatch>& matches, bool addQuery, const Mat& /*mask*/) {
|
||||||
|
|
||||||
// TODO: add first query if empty (is this necessary)
|
// TODO: add first query if empty (is this necessary)
|
||||||
|
|
||||||
@ -199,9 +199,9 @@ void FabMap::compare(const vector<Mat>& queryImgDescriptors,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::compare(const vector<Mat>& queryImgDescriptors,
|
void FabMap::compare(const std::vector<Mat>& queryImgDescriptors,
|
||||||
const vector<Mat>& _testImgDescriptors,
|
const std::vector<Mat>& _testImgDescriptors,
|
||||||
vector<IMatch>& matches, const Mat& /*mask*/) {
|
std::vector<IMatch>& matches, const Mat& /*mask*/) {
|
||||||
|
|
||||||
CV_Assert(!(flags & MOTION_MODEL));
|
CV_Assert(!(flags & MOTION_MODEL));
|
||||||
for (size_t i = 0; i < _testImgDescriptors.size(); i++) {
|
for (size_t i = 0; i < _testImgDescriptors.size(); i++) {
|
||||||
@ -225,10 +225,10 @@ void FabMap::compare(const vector<Mat>& queryImgDescriptors,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::compareImgDescriptor(const Mat& queryImgDescriptor,
|
void FabMap::compareImgDescriptor(const Mat& queryImgDescriptor,
|
||||||
int queryIndex, const vector<Mat>& _testImgDescriptors,
|
int queryIndex, const std::vector<Mat>& _testImgDescriptors,
|
||||||
vector<IMatch>& matches) {
|
std::vector<IMatch>& matches) {
|
||||||
|
|
||||||
vector<IMatch> queryMatches;
|
std::vector<IMatch> queryMatches;
|
||||||
queryMatches.push_back(IMatch(queryIndex,-1,
|
queryMatches.push_back(IMatch(queryIndex,-1,
|
||||||
getNewPlaceLikelihood(queryImgDescriptor),0));
|
getNewPlaceLikelihood(queryImgDescriptor),0));
|
||||||
getLikelihoods(queryImgDescriptor,_testImgDescriptors,queryMatches);
|
getLikelihoods(queryImgDescriptor,_testImgDescriptors,queryMatches);
|
||||||
@ -240,7 +240,7 @@ void FabMap::compareImgDescriptor(const Mat& queryImgDescriptor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::getLikelihoods(const Mat& /*queryImgDescriptor*/,
|
void FabMap::getLikelihoods(const Mat& /*queryImgDescriptor*/,
|
||||||
const vector<Mat>& /*testImgDescriptors*/, vector<IMatch>& /*matches*/) {
|
const std::vector<Mat>& /*testImgDescriptors*/, std::vector<IMatch>& /*matches*/) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
|
|||||||
for (int q = 0; q < clTree.cols; q++) {
|
for (int q = 0; q < clTree.cols; q++) {
|
||||||
zq = queryImgDescriptor.at<float>(0,q) > 0;
|
zq = queryImgDescriptor.at<float>(0,q) > 0;
|
||||||
|
|
||||||
logP += log(Pzq(q, false) * PzqGeq(zq, false) +
|
logP += std::log(Pzq(q, false) * PzqGeq(zq, false) +
|
||||||
Pzq(q, true) * PzqGeq(zq, true));
|
Pzq(q, true) * PzqGeq(zq, true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -269,7 +269,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
|
|||||||
beta = Pzq(q, !zq) * PzqGeq(zq, true) * PzqGzpq(q, zq, zpq);
|
beta = Pzq(q, !zq) * PzqGeq(zq, true) * PzqGzpq(q, zq, zpq);
|
||||||
p += Pzq(q, true) * beta / (alpha + beta);
|
p += Pzq(q, true) * beta / (alpha + beta);
|
||||||
|
|
||||||
logP += log(p);
|
logP += std::log(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return logP;
|
return logP;
|
||||||
@ -279,7 +279,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
|
|||||||
CV_Assert(!trainingImgDescriptors.empty());
|
CV_Assert(!trainingImgDescriptors.empty());
|
||||||
CV_Assert(numSamples > 0);
|
CV_Assert(numSamples > 0);
|
||||||
|
|
||||||
vector<Mat> sampledImgDescriptors;
|
std::vector<Mat> sampledImgDescriptors;
|
||||||
|
|
||||||
// TODO: this method can result in the same sample being added
|
// TODO: this method can result in the same sample being added
|
||||||
// multiple times. Is this desired?
|
// multiple times. Is this desired?
|
||||||
@ -289,7 +289,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
|
|||||||
sampledImgDescriptors.push_back(trainingImgDescriptors[index]);
|
sampledImgDescriptors.push_back(trainingImgDescriptors[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<IMatch> matches;
|
std::vector<IMatch> matches;
|
||||||
getLikelihoods(queryImgDescriptor,sampledImgDescriptors,matches);
|
getLikelihoods(queryImgDescriptor,sampledImgDescriptors,matches);
|
||||||
|
|
||||||
double averageLogLikelihood = -DBL_MAX + matches.front().likelihood + 1;
|
double averageLogLikelihood = -DBL_MAX + matches.front().likelihood + 1;
|
||||||
@ -298,34 +298,34 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
|
|||||||
logsumexp(matches[i].likelihood, averageLogLikelihood);
|
logsumexp(matches[i].likelihood, averageLogLikelihood);
|
||||||
}
|
}
|
||||||
|
|
||||||
return averageLogLikelihood - log((double)numSamples);
|
return averageLogLikelihood - std::log((double)numSamples);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FabMap::normaliseDistribution(vector<IMatch>& matches) {
|
void FabMap::normaliseDistribution(std::vector<IMatch>& matches) {
|
||||||
CV_Assert(!matches.empty());
|
CV_Assert(!matches.empty());
|
||||||
|
|
||||||
if (flags & MOTION_MODEL) {
|
if (flags & MOTION_MODEL) {
|
||||||
|
|
||||||
matches[0].match = matches[0].likelihood + log(Pnew);
|
matches[0].match = matches[0].likelihood + std::log(Pnew);
|
||||||
|
|
||||||
if (priorMatches.size() > 2) {
|
if (priorMatches.size() > 2) {
|
||||||
matches[1].match = matches[1].likelihood;
|
matches[1].match = matches[1].likelihood;
|
||||||
matches[1].match += log(
|
matches[1].match += std::log(
|
||||||
(2 * (1-mBias) * priorMatches[1].match +
|
(2 * (1-mBias) * priorMatches[1].match +
|
||||||
priorMatches[1].match +
|
priorMatches[1].match +
|
||||||
2 * mBias * priorMatches[2].match) / 3);
|
2 * mBias * priorMatches[2].match) / 3);
|
||||||
for (size_t i = 2; i < priorMatches.size()-1; i++) {
|
for (size_t i = 2; i < priorMatches.size()-1; i++) {
|
||||||
matches[i].match = matches[i].likelihood;
|
matches[i].match = matches[i].likelihood;
|
||||||
matches[i].match += log(
|
matches[i].match += std::log(
|
||||||
(2 * (1-mBias) * priorMatches[i-1].match +
|
(2 * (1-mBias) * priorMatches[i-1].match +
|
||||||
priorMatches[i].match +
|
priorMatches[i].match +
|
||||||
2 * mBias * priorMatches[i+1].match)/3);
|
2 * mBias * priorMatches[i+1].match)/3);
|
||||||
}
|
}
|
||||||
matches[priorMatches.size()-1].match =
|
matches[priorMatches.size()-1].match =
|
||||||
matches[priorMatches.size()-1].likelihood;
|
matches[priorMatches.size()-1].likelihood;
|
||||||
matches[priorMatches.size()-1].match += log(
|
matches[priorMatches.size()-1].match += std::log(
|
||||||
(2 * (1-mBias) * priorMatches[priorMatches.size()-2].match +
|
(2 * (1-mBias) * priorMatches[priorMatches.size()-2].match +
|
||||||
priorMatches[priorMatches.size()-1].match +
|
priorMatches[priorMatches.size()-1].match +
|
||||||
2 * mBias * priorMatches[priorMatches.size()-1].match)/3);
|
2 * mBias * priorMatches[priorMatches.size()-1].match)/3);
|
||||||
@ -348,7 +348,7 @@ void FabMap::normaliseDistribution(vector<IMatch>& matches) {
|
|||||||
|
|
||||||
//normalise
|
//normalise
|
||||||
for (size_t i = 0; i < matches.size(); i++) {
|
for (size_t i = 0; i < matches.size(); i++) {
|
||||||
matches[i].match = exp(matches[i].match - logsum);
|
matches[i].match = std::exp(matches[i].match - logsum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//smooth final probabilities
|
//smooth final probabilities
|
||||||
@ -368,7 +368,7 @@ void FabMap::normaliseDistribution(vector<IMatch>& matches) {
|
|||||||
logsum = logsumexp(logsum, matches[i].likelihood);
|
logsum = logsumexp(logsum, matches[i].likelihood);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < matches.size(); i++) {
|
for (size_t i = 0; i < matches.size(); i++) {
|
||||||
matches[i].match = exp(matches[i].likelihood - logsum);
|
matches[i].match = std::exp(matches[i].likelihood - logsum);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < matches.size(); i++) {
|
for (size_t i = 0; i < matches.size(); i++) {
|
||||||
matches[i].match = sFactor*matches[i].match +
|
matches[i].match = sFactor*matches[i].match +
|
||||||
@ -444,7 +444,7 @@ FabMap1::~FabMap1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMap1::getLikelihoods(const Mat& queryImgDescriptor,
|
void FabMap1::getLikelihoods(const Mat& queryImgDescriptor,
|
||||||
const vector<Mat>& testImageDescriptors, vector<IMatch>& matches) {
|
const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
|
||||||
|
|
||||||
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
||||||
bool zq, zpq, Lzq;
|
bool zq, zpq, Lzq;
|
||||||
@ -455,7 +455,7 @@ void FabMap1::getLikelihoods(const Mat& queryImgDescriptor,
|
|||||||
zpq = queryImgDescriptor.at<float>(0,pq(q)) > 0;
|
zpq = queryImgDescriptor.at<float>(0,pq(q)) > 0;
|
||||||
Lzq = testImageDescriptors[i].at<float>(0,q) > 0;
|
Lzq = testImageDescriptors[i].at<float>(0,q) > 0;
|
||||||
|
|
||||||
logP += log((this->*PzGL)(q, zq, zpq, Lzq));
|
logP += std::log((this->*PzGL)(q, zq, zpq, Lzq));
|
||||||
|
|
||||||
}
|
}
|
||||||
matches.push_back(IMatch(0,(int)i,logP,0));
|
matches.push_back(IMatch(0,(int)i,logP,0));
|
||||||
@ -467,7 +467,7 @@ FabMapLUT::FabMapLUT(const Mat& _clTree, double _PzGe, double _PzGNe,
|
|||||||
FabMap(_clTree, _PzGe, _PzGNe, _flags, _numSamples), precision(_precision) {
|
FabMap(_clTree, _PzGe, _PzGNe, _flags, _numSamples), precision(_precision) {
|
||||||
|
|
||||||
int nWords = clTree.cols;
|
int nWords = clTree.cols;
|
||||||
double precFactor = (double)pow(10.0, precision);
|
double precFactor = (double)std::pow(10.0, precision);
|
||||||
|
|
||||||
table = new int[nWords][8];
|
table = new int[nWords][8];
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ FabMap(_clTree, _PzGe, _PzGNe, _flags, _numSamples), precision(_precision) {
|
|||||||
bool zq = (bool) ((i >> 1) & 0x01);
|
bool zq = (bool) ((i >> 1) & 0x01);
|
||||||
bool zpq = (bool) (i & 1);
|
bool zpq = (bool) (i & 1);
|
||||||
|
|
||||||
table[q][i] = -(int)(log((this->*PzGL)(q, zq, zpq, Lzq))
|
table[q][i] = -(int)(std::log((this->*PzGL)(q, zq, zpq, Lzq))
|
||||||
* precFactor);
|
* precFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -489,9 +489,9 @@ FabMapLUT::~FabMapLUT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMapLUT::getLikelihoods(const Mat& queryImgDescriptor,
|
void FabMapLUT::getLikelihoods(const Mat& queryImgDescriptor,
|
||||||
const vector<Mat>& testImageDescriptors, vector<IMatch>& matches) {
|
const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
|
||||||
|
|
||||||
double precFactor = (double)pow(10.0, -precision);
|
double precFactor = (double)std::pow(10.0, -precision);
|
||||||
|
|
||||||
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
||||||
unsigned long long int logP = 0;
|
unsigned long long int logP = 0;
|
||||||
@ -517,13 +517,13 @@ FabMapFBO::~FabMapFBO() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor,
|
void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor,
|
||||||
const vector<Mat>& testImageDescriptors, vector<IMatch>& matches) {
|
const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
|
||||||
|
|
||||||
std::multiset<WordStats> wordData;
|
std::multiset<WordStats> wordData;
|
||||||
setWordStatistics(queryImgDescriptor, wordData);
|
setWordStatistics(queryImgDescriptor, wordData);
|
||||||
|
|
||||||
vector<int> matchIndices;
|
std::vector<int> matchIndices;
|
||||||
vector<IMatch> queryMatches;
|
std::vector<IMatch> queryMatches;
|
||||||
|
|
||||||
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
||||||
queryMatches.push_back(IMatch(0,(int)i,0,0));
|
queryMatches.push_back(IMatch(0,(int)i,0,0));
|
||||||
@ -544,7 +544,7 @@ void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor,
|
|||||||
bool Lzq =
|
bool Lzq =
|
||||||
testImageDescriptors[matchIndices[i]].at<float>(0,wordIter->q) > 0;
|
testImageDescriptors[matchIndices[i]].at<float>(0,wordIter->q) > 0;
|
||||||
queryMatches[matchIndices[i]].likelihood +=
|
queryMatches[matchIndices[i]].likelihood +=
|
||||||
log((this->*PzGL)(wordIter->q,zq,zpq,Lzq));
|
std::log((this->*PzGL)(wordIter->q,zq,zpq,Lzq));
|
||||||
currBest =
|
currBest =
|
||||||
std::max(queryMatches[matchIndices[i]].likelihood, currBest);
|
std::max(queryMatches[matchIndices[i]].likelihood, currBest);
|
||||||
}
|
}
|
||||||
@ -553,9 +553,9 @@ void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
double delta = std::max(limitbisection(wordIter->V, wordIter->M),
|
double delta = std::max(limitbisection(wordIter->V, wordIter->M),
|
||||||
-log(rejectionThreshold));
|
-std::log(rejectionThreshold));
|
||||||
|
|
||||||
vector<int>::iterator matchIter = matchIndices.begin();
|
std::vector<int>::iterator matchIter = matchIndices.begin();
|
||||||
while (matchIter != matchIndices.end()) {
|
while (matchIter != matchIndices.end()) {
|
||||||
if (currBest - queryMatches[*matchIter].likelihood > delta) {
|
if (currBest - queryMatches[*matchIter].likelihood > delta) {
|
||||||
queryMatches[*matchIter].likelihood = bailedOut;
|
queryMatches[*matchIter].likelihood = bailedOut;
|
||||||
@ -568,7 +568,7 @@ void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor,
|
|||||||
|
|
||||||
for (size_t i = 0; i < queryMatches.size(); i++) {
|
for (size_t i = 0; i < queryMatches.size(); i++) {
|
||||||
if (queryMatches[i].likelihood == bailedOut) {
|
if (queryMatches[i].likelihood == bailedOut) {
|
||||||
queryMatches[i].likelihood = currBest + log(rejectionThreshold);
|
queryMatches[i].likelihood = currBest + std::log(rejectionThreshold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matches.insert(matches.end(), queryMatches.begin(), queryMatches.end());
|
matches.insert(matches.end(), queryMatches.begin(), queryMatches.end());
|
||||||
@ -595,11 +595,11 @@ void FabMapFBO::setWordStatistics(const Mat& queryImgDescriptor,
|
|||||||
zq = queryImgDescriptor.at<float>(0,wordIter->q) > 0;
|
zq = queryImgDescriptor.at<float>(0,wordIter->q) > 0;
|
||||||
zpq = queryImgDescriptor.at<float>(0,pq(wordIter->q)) > 0;
|
zpq = queryImgDescriptor.at<float>(0,pq(wordIter->q)) > 0;
|
||||||
|
|
||||||
d = log((this->*PzGL)(wordIter->q, zq, zpq, true)) -
|
d = std::log((this->*PzGL)(wordIter->q, zq, zpq, true)) -
|
||||||
log((this->*PzGL)(wordIter->q, zq, zpq, false));
|
std::log((this->*PzGL)(wordIter->q, zq, zpq, false));
|
||||||
|
|
||||||
V += pow(d, 2.0) * 2 *
|
V += std::pow(d, 2.0) * 2 *
|
||||||
(Pzq(wordIter->q, true) - pow(Pzq(wordIter->q, true), 2.0));
|
(Pzq(wordIter->q, true) - std::pow(Pzq(wordIter->q, true), 2.0));
|
||||||
M = std::max(M, fabs(d));
|
M = std::max(M, fabs(d));
|
||||||
|
|
||||||
wordIter->V = V;
|
wordIter->V = V;
|
||||||
@ -631,8 +631,8 @@ double FabMapFBO::limitbisection(double v, double m) {
|
|||||||
|
|
||||||
double FabMapFBO::bennettInequality(double v, double m, double delta) {
|
double FabMapFBO::bennettInequality(double v, double m, double delta) {
|
||||||
double DMonV = delta * m / v;
|
double DMonV = delta * m / v;
|
||||||
double f_delta = log(DMonV + sqrt(pow(DMonV, 2.0) + 1));
|
double f_delta = std::log(DMonV + std::sqrt(std::pow(DMonV, 2.0) + 1));
|
||||||
return exp((v / pow(m, 2.0))*(cosh(f_delta) - 1 - DMonV * f_delta));
|
return std::exp((v / std::pow(m, 2.0))*(cosh(f_delta) - 1 - DMonV * f_delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FabMapFBO::compInfo(const WordStats& first, const WordStats& second) {
|
bool FabMapFBO::compInfo(const WordStats& first, const WordStats& second) {
|
||||||
@ -647,13 +647,13 @@ FabMap(_clTree, _PzGe, _PzGNe, _flags) {
|
|||||||
children.resize(clTree.cols);
|
children.resize(clTree.cols);
|
||||||
|
|
||||||
for (int q = 0; q < clTree.cols; q++) {
|
for (int q = 0; q < clTree.cols; q++) {
|
||||||
d1.push_back(log((this->*PzGL)(q, false, false, true) /
|
d1.push_back(std::log((this->*PzGL)(q, false, false, true) /
|
||||||
(this->*PzGL)(q, false, false, false)));
|
(this->*PzGL)(q, false, false, false)));
|
||||||
d2.push_back(log((this->*PzGL)(q, false, true, true) /
|
d2.push_back(std::log((this->*PzGL)(q, false, true, true) /
|
||||||
(this->*PzGL)(q, false, true, false)) - d1[q]);
|
(this->*PzGL)(q, false, true, false)) - d1[q]);
|
||||||
d3.push_back(log((this->*PzGL)(q, true, false, true) /
|
d3.push_back(std::log((this->*PzGL)(q, true, false, true) /
|
||||||
(this->*PzGL)(q, true, false, false))- d1[q]);
|
(this->*PzGL)(q, true, false, false))- d1[q]);
|
||||||
d4.push_back(log((this->*PzGL)(q, true, true, true) /
|
d4.push_back(std::log((this->*PzGL)(q, true, true, true) /
|
||||||
(this->*PzGL)(q, true, true, false))- d1[q]);
|
(this->*PzGL)(q, true, true, false))- d1[q]);
|
||||||
children[pq(q)].push_back(q);
|
children[pq(q)].push_back(q);
|
||||||
}
|
}
|
||||||
@ -664,7 +664,7 @@ FabMap2::~FabMap2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FabMap2::addTraining(const vector<Mat>& queryImgDescriptors) {
|
void FabMap2::addTraining(const std::vector<Mat>& queryImgDescriptors) {
|
||||||
for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
|
for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
|
||||||
CV_Assert(!queryImgDescriptors[i].empty());
|
CV_Assert(!queryImgDescriptors[i].empty());
|
||||||
CV_Assert(queryImgDescriptors[i].rows == 1);
|
CV_Assert(queryImgDescriptors[i].rows == 1);
|
||||||
@ -676,7 +676,7 @@ void FabMap2::addTraining(const vector<Mat>& queryImgDescriptors) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FabMap2::add(const vector<Mat>& queryImgDescriptors) {
|
void FabMap2::add(const std::vector<Mat>& queryImgDescriptors) {
|
||||||
for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
|
for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
|
||||||
CV_Assert(!queryImgDescriptors[i].empty());
|
CV_Assert(!queryImgDescriptors[i].empty());
|
||||||
CV_Assert(queryImgDescriptors[i].rows == 1);
|
CV_Assert(queryImgDescriptors[i].rows == 1);
|
||||||
@ -688,15 +688,15 @@ void FabMap2::add(const vector<Mat>& queryImgDescriptors) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FabMap2::getLikelihoods(const Mat& queryImgDescriptor,
|
void FabMap2::getLikelihoods(const Mat& queryImgDescriptor,
|
||||||
const vector<Mat>& testImageDescriptors, vector<IMatch>& matches) {
|
const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
|
||||||
|
|
||||||
if (&testImageDescriptors == &testImgDescriptors) {
|
if (&testImageDescriptors == &testImgDescriptors) {
|
||||||
getIndexLikelihoods(queryImgDescriptor, testDefaults, testInvertedMap,
|
getIndexLikelihoods(queryImgDescriptor, testDefaults, testInvertedMap,
|
||||||
matches);
|
matches);
|
||||||
} else {
|
} else {
|
||||||
CV_Assert(!(flags & MOTION_MODEL));
|
CV_Assert(!(flags & MOTION_MODEL));
|
||||||
vector<double> defaults;
|
std::vector<double> defaults;
|
||||||
std::map<int, vector<int> > invertedMap;
|
std::map<int, std::vector<int> > invertedMap;
|
||||||
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
for (size_t i = 0; i < testImageDescriptors.size(); i++) {
|
||||||
addToIndex(testImageDescriptors[i],defaults,invertedMap);
|
addToIndex(testImageDescriptors[i],defaults,invertedMap);
|
||||||
}
|
}
|
||||||
@ -708,7 +708,7 @@ double FabMap2::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
|
|||||||
|
|
||||||
CV_Assert(!trainingImgDescriptors.empty());
|
CV_Assert(!trainingImgDescriptors.empty());
|
||||||
|
|
||||||
vector<IMatch> matches;
|
std::vector<IMatch> matches;
|
||||||
getIndexLikelihoods(queryImgDescriptor, trainingDefaults,
|
getIndexLikelihoods(queryImgDescriptor, trainingDefaults,
|
||||||
trainingInvertedMap, matches);
|
trainingInvertedMap, matches);
|
||||||
|
|
||||||
@ -718,13 +718,13 @@ double FabMap2::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
|
|||||||
logsumexp(matches[i].likelihood, averageLogLikelihood);
|
logsumexp(matches[i].likelihood, averageLogLikelihood);
|
||||||
}
|
}
|
||||||
|
|
||||||
return averageLogLikelihood - log((double)trainingDefaults.size());
|
return averageLogLikelihood - std::log((double)trainingDefaults.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FabMap2::addToIndex(const Mat& queryImgDescriptor,
|
void FabMap2::addToIndex(const Mat& queryImgDescriptor,
|
||||||
vector<double>& defaults,
|
std::vector<double>& defaults,
|
||||||
std::map<int, vector<int> >& invertedMap) {
|
std::map<int, std::vector<int> >& invertedMap) {
|
||||||
defaults.push_back(0);
|
defaults.push_back(0);
|
||||||
for (int q = 0; q < clTree.cols; q++) {
|
for (int q = 0; q < clTree.cols; q++) {
|
||||||
if (queryImgDescriptor.at<float>(0,q) > 0) {
|
if (queryImgDescriptor.at<float>(0,q) > 0) {
|
||||||
@ -736,10 +736,10 @@ void FabMap2::addToIndex(const Mat& queryImgDescriptor,
|
|||||||
|
|
||||||
void FabMap2::getIndexLikelihoods(const Mat& queryImgDescriptor,
|
void FabMap2::getIndexLikelihoods(const Mat& queryImgDescriptor,
|
||||||
std::vector<double>& defaults,
|
std::vector<double>& defaults,
|
||||||
std::map<int, vector<int> >& invertedMap,
|
std::map<int, std::vector<int> >& invertedMap,
|
||||||
std::vector<IMatch>& matches) {
|
std::vector<IMatch>& matches) {
|
||||||
|
|
||||||
vector<int>::iterator LwithI, child;
|
std::vector<int>::iterator LwithI, child;
|
||||||
|
|
||||||
std::vector<double> likelihoods = defaults;
|
std::vector<double> likelihoods = defaults;
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ namespace cv
|
|||||||
{
|
{
|
||||||
for (j=0;j<(int)_photoreceptorsPrefilter.getNBcolumns();++j)
|
for (j=0;j<(int)_photoreceptorsPrefilter.getNBcolumns();++j)
|
||||||
{
|
{
|
||||||
float distanceToCenter=sqrt(((float)(i-halfRows)*(i-halfRows)+(j-halfColumns)*(j-halfColumns)));
|
float distanceToCenter=std::sqrt(((float)(i-halfRows)*(i-halfRows)+(j-halfColumns)*(j-halfColumns)));
|
||||||
if (distanceToCenter<minDistance)
|
if (distanceToCenter<minDistance)
|
||||||
{
|
{
|
||||||
float a=*(hybridParvoMagnoCoefTablePTR++)=0.5f+0.5f*(float)cos(CV_PI*distanceToCenter/minDistance);
|
float a=*(hybridParvoMagnoCoefTablePTR++)=0.5f+0.5f*(float)cos(CV_PI*distanceToCenter/minDistance);
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#include "opencv2/core/internal.hpp"
|
#include "opencv2/core/internal.hpp"
|
||||||
#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3
|
#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3
|
||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
template <typename Scalar> Scalar log2(Scalar v) { using std::log; return log(v)/log(Scalar(2)); }
|
template <typename Scalar> Scalar log2(Scalar v) { return std::log(v)/std::log(Scalar(2)); }
|
||||||
# endif
|
# endif
|
||||||
# if defined __GNUC__ && defined __APPLE__
|
# if defined __GNUC__ && defined __APPLE__
|
||||||
# pragma GCC diagnostic ignored "-Wshadow"
|
# pragma GCC diagnostic ignored "-Wshadow"
|
||||||
@ -172,7 +172,7 @@ static void warpImage( const Mat& image, const Mat& depth,
|
|||||||
{
|
{
|
||||||
const Rect rect = Rect(0, 0, image.cols, image.rows);
|
const Rect rect = Rect(0, 0, image.cols, image.rows);
|
||||||
|
|
||||||
vector<Point2f> points2d;
|
std::vector<Point2f> points2d;
|
||||||
Mat cloud, transformedCloud;
|
Mat cloud, transformedCloud;
|
||||||
|
|
||||||
cvtDepth2Cloud( depth, cloud, cameraMatrix );
|
cvtDepth2Cloud( depth, cloud, cameraMatrix );
|
||||||
@ -310,11 +310,11 @@ static
|
|||||||
void buildPyramids( const Mat& image0, const Mat& image1,
|
void buildPyramids( const Mat& image0, const Mat& image1,
|
||||||
const Mat& depth0, const Mat& depth1,
|
const Mat& depth0, const Mat& depth1,
|
||||||
const Mat& cameraMatrix, int sobelSize, double sobelScale,
|
const Mat& cameraMatrix, int sobelSize, double sobelScale,
|
||||||
const vector<float>& minGradMagnitudes,
|
const std::vector<float>& minGradMagnitudes,
|
||||||
vector<Mat>& pyramidImage0, vector<Mat>& pyramidDepth0,
|
std::vector<Mat>& pyramidImage0, std::vector<Mat>& pyramidDepth0,
|
||||||
vector<Mat>& pyramidImage1, vector<Mat>& pyramidDepth1,
|
std::vector<Mat>& pyramidImage1, std::vector<Mat>& pyramidDepth1,
|
||||||
vector<Mat>& pyramid_dI_dx1, vector<Mat>& pyramid_dI_dy1,
|
std::vector<Mat>& pyramid_dI_dx1, std::vector<Mat>& pyramid_dI_dy1,
|
||||||
vector<Mat>& pyramidTexturedMask1, vector<Mat>& pyramidCameraMatrix )
|
std::vector<Mat>& pyramidTexturedMask1, std::vector<Mat>& pyramidCameraMatrix )
|
||||||
{
|
{
|
||||||
const int pyramidMaxLevel = (int)minGradMagnitudes.size() - 1;
|
const int pyramidMaxLevel = (int)minGradMagnitudes.size() - 1;
|
||||||
|
|
||||||
@ -535,10 +535,10 @@ bool cv::RGBDOdometry( cv::Mat& Rt, const Mat& initRt,
|
|||||||
minGradientMagnitudes.size() == iterCounts.size() );
|
minGradientMagnitudes.size() == iterCounts.size() );
|
||||||
CV_Assert( initRt.empty() || (initRt.type()==CV_64FC1 && initRt.size()==Size(4,4) ) );
|
CV_Assert( initRt.empty() || (initRt.type()==CV_64FC1 && initRt.size()==Size(4,4) ) );
|
||||||
|
|
||||||
vector<int> defaultIterCounts;
|
std::vector<int> defaultIterCounts;
|
||||||
vector<float> defaultMinGradMagnitudes;
|
std::vector<float> defaultMinGradMagnitudes;
|
||||||
vector<int> const* iterCountsPtr = &iterCounts;
|
std::vector<int> const* iterCountsPtr = &iterCounts;
|
||||||
vector<float> const* minGradientMagnitudesPtr = &minGradientMagnitudes;
|
std::vector<float> const* minGradientMagnitudesPtr = &minGradientMagnitudes;
|
||||||
|
|
||||||
if( iterCounts.empty() || minGradientMagnitudes.empty() )
|
if( iterCounts.empty() || minGradientMagnitudes.empty() )
|
||||||
{
|
{
|
||||||
@ -560,7 +560,7 @@ bool cv::RGBDOdometry( cv::Mat& Rt, const Mat& initRt,
|
|||||||
|
|
||||||
preprocessDepth( depth0, depth1, validMask0, validMask1, minDepth, maxDepth );
|
preprocessDepth( depth0, depth1, validMask0, validMask1, minDepth, maxDepth );
|
||||||
|
|
||||||
vector<Mat> pyramidImage0, pyramidDepth0,
|
std::vector<Mat> pyramidImage0, pyramidDepth0,
|
||||||
pyramidImage1, pyramidDepth1, pyramid_dI_dx1, pyramid_dI_dy1, pyramidTexturedMask1,
|
pyramidImage1, pyramidDepth1, pyramid_dI_dx1, pyramid_dI_dy1, pyramidTexturedMask1,
|
||||||
pyramidCameraMatrix;
|
pyramidCameraMatrix;
|
||||||
buildPyramids( image0, image1, depth0, depth1, cameraMatrix, sobelSize, sobelScale, *minGradientMagnitudesPtr,
|
buildPyramids( image0, image1, depth0, depth1, cameraMatrix, sobelSize, sobelScale, *minGradientMagnitudesPtr,
|
||||||
|
@ -145,8 +145,8 @@ void SelfSimDescriptor::SSD(const Mat& img, Point pt, Mat& ssd) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SelfSimDescriptor::compute(const Mat& img, vector<float>& descriptors, Size winStride,
|
void SelfSimDescriptor::compute(const Mat& img, std::vector<float>& descriptors, Size winStride,
|
||||||
const vector<Point>& locations) const
|
const std::vector<Point>& locations) const
|
||||||
{
|
{
|
||||||
CV_Assert( img.depth() == CV_8U );
|
CV_Assert( img.depth() == CV_8U );
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ void SelfSimDescriptor::compute(const Mat& img, vector<float>& descriptors, Size
|
|||||||
int i, nwindows = locations.empty() ? gridSize.width*gridSize.height : (int)locations.size();
|
int i, nwindows = locations.empty() ? gridSize.width*gridSize.height : (int)locations.size();
|
||||||
int border = largeSize/2 + smallSize/2;
|
int border = largeSize/2 + smallSize/2;
|
||||||
int fsize = (int)getDescriptorSize();
|
int fsize = (int)getDescriptorSize();
|
||||||
vector<float> tempFeature(fsize+1);
|
std::vector<float> tempFeature(fsize+1);
|
||||||
descriptors.resize(fsize*nwindows + 1);
|
descriptors.resize(fsize*nwindows + 1);
|
||||||
Mat ssd(largeSize, largeSize, CV_32F), mappingMask;
|
Mat ssd(largeSize, largeSize, CV_32F), mappingMask;
|
||||||
computeLogPolarMapping(mappingMask);
|
computeLogPolarMapping(mappingMask);
|
||||||
|
@ -49,17 +49,9 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/********************************* local utility *********************************/
|
/********************************* local utility *********************************/
|
||||||
|
|
||||||
namespace cv
|
|
||||||
{
|
|
||||||
using std::log;
|
|
||||||
using std::max;
|
|
||||||
using std::min;
|
|
||||||
using std::sqrt;
|
|
||||||
}
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const static Scalar colors[] =
|
const static Scalar colors[] =
|
||||||
@ -85,13 +77,20 @@ namespace
|
|||||||
};
|
};
|
||||||
size_t colors_mum = sizeof(colors)/sizeof(colors[0]);
|
size_t colors_mum = sizeof(colors)/sizeof(colors[0]);
|
||||||
|
|
||||||
#if (defined __cplusplus && __cplusplus > 199711L) || defined _STLPORT_MAJOR
|
namespace {
|
||||||
#else
|
|
||||||
template<class FwIt, class T> void iota(FwIt first, FwIt last, T value) { while(first != last) *first++ = value++; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void computeNormals( const Octree& Octree, const vector<Point3f>& centers, vector<Point3f>& normals,
|
template<class FwIt, class T> inline void _iota(FwIt first, FwIt last, T value)
|
||||||
vector<uchar>& mask, float normalRadius, int minNeighbors = 20)
|
{
|
||||||
|
#if (defined __cplusplus && __cplusplus > 199711L) || defined _STLPORT_MAJOR
|
||||||
|
std::iota(first, last, value);
|
||||||
|
#else
|
||||||
|
while(first != last) *first++ = value++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void computeNormals( const Octree& Octree, const std::vector<Point3f>& centers, std::vector<Point3f>& normals,
|
||||||
|
std::vector<uchar>& mask, float normalRadius, int minNeighbors = 20)
|
||||||
{
|
{
|
||||||
size_t normals_size = centers.size();
|
size_t normals_size = centers.size();
|
||||||
normals.resize(normals_size);
|
normals.resize(normals_size);
|
||||||
@ -105,7 +104,7 @@ void computeNormals( const Octree& Octree, const vector<Point3f>& centers, vecto
|
|||||||
mask[m] = 1;
|
mask[m] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Point3f> buffer;
|
std::vector<Point3f> buffer;
|
||||||
buffer.reserve(128);
|
buffer.reserve(128);
|
||||||
SVD svd;
|
SVD svd;
|
||||||
|
|
||||||
@ -223,8 +222,8 @@ inline __m128i _mm_mullo_epi32_emul(const __m128i& a, __m128i& b)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void computeSpinImages( const Octree& Octree, const vector<Point3f>& points, const vector<Point3f>& normals,
|
void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points, const std::vector<Point3f>& normals,
|
||||||
vector<uchar>& mask, Mat& spinImages, int imageWidth, float binSize)
|
std::vector<uchar>& mask, Mat& spinImages, int imageWidth, float binSize)
|
||||||
{
|
{
|
||||||
float pixelsPerMeter = 1.f / binSize;
|
float pixelsPerMeter = 1.f / binSize;
|
||||||
float support = imageWidth * binSize;
|
float support = imageWidth * binSize;
|
||||||
@ -243,12 +242,12 @@ void computeSpinImages( const Octree& Octree, const vector<Point3f>& points, con
|
|||||||
int nthreads = getNumThreads();
|
int nthreads = getNumThreads();
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
vector< vector<Point3f> > pointsInSpherePool(nthreads);
|
std::vector< std::vector<Point3f> > pointsInSpherePool(nthreads);
|
||||||
for(i = 0; i < nthreads; i++)
|
for(i = 0; i < nthreads; i++)
|
||||||
pointsInSpherePool[i].reserve(2048);
|
pointsInSpherePool[i].reserve(2048);
|
||||||
|
|
||||||
float halfSuppport = support / 2;
|
float halfSuppport = support / 2;
|
||||||
float searchRad = support * sqrt(5.f) / 2; // sqrt(sup*sup + (sup/2) * (sup/2) )
|
float searchRad = support * std::sqrt(5.f) / 2; // std::sqrt(sup*sup + (sup/2) * (sup/2) )
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for num_threads(nthreads)
|
#pragma omp parallel for num_threads(nthreads)
|
||||||
@ -259,7 +258,7 @@ void computeSpinImages( const Octree& Octree, const vector<Point3f>& points, con
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int t = cvGetThreadNum();
|
int t = cvGetThreadNum();
|
||||||
vector<Point3f>& pointsInSphere = pointsInSpherePool[t];
|
std::vector<Point3f>& pointsInSphere = pointsInSpherePool[t];
|
||||||
|
|
||||||
const Point3f& center = points[i];
|
const Point3f& center = points[i];
|
||||||
Octree.getPointsWithinSphere(center, searchRad, pointsInSphere);
|
Octree.getPointsWithinSphere(center, searchRad, pointsInSphere);
|
||||||
@ -398,7 +397,7 @@ void computeSpinImages( const Octree& Octree, const vector<Point3f>& points, con
|
|||||||
if (beta >= support || beta < 0)
|
if (beta >= support || beta < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
alpha = sqrt( (new_center.x - pt.x) * (new_center.x - pt.x) +
|
alpha = std::sqrt( (new_center.x - pt.x) * (new_center.x - pt.x) +
|
||||||
(new_center.y - pt.y) * (new_center.y - pt.y) );
|
(new_center.y - pt.y) * (new_center.y - pt.y) );
|
||||||
|
|
||||||
float n1f = beta * pixelsPerMeter;
|
float n1f = beta * pixelsPerMeter;
|
||||||
@ -432,7 +431,7 @@ void computeSpinImages( const Octree& Octree, const vector<Point3f>& points, con
|
|||||||
const Point3f cv::Mesh3D::allzero(0.f, 0.f, 0.f);
|
const Point3f cv::Mesh3D::allzero(0.f, 0.f, 0.f);
|
||||||
|
|
||||||
cv::Mesh3D::Mesh3D() { resolution = -1; }
|
cv::Mesh3D::Mesh3D() { resolution = -1; }
|
||||||
cv::Mesh3D::Mesh3D(const vector<Point3f>& _vtx)
|
cv::Mesh3D::Mesh3D(const std::vector<Point3f>& _vtx)
|
||||||
{
|
{
|
||||||
resolution = -1;
|
resolution = -1;
|
||||||
vtx.resize(_vtx.size());
|
vtx.resize(_vtx.size());
|
||||||
@ -450,14 +449,14 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/)
|
|||||||
const int minReasonable = 10;
|
const int minReasonable = 10;
|
||||||
|
|
||||||
int tryNum = static_cast<int>(tryRatio * vtx.size());
|
int tryNum = static_cast<int>(tryRatio * vtx.size());
|
||||||
tryNum = min(max(tryNum, minReasonable), (int)vtx.size());
|
tryNum = std::min(std::max(tryNum, minReasonable), (int)vtx.size());
|
||||||
|
|
||||||
CvMat desc = cvMat((int)vtx.size(), 3, CV_32F, &vtx[0]);
|
CvMat desc = cvMat((int)vtx.size(), 3, CV_32F, &vtx[0]);
|
||||||
CvFeatureTree* tr = cvCreateKDTree(&desc);
|
CvFeatureTree* tr = cvCreateKDTree(&desc);
|
||||||
|
|
||||||
vector<double> dist(tryNum * neighbors);
|
std::vector<double> dist(tryNum * neighbors);
|
||||||
vector<int> inds(tryNum * neighbors);
|
std::vector<int> inds(tryNum * neighbors);
|
||||||
vector<Point3f> query;
|
std::vector<Point3f> query;
|
||||||
|
|
||||||
RNG& rng = theRNG();
|
RNG& rng = theRNG();
|
||||||
for(int i = 0; i < tryNum; ++i)
|
for(int i = 0; i < tryNum; ++i)
|
||||||
@ -476,7 +475,7 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/)
|
|||||||
|
|
||||||
dist.resize(remove(dist.begin(), dist.end(), invalid_dist) - dist.begin());
|
dist.resize(remove(dist.begin(), dist.end(), invalid_dist) - dist.begin());
|
||||||
|
|
||||||
sort(dist, less<double>());
|
sort(dist, std::less<double>());
|
||||||
|
|
||||||
return resolution = (float)dist[ dist.size() / 2 ];
|
return resolution = (float)dist[ dist.size() / 2 ];
|
||||||
#else
|
#else
|
||||||
@ -489,49 +488,49 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/)
|
|||||||
void cv::Mesh3D::computeNormals(float normalRadius, int minNeighbors)
|
void cv::Mesh3D::computeNormals(float normalRadius, int minNeighbors)
|
||||||
{
|
{
|
||||||
buildOctree();
|
buildOctree();
|
||||||
vector<uchar> mask;
|
std::vector<uchar> mask;
|
||||||
::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors);
|
::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::Mesh3D::computeNormals(const vector<int>& subset, float normalRadius, int minNeighbors)
|
void cv::Mesh3D::computeNormals(const std::vector<int>& subset, float normalRadius, int minNeighbors)
|
||||||
{
|
{
|
||||||
buildOctree();
|
buildOctree();
|
||||||
vector<uchar> mask(vtx.size(), 0);
|
std::vector<uchar> mask(vtx.size(), 0);
|
||||||
for(size_t i = 0; i < subset.size(); ++i)
|
for(size_t i = 0; i < subset.size(); ++i)
|
||||||
mask[subset[i]] = 1;
|
mask[subset[i]] = 1;
|
||||||
::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors);
|
::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::Mesh3D::writeAsVrml(const String& file, const vector<Scalar>& _colors) const
|
void cv::Mesh3D::writeAsVrml(const std::string& file, const std::vector<Scalar>& _colors) const
|
||||||
{
|
{
|
||||||
ofstream ofs(file.c_str());
|
std::ofstream ofs(file.c_str());
|
||||||
|
|
||||||
ofs << "#VRML V2.0 utf8" << endl;
|
ofs << "#VRML V2.0 utf8" << std::endl;
|
||||||
ofs << "Shape" << std::endl << "{" << endl;
|
ofs << "Shape" << std::endl << "{" << std::endl;
|
||||||
ofs << "geometry PointSet" << endl << "{" << endl;
|
ofs << "geometry PointSet" << std::endl << "{" << std::endl;
|
||||||
ofs << "coord Coordinate" << endl << "{" << endl;
|
ofs << "coord Coordinate" << std::endl << "{" << std::endl;
|
||||||
ofs << "point[" << endl;
|
ofs << "point[" << std::endl;
|
||||||
|
|
||||||
for(size_t i = 0; i < vtx.size(); ++i)
|
for(size_t i = 0; i < vtx.size(); ++i)
|
||||||
ofs << vtx[i].x << " " << vtx[i].y << " " << vtx[i].z << endl;
|
ofs << vtx[i].x << " " << vtx[i].y << " " << vtx[i].z << std::endl;
|
||||||
|
|
||||||
ofs << "]" << endl; //point[
|
ofs << "]" << std::endl; //point[
|
||||||
ofs << "}" << endl; //Coordinate{
|
ofs << "}" << std::endl; //Coordinate{
|
||||||
|
|
||||||
if (vtx.size() == _colors.size())
|
if (vtx.size() == _colors.size())
|
||||||
{
|
{
|
||||||
ofs << "color Color" << endl << "{" << endl;
|
ofs << "color Color" << std::endl << "{" << std::endl;
|
||||||
ofs << "color[" << endl;
|
ofs << "color[" << std::endl;
|
||||||
|
|
||||||
for(size_t i = 0; i < _colors.size(); ++i)
|
for(size_t i = 0; i < _colors.size(); ++i)
|
||||||
ofs << (float)_colors[i][2] << " " << (float)_colors[i][1] << " " << (float)_colors[i][0] << endl;
|
ofs << (float)_colors[i][2] << " " << (float)_colors[i][1] << " " << (float)_colors[i][0] << std::endl;
|
||||||
|
|
||||||
ofs << "]" << endl; //color[
|
ofs << "]" << std::endl; //color[
|
||||||
ofs << "}" << endl; //color Color{
|
ofs << "}" << std::endl; //color Color{
|
||||||
}
|
}
|
||||||
|
|
||||||
ofs << "}" << endl; //PointSet{
|
ofs << "}" << std::endl; //PointSet{
|
||||||
ofs << "}" << endl; //Shape{
|
ofs << "}" << std::endl; //Shape{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -624,7 +623,7 @@ bool cv::SpinImageModel::spinCorrelation(const Mat& spin1, const Mat& spin2, flo
|
|||||||
if (Nsum11 == sum1sum1 || Nsum22 == sum2sum2)
|
if (Nsum11 == sum1sum1 || Nsum22 == sum2sum2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
double corr = (Nsum12 - sum1 * sum2) / sqrt( (Nsum11 - sum1sum1) * (Nsum22 - sum2sum2) );
|
double corr = (Nsum12 - sum1 * sum2) / std::sqrt( (Nsum11 - sum1sum1) * (Nsum22 - sum2sum2) );
|
||||||
double atanh = Math::atanh(corr);
|
double atanh = Math::atanh(corr);
|
||||||
result = (float)( atanh * atanh - lambda * ( 1.0 / (N - 3) ) );
|
result = (float)( atanh * atanh - lambda * ( 1.0 / (N - 3) ) );
|
||||||
return true;
|
return true;
|
||||||
@ -636,13 +635,13 @@ inline Point2f cv::SpinImageModel::calcSpinMapCoo(const Point3f& p, const Point3
|
|||||||
float normalNorm = (float)norm(n);
|
float normalNorm = (float)norm(n);
|
||||||
float beta = PmV.dot(n) / normalNorm;
|
float beta = PmV.dot(n) / normalNorm;
|
||||||
float pmcNorm = (float)norm(PmV);
|
float pmcNorm = (float)norm(PmV);
|
||||||
float alpha = sqrt( pmcNorm * pmcNorm - beta * beta);
|
float alpha = std::sqrt( pmcNorm * pmcNorm - beta * beta);
|
||||||
return Point2f(alpha, beta);*/
|
return Point2f(alpha, beta);*/
|
||||||
|
|
||||||
float pmv_x = p.x - v.x, pmv_y = p.y - v.y, pmv_z = p.z - v.z;
|
float pmv_x = p.x - v.x, pmv_y = p.y - v.y, pmv_z = p.z - v.z;
|
||||||
|
|
||||||
float beta = (pmv_x * n.x + pmv_y + n.y + pmv_z * n.z) / sqrt(n.x * n.x + n.y * n.y + n.z * n.z);
|
float beta = (pmv_x * n.x + pmv_y + n.y + pmv_z * n.z) / std::sqrt(n.x * n.x + n.y * n.y + n.z * n.z);
|
||||||
float alpha = sqrt( pmv_x * pmv_x + pmv_y * pmv_y + pmv_z * pmv_z - beta * beta);
|
float alpha = std::sqrt( pmv_x * pmv_x + pmv_y * pmv_y + pmv_z * pmv_z - beta * beta);
|
||||||
return Point2f(alpha, beta);
|
return Point2f(alpha, beta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,7 +663,7 @@ inline float cv::SpinImageModel::geometricConsistency(const Point3f& pointScene1
|
|||||||
|
|
||||||
double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 ) ;
|
double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 ) ;
|
||||||
|
|
||||||
return (float)max(gc12, gc21);
|
return (float)std::max(gc12, gc21);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, const Point3f& normalScene1,
|
inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, const Point3f& normalScene1,
|
||||||
@ -682,15 +681,15 @@ inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, co
|
|||||||
double n_Ss2_to_s1 = norm(Ss2_to_s1 = calcSpinMapCoo(pointScene2, pointScene1, normalScene1));
|
double n_Ss2_to_s1 = norm(Ss2_to_s1 = calcSpinMapCoo(pointScene2, pointScene1, normalScene1));
|
||||||
|
|
||||||
double gc21 = 2 * norm(Sm2_to_m1 - Ss2_to_s1) / (n_Sm2_to_m1 + n_Ss2_to_s1 );
|
double gc21 = 2 * norm(Sm2_to_m1 - Ss2_to_s1) / (n_Sm2_to_m1 + n_Ss2_to_s1 );
|
||||||
double wgc21 = gc21 / (1 - exp( -(n_Sm2_to_m1 + n_Ss2_to_s1) * gamma05_inv ) );
|
double wgc21 = gc21 / (1 - std::exp( -(n_Sm2_to_m1 + n_Ss2_to_s1) * gamma05_inv ) );
|
||||||
|
|
||||||
double n_Sm1_to_m2 = norm(Sm1_to_m2 = calcSpinMapCoo(pointModel1, pointModel2, normalModel2));
|
double n_Sm1_to_m2 = norm(Sm1_to_m2 = calcSpinMapCoo(pointModel1, pointModel2, normalModel2));
|
||||||
double n_Ss1_to_s2 = norm(Ss1_to_s2 = calcSpinMapCoo(pointScene1, pointScene2, normalScene2));
|
double n_Ss1_to_s2 = norm(Ss1_to_s2 = calcSpinMapCoo(pointScene1, pointScene2, normalScene2));
|
||||||
|
|
||||||
double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 );
|
double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 );
|
||||||
double wgc12 = gc12 / (1 - exp( -(n_Sm1_to_m2 + n_Ss1_to_s2) * gamma05_inv ) );
|
double wgc12 = gc12 / (1 - std::exp( -(n_Sm1_to_m2 + n_Ss1_to_s2) * gamma05_inv ) );
|
||||||
|
|
||||||
return (float)max(wgc12, wgc21);
|
return (float)std::max(wgc12, wgc21);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -703,7 +702,7 @@ cv::SpinImageModel::SpinImageModel(const Mesh3D& _mesh) : mesh(_mesh) , out(0)
|
|||||||
cv::SpinImageModel::SpinImageModel() : out(0) { defaultParams(); }
|
cv::SpinImageModel::SpinImageModel() : out(0) { defaultParams(); }
|
||||||
cv::SpinImageModel::~SpinImageModel() {}
|
cv::SpinImageModel::~SpinImageModel() {}
|
||||||
|
|
||||||
void cv::SpinImageModel::setLogger(ostream* log) { out = log; }
|
void cv::SpinImageModel::setLogger(std::ostream* log) { out = log; }
|
||||||
|
|
||||||
void cv::SpinImageModel::defaultParams()
|
void cv::SpinImageModel::defaultParams()
|
||||||
{
|
{
|
||||||
@ -723,14 +722,14 @@ void cv::SpinImageModel::defaultParams()
|
|||||||
Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, size_t yCount) const
|
Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, size_t yCount) const
|
||||||
{
|
{
|
||||||
int spinNum = (int)getSpinCount();
|
int spinNum = (int)getSpinCount();
|
||||||
int num = min(spinNum, (int)(xCount * yCount));
|
int num = std::min(spinNum, (int)(xCount * yCount));
|
||||||
|
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
return Mat();
|
return Mat();
|
||||||
|
|
||||||
RNG& rng = theRNG();
|
RNG& rng = theRNG();
|
||||||
|
|
||||||
vector<Mat> spins;
|
std::vector<Mat> spins;
|
||||||
for(int i = 0; i < num; ++i)
|
for(int i = 0; i < num; ++i)
|
||||||
spins.push_back(getSpinImage( rng.next() % spinNum ).reshape(1, imageWidth));
|
spins.push_back(getSpinImage( rng.next() % spinNum ).reshape(1, imageWidth));
|
||||||
|
|
||||||
@ -750,7 +749,7 @@ Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount,
|
|||||||
{
|
{
|
||||||
double m;
|
double m;
|
||||||
minMaxLoc(spins[i], 0, &m);
|
minMaxLoc(spins[i], 0, &m);
|
||||||
totalMax = max(m, totalMax);
|
totalMax = std::max(m, totalMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < num; ++i)
|
for(int i = 0; i < num; ++i)
|
||||||
@ -787,7 +786,7 @@ Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount,
|
|||||||
|
|
||||||
void cv::SpinImageModel::selectRandomSubset(float ratio)
|
void cv::SpinImageModel::selectRandomSubset(float ratio)
|
||||||
{
|
{
|
||||||
ratio = min(max(ratio, 0.f), 1.f);
|
ratio = std::min(std::max(ratio, 0.f), 1.f);
|
||||||
|
|
||||||
size_t vtxSize = mesh.vtx.size();
|
size_t vtxSize = mesh.vtx.size();
|
||||||
size_t setSize = static_cast<size_t>(vtxSize * ratio);
|
size_t setSize = static_cast<size_t>(vtxSize * ratio);
|
||||||
@ -799,14 +798,14 @@ void cv::SpinImageModel::selectRandomSubset(float ratio)
|
|||||||
else if (setSize == vtxSize)
|
else if (setSize == vtxSize)
|
||||||
{
|
{
|
||||||
subset.resize(vtxSize);
|
subset.resize(vtxSize);
|
||||||
iota(subset.begin(), subset.end(), 0);
|
_iota(subset.begin(), subset.end(), 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RNG& rnd = theRNG();
|
RNG& rnd = theRNG();
|
||||||
|
|
||||||
vector<size_t> left(vtxSize);
|
std::vector<size_t> left(vtxSize);
|
||||||
iota(left.begin(), left.end(), (size_t)0);
|
_iota(left.begin(), left.end(), (size_t)0);
|
||||||
|
|
||||||
subset.resize(setSize);
|
subset.resize(setSize);
|
||||||
for(size_t i = 0; i < setSize; ++i)
|
for(size_t i = 0; i < setSize; ++i)
|
||||||
@ -817,20 +816,20 @@ void cv::SpinImageModel::selectRandomSubset(float ratio)
|
|||||||
left[pos] = left.back();
|
left[pos] = left.back();
|
||||||
left.resize(left.size() - 1);
|
left.resize(left.size() - 1);
|
||||||
}
|
}
|
||||||
sort(subset, less<int>());
|
sort(subset, std::less<int>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::SpinImageModel::setSubset(const vector<int>& ss)
|
void cv::SpinImageModel::setSubset(const std::vector<int>& ss)
|
||||||
{
|
{
|
||||||
subset = ss;
|
subset = ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::SpinImageModel::repackSpinImages(const vector<uchar>& mask, Mat& _spinImages, bool reAlloc) const
|
void cv::SpinImageModel::repackSpinImages(const std::vector<uchar>& mask, Mat& _spinImages, bool reAlloc) const
|
||||||
{
|
{
|
||||||
if (reAlloc)
|
if (reAlloc)
|
||||||
{
|
{
|
||||||
size_t spinCount = mask.size() - count(mask.begin(), mask.end(), (uchar)0);
|
size_t spinCount = mask.size() - std::count(mask.begin(), mask.end(), (uchar)0);
|
||||||
Mat newImgs((int)spinCount, _spinImages.cols, _spinImages.type());
|
Mat newImgs((int)spinCount, _spinImages.cols, _spinImages.type());
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
@ -846,7 +845,7 @@ void cv::SpinImageModel::repackSpinImages(const vector<uchar>& mask, Mat& _spinI
|
|||||||
{
|
{
|
||||||
int last = (int)mask.size();
|
int last = (int)mask.size();
|
||||||
|
|
||||||
int dest = (int)(find(mask.begin(), mask.end(), (uchar)0) - mask.begin());
|
int dest = (int)(std::find(mask.begin(), mask.end(), (uchar)0) - mask.begin());
|
||||||
if (dest == last)
|
if (dest == last)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -879,21 +878,21 @@ void cv::SpinImageModel::compute()
|
|||||||
{
|
{
|
||||||
mesh.computeNormals(normalRadius, minNeighbors);
|
mesh.computeNormals(normalRadius, minNeighbors);
|
||||||
subset.resize(mesh.vtx.size());
|
subset.resize(mesh.vtx.size());
|
||||||
iota(subset.begin(), subset.end(), 0);
|
_iota(subset.begin(), subset.end(), 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mesh.computeNormals(subset, normalRadius, minNeighbors);
|
mesh.computeNormals(subset, normalRadius, minNeighbors);
|
||||||
|
|
||||||
vector<uchar> mask(mesh.vtx.size(), 0);
|
std::vector<uchar> mask(mesh.vtx.size(), 0);
|
||||||
for(size_t i = 0; i < subset.size(); ++i)
|
for(size_t i = 0; i < subset.size(); ++i)
|
||||||
if (mesh.normals[subset[i]] == Mesh3D::allzero)
|
if (mesh.normals[subset[i]] == Mesh3D::allzero)
|
||||||
subset[i] = -1;
|
subset[i] = -1;
|
||||||
else
|
else
|
||||||
mask[subset[i]] = 1;
|
mask[subset[i]] = 1;
|
||||||
subset.resize( remove(subset.begin(), subset.end(), -1) - subset.begin() );
|
subset.resize( std::remove(subset.begin(), subset.end(), -1) - subset.begin() );
|
||||||
|
|
||||||
vector<Point3f> vtx;
|
std::vector<Point3f> vtx;
|
||||||
vector<Point3f> normals;
|
std::vector<Point3f> normals;
|
||||||
for(size_t i = 0; i < mask.size(); ++i)
|
for(size_t i = 0; i < mask.size(); ++i)
|
||||||
if(mask[i])
|
if(mask[i])
|
||||||
{
|
{
|
||||||
@ -901,7 +900,7 @@ void cv::SpinImageModel::compute()
|
|||||||
normals.push_back(mesh.normals[i]);
|
normals.push_back(mesh.normals[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<uchar> spinMask(vtx.size(), 1);
|
std::vector<uchar> spinMask(vtx.size(), 1);
|
||||||
computeSpinImages( mesh.octree, vtx, normals, spinMask, spinImages, imageWidth, binSize);
|
computeSpinImages( mesh.octree, vtx, normals, spinMask, spinImages, imageWidth, binSize);
|
||||||
repackSpinImages(spinMask, spinImages);
|
repackSpinImages(spinMask, spinImages);
|
||||||
|
|
||||||
@ -909,19 +908,19 @@ void cv::SpinImageModel::compute()
|
|||||||
for(size_t i = 0; i < mask.size(); ++i)
|
for(size_t i = 0; i < mask.size(); ++i)
|
||||||
if(mask[i])
|
if(mask[i])
|
||||||
if (spinMask[mask_pos++] == 0)
|
if (spinMask[mask_pos++] == 0)
|
||||||
subset.resize( remove(subset.begin(), subset.end(), (int)i) - subset.begin() );
|
subset.resize( std::remove(subset.begin(), subset.end(), (int)i) - subset.begin() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::SpinImageModel::matchSpinToModel(const Mat& spin, vector<int>& indeces, vector<float>& corrCoeffs, bool useExtremeOutliers) const
|
void cv::SpinImageModel::matchSpinToModel(const Mat& spin, std::vector<int>& indeces, std::vector<float>& corrCoeffs, bool useExtremeOutliers) const
|
||||||
{
|
{
|
||||||
const SpinImageModel& model = *this;
|
const SpinImageModel& model = *this;
|
||||||
|
|
||||||
indeces.clear();
|
indeces.clear();
|
||||||
corrCoeffs.clear();
|
corrCoeffs.clear();
|
||||||
|
|
||||||
vector<float> corrs(model.spinImages.rows);
|
std::vector<float> corrs(model.spinImages.rows);
|
||||||
vector<uchar> masks(model.spinImages.rows);
|
std::vector<uchar> masks(model.spinImages.rows);
|
||||||
vector<float> cleanCorrs;
|
std::vector<float> cleanCorrs;
|
||||||
cleanCorrs.reserve(model.spinImages.rows);
|
cleanCorrs.reserve(model.spinImages.rows);
|
||||||
|
|
||||||
for(int i = 0; i < model.spinImages.rows; ++i)
|
for(int i = 0; i < model.spinImages.rows; ++i)
|
||||||
@ -936,7 +935,7 @@ void cv::SpinImageModel::matchSpinToModel(const Mat& spin, vector<int>& indeces,
|
|||||||
if(total < 5)
|
if(total < 5)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sort(cleanCorrs, less<float>());
|
sort(cleanCorrs, std::less<float>());
|
||||||
|
|
||||||
float lower_fourth = cleanCorrs[(1 * total) / 4 - 1];
|
float lower_fourth = cleanCorrs[(1 * total) / 4 - 1];
|
||||||
float upper_fourth = cleanCorrs[(3 * total) / 4 - 0];
|
float upper_fourth = cleanCorrs[(3 * total) / 4 - 0];
|
||||||
@ -971,7 +970,7 @@ struct Match
|
|||||||
operator float() const { return measure; }
|
operator float() const { return measure; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef set<size_t> group_t;
|
typedef std::set<size_t> group_t;
|
||||||
typedef group_t::iterator iter;
|
typedef group_t::iterator iter;
|
||||||
typedef group_t::const_iterator citer;
|
typedef group_t::const_iterator citer;
|
||||||
|
|
||||||
@ -986,10 +985,10 @@ struct WgcHelper
|
|||||||
float Wgc(const size_t corespInd, const group_t& group) const
|
float Wgc(const size_t corespInd, const group_t& group) const
|
||||||
{
|
{
|
||||||
const float* wgcLine = mat.ptr<float>((int)corespInd);
|
const float* wgcLine = mat.ptr<float>((int)corespInd);
|
||||||
float maximum = numeric_limits<float>::min();
|
float maximum = std::numeric_limits<float>::min();
|
||||||
|
|
||||||
for(citer pos = group.begin(); pos != group.end(); ++pos)
|
for(citer pos = group.begin(); pos != group.end(); ++pos)
|
||||||
maximum = max(wgcLine[*pos], maximum);
|
maximum = std::max(wgcLine[*pos], maximum);
|
||||||
|
|
||||||
return maximum;
|
return maximum;
|
||||||
}
|
}
|
||||||
@ -999,7 +998,7 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::SpinImageModel::match(const SpinImageModel& scene, vector< vector<Vec2i> >& result)
|
void cv::SpinImageModel::match(const SpinImageModel& scene, std::vector< std::vector<Vec2i> >& result)
|
||||||
{
|
{
|
||||||
if (mesh.vtx.empty())
|
if (mesh.vtx.empty())
|
||||||
throw Mesh3D::EmptyMeshException();
|
throw Mesh3D::EmptyMeshException();
|
||||||
@ -1007,8 +1006,8 @@ private:
|
|||||||
result.clear();
|
result.clear();
|
||||||
|
|
||||||
SpinImageModel& model = *this;
|
SpinImageModel& model = *this;
|
||||||
const float infinity = numeric_limits<float>::infinity();
|
const float infinity = std::numeric_limits<float>::infinity();
|
||||||
const float float_max = numeric_limits<float>::max();
|
const float float_max = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
/* estimate gamma */
|
/* estimate gamma */
|
||||||
if (model.gamma == 0.f)
|
if (model.gamma == 0.f)
|
||||||
@ -1021,40 +1020,40 @@ private:
|
|||||||
/* estimate lambda */
|
/* estimate lambda */
|
||||||
if (model.lambda == 0.f)
|
if (model.lambda == 0.f)
|
||||||
{
|
{
|
||||||
vector<int> nonzero(model.spinImages.rows);
|
std::vector<int> nonzero(model.spinImages.rows);
|
||||||
for(int i = 0; i < model.spinImages.rows; ++i)
|
for(int i = 0; i < model.spinImages.rows; ++i)
|
||||||
nonzero[i] = countNonZero(model.spinImages.row(i));
|
nonzero[i] = countNonZero(model.spinImages.row(i));
|
||||||
sort(nonzero, less<int>());
|
sort(nonzero, std::less<int>());
|
||||||
model.lambda = static_cast<float>( nonzero[ nonzero.size()/2 ] ) / 2;
|
model.lambda = static_cast<float>( nonzero[ nonzero.size()/2 ] ) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
TickMeter corr_timer;
|
TickMeter corr_timer;
|
||||||
corr_timer.start();
|
corr_timer.start();
|
||||||
vector<Match> allMatches;
|
std::vector<Match> allMatches;
|
||||||
for(int i = 0; i < scene.spinImages.rows; ++i)
|
for(int i = 0; i < scene.spinImages.rows; ++i)
|
||||||
{
|
{
|
||||||
vector<int> indeces;
|
std::vector<int> indeces;
|
||||||
vector<float> coeffs;
|
std::vector<float> coeffs;
|
||||||
matchSpinToModel(scene.spinImages.row(i), indeces, coeffs);
|
matchSpinToModel(scene.spinImages.row(i), indeces, coeffs);
|
||||||
for(size_t t = 0; t < indeces.size(); ++t)
|
for(size_t t = 0; t < indeces.size(); ++t)
|
||||||
allMatches.push_back(Match(i, indeces[t], coeffs[t]));
|
allMatches.push_back(Match(i, indeces[t], coeffs[t]));
|
||||||
|
|
||||||
if (out) if (i % 100 == 0) *out << "Comparing scene spinimage " << i << " of " << scene.spinImages.rows << endl;
|
if (out) if (i % 100 == 0) *out << "Comparing scene spinimage " << i << " of " << scene.spinImages.rows << std::endl;
|
||||||
}
|
}
|
||||||
corr_timer.stop();
|
corr_timer.stop();
|
||||||
if (out) *out << "Spin correlation time = " << corr_timer << endl;
|
if (out) *out << "Spin correlation time = " << corr_timer << std::endl;
|
||||||
if (out) *out << "Matches number = " << allMatches.size() << endl;
|
if (out) *out << "Matches number = " << allMatches.size() << std::endl;
|
||||||
|
|
||||||
if(allMatches.empty())
|
if(allMatches.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* filtering by similarity measure */
|
/* filtering by similarity measure */
|
||||||
const float fraction = 0.5f;
|
const float fraction = 0.5f;
|
||||||
float maxMeasure = max_element(allMatches.begin(), allMatches.end(), less<float>())->measure;
|
float maxMeasure = max_element(allMatches.begin(), allMatches.end(), std::less<float>())->measure;
|
||||||
allMatches.erase(
|
allMatches.erase(
|
||||||
remove_if(allMatches.begin(), allMatches.end(), bind2nd(less<float>(), maxMeasure * fraction)),
|
remove_if(allMatches.begin(), allMatches.end(), bind2nd(std::less<float>(), maxMeasure * fraction)),
|
||||||
allMatches.end());
|
allMatches.end());
|
||||||
if (out) *out << "Matches number [filtered by similarity measure] = " << allMatches.size() << endl;
|
if (out) *out << "Matches number [filtered by similarity measure] = " << allMatches.size() << std::endl;
|
||||||
|
|
||||||
int matchesSize = (int)allMatches.size();
|
int matchesSize = (int)allMatches.size();
|
||||||
if(matchesSize == 0)
|
if(matchesSize == 0)
|
||||||
@ -1101,16 +1100,16 @@ private:
|
|||||||
allMatches[i].measure = infinity;
|
allMatches[i].measure = infinity;
|
||||||
}
|
}
|
||||||
allMatches.erase(
|
allMatches.erase(
|
||||||
remove_if(allMatches.begin(), allMatches.end(), bind2nd(equal_to<float>(), infinity)),
|
std::remove_if(allMatches.begin(), allMatches.end(), std::bind2nd(std::equal_to<float>(), infinity)),
|
||||||
allMatches.end());
|
allMatches.end());
|
||||||
if (out) *out << "Matches number [filtered by geometric consistency] = " << allMatches.size() << endl;
|
if (out) *out << "Matches number [filtered by geometric consistency] = " << allMatches.size() << std::endl;
|
||||||
|
|
||||||
|
|
||||||
matchesSize = (int)allMatches.size();
|
matchesSize = (int)allMatches.size();
|
||||||
if(matchesSize == 0)
|
if(matchesSize == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (out) *out << "grouping ..." << endl;
|
if (out) *out << "grouping ..." << std::endl;
|
||||||
|
|
||||||
Mat groupingMat((int)matchesSize, (int)matchesSize, CV_32F);
|
Mat groupingMat((int)matchesSize, (int)matchesSize, CV_32F);
|
||||||
groupingMat = Scalar(0);
|
groupingMat = Scalar(0);
|
||||||
@ -1153,13 +1152,13 @@ private:
|
|||||||
for(int i = 0; i < matchesSize; ++i)
|
for(int i = 0; i < matchesSize; ++i)
|
||||||
allMatchesInds.insert(i);
|
allMatchesInds.insert(i);
|
||||||
|
|
||||||
vector<float> buf(matchesSize);
|
std::vector<float> buf(matchesSize);
|
||||||
float *buf_beg = &buf[0];
|
float *buf_beg = &buf[0];
|
||||||
vector<group_t> groups;
|
std::vector<group_t> groups;
|
||||||
|
|
||||||
for(int g = 0; g < matchesSize; ++g)
|
for(int g = 0; g < matchesSize; ++g)
|
||||||
{
|
{
|
||||||
if (out) if (g % 100 == 0) *out << "G = " << g << endl;
|
if (out) if (g % 100 == 0) *out << "G = " << g << std::endl;
|
||||||
|
|
||||||
group_t left = allMatchesInds;
|
group_t left = allMatchesInds;
|
||||||
group_t group;
|
group_t group;
|
||||||
@ -1174,7 +1173,7 @@ private:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
std::transform(left.begin(), left.end(), buf_beg, WgcHelper(group, groupingMat));
|
std::transform(left.begin(), left.end(), buf_beg, WgcHelper(group, groupingMat));
|
||||||
size_t minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg;
|
size_t minInd = std::min_element(buf_beg, buf_beg + left_size) - buf_beg;
|
||||||
|
|
||||||
if (buf[minInd] < model.T_GroupingCorespondances) /* can add corespondance to group */
|
if (buf[minInd] < model.T_GroupingCorespondances) /* can add corespondance to group */
|
||||||
{
|
{
|
||||||
@ -1197,7 +1196,7 @@ private:
|
|||||||
{
|
{
|
||||||
const group_t& group = groups[i];
|
const group_t& group = groups[i];
|
||||||
|
|
||||||
vector< Vec2i > outgrp;
|
std::vector< Vec2i > outgrp;
|
||||||
for(citer pos = group.begin(); pos != group.end(); ++pos)
|
for(citer pos = group.begin(); pos != group.end(); ++pos)
|
||||||
{
|
{
|
||||||
const Match& m = allMatches[*pos];
|
const Match& m = allMatches[*pos];
|
||||||
|
@ -144,11 +144,11 @@ void StereoVar::VariationalSolver(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
|
|||||||
|
|
||||||
|
|
||||||
if (flags & USE_SMART_ID) {
|
if (flags & USE_SMART_ID) {
|
||||||
double scale = pow(pyrScale, (double) level) * (1 + pyrScale);
|
double scale = std::pow(pyrScale, (double) level) * (1 + pyrScale);
|
||||||
N = (int) (N / scale);
|
N = (int) (N / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
double scale = pow(pyrScale, (double) level);
|
double scale = std::pow(pyrScale, (double) level);
|
||||||
Fi /= (float) scale;
|
Fi /= (float) scale;
|
||||||
l *= (float) scale;
|
l *= (float) scale;
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level)
|
|||||||
|
|
||||||
void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
|
void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
|
||||||
{
|
{
|
||||||
double scale = pow(pyrScale, (double) level);
|
double scale = std::pow(pyrScale, (double) level);
|
||||||
CvSize frmSize = cvSize((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5));
|
CvSize frmSize = cvSize((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5));
|
||||||
Mat I1_h, I2_h, I2x_h, u_h;
|
Mat I1_h, I2_h, I2x_h, u_h;
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ void StereoVar::autoParams()
|
|||||||
|
|
||||||
if (maxD) {
|
if (maxD) {
|
||||||
levels = 0;
|
levels = 0;
|
||||||
while ( pow(pyrScale, levels) * maxD > 1.5) levels ++;
|
while ( std::pow(pyrScale, levels) * maxD > 1.5) levels ++;
|
||||||
levels++;
|
levels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ namespace cv
|
|||||||
double diff=(*(bufferPTR++)-meanValue);
|
double diff=(*(bufferPTR++)-meanValue);
|
||||||
standardDeviation+=diff*diff;
|
standardDeviation+=diff*diff;
|
||||||
}
|
}
|
||||||
return sqrt(standardDeviation/this->size());
|
return std::sqrt(standardDeviation/this->size());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -513,7 +513,7 @@ namespace cv
|
|||||||
stdValue+=inputMinusMean*inputMinusMean;
|
stdValue+=inputMinusMean*inputMinusMean;
|
||||||
}
|
}
|
||||||
|
|
||||||
stdValue=sqrt(stdValue/((type)_NBpixels));
|
stdValue=std::sqrt(stdValue/((type)_NBpixels));
|
||||||
// adjust luminance in regard of mean and std value;
|
// adjust luminance in regard of mean and std value;
|
||||||
inputOutputBufferPTR=inputOutputBuffer;
|
inputOutputBufferPTR=inputOutputBuffer;
|
||||||
for (size_t index=0;index<_NBpixels;++index, ++inputOutputBufferPTR)
|
for (size_t index=0;index<_NBpixels;++index, ++inputOutputBufferPTR)
|
||||||
|
@ -548,11 +548,11 @@ Returns the node content as double.
|
|||||||
:returns: The node content as double.
|
:returns: The node content as double.
|
||||||
|
|
||||||
|
|
||||||
FileNode::operator string
|
FileNode::operator std::string
|
||||||
-------------------------
|
------------------------------
|
||||||
Returns the node content as text string.
|
Returns the node content as text string.
|
||||||
|
|
||||||
.. ocv:function:: FileNode::operator string() const
|
.. ocv:function:: FileNode::operator std::string() const
|
||||||
|
|
||||||
:returns: The node content as a text string.
|
:returns: The node content as a text string.
|
||||||
|
|
||||||
|
@ -74,18 +74,12 @@ namespace cv {
|
|||||||
#undef max
|
#undef max
|
||||||
#undef Complex
|
#undef Complex
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
using std::string;
|
|
||||||
using std::ptrdiff_t;
|
|
||||||
|
|
||||||
template<typename _Tp> class CV_EXPORTS Size_;
|
template<typename _Tp> class CV_EXPORTS Size_;
|
||||||
template<typename _Tp> class CV_EXPORTS Point_;
|
template<typename _Tp> class CV_EXPORTS Point_;
|
||||||
template<typename _Tp> class CV_EXPORTS Rect_;
|
template<typename _Tp> class CV_EXPORTS Rect_;
|
||||||
template<typename _Tp, int cn> class CV_EXPORTS Vec;
|
template<typename _Tp, int cn> class CV_EXPORTS Vec;
|
||||||
template<typename _Tp, int m, int n> class CV_EXPORTS Matx;
|
template<typename _Tp, int m, int n> class CV_EXPORTS Matx;
|
||||||
|
|
||||||
typedef std::string String;
|
|
||||||
|
|
||||||
class Mat;
|
class Mat;
|
||||||
class SparseMat;
|
class SparseMat;
|
||||||
typedef Mat MatND;
|
typedef Mat MatND;
|
||||||
@ -111,8 +105,8 @@ template<typename _Tp> class CV_EXPORTS MatCommaInitializer_;
|
|||||||
|
|
||||||
template<typename _Tp, size_t fixed_size = 1024/sizeof(_Tp)+8> class CV_EXPORTS AutoBuffer;
|
template<typename _Tp, size_t fixed_size = 1024/sizeof(_Tp)+8> class CV_EXPORTS AutoBuffer;
|
||||||
|
|
||||||
CV_EXPORTS string format( const char* fmt, ... );
|
CV_EXPORTS std::string format( const char* fmt, ... );
|
||||||
CV_EXPORTS string tempfile( const char* suffix CV_DEFAULT(0));
|
CV_EXPORTS std::string tempfile( const char* suffix CV_DEFAULT(0));
|
||||||
|
|
||||||
// matrix decomposition types
|
// matrix decomposition types
|
||||||
enum { DECOMP_LU=0, DECOMP_SVD=1, DECOMP_EIG=2, DECOMP_CHOLESKY=3, DECOMP_QR=4, DECOMP_NORMAL=16 };
|
enum { DECOMP_LU=0, DECOMP_SVD=1, DECOMP_EIG=2, DECOMP_CHOLESKY=3, DECOMP_QR=4, DECOMP_NORMAL=16 };
|
||||||
@ -138,7 +132,7 @@ public:
|
|||||||
Full constructor. Normally the constuctor is not called explicitly.
|
Full constructor. Normally the constuctor is not called explicitly.
|
||||||
Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
|
Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
|
||||||
*/
|
*/
|
||||||
Exception(int _code, const string& _err, const string& _func, const string& _file, int _line);
|
Exception(int _code, const std::string& _err, const std::string& _func, const std::string& _file, int _line);
|
||||||
virtual ~Exception() throw();
|
virtual ~Exception() throw();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -147,12 +141,12 @@ public:
|
|||||||
virtual const char *what() const throw();
|
virtual const char *what() const throw();
|
||||||
void formatMessage();
|
void formatMessage();
|
||||||
|
|
||||||
string msg; ///< the formatted error message
|
std::string msg; ///< the formatted error message
|
||||||
|
|
||||||
int code; ///< error code @see CVStatus
|
int code; ///< error code @see CVStatus
|
||||||
string err; ///< error description
|
std::string err; ///< error description
|
||||||
string func; ///< function name. Available only when the compiler supports __func__ macro
|
std::string func; ///< function name. Available only when the compiler supports __func__ macro
|
||||||
string file; ///< source file name where the error has occured
|
std::string file; ///< source file name where the error has occured
|
||||||
int line; ///< line number in the source file where the error has occured
|
int line; ///< line number in the source file where the error has occured
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,7 +210,7 @@ CV_EXPORTS void setNumThreads(int nthreads);
|
|||||||
CV_EXPORTS int getNumThreads();
|
CV_EXPORTS int getNumThreads();
|
||||||
CV_EXPORTS int getThreadNum();
|
CV_EXPORTS int getThreadNum();
|
||||||
|
|
||||||
CV_EXPORTS_W const string& getBuildInformation();
|
CV_EXPORTS_W const std::string& getBuildInformation();
|
||||||
|
|
||||||
//! Returns the number of ticks.
|
//! Returns the number of ticks.
|
||||||
|
|
||||||
@ -1317,10 +1311,10 @@ public:
|
|||||||
_InputArray(const Mat& m);
|
_InputArray(const Mat& m);
|
||||||
_InputArray(const MatExpr& expr);
|
_InputArray(const MatExpr& expr);
|
||||||
template<typename _Tp> _InputArray(const _Tp* vec, int n);
|
template<typename _Tp> _InputArray(const _Tp* vec, int n);
|
||||||
template<typename _Tp> _InputArray(const vector<_Tp>& vec);
|
template<typename _Tp> _InputArray(const std::vector<_Tp>& vec);
|
||||||
template<typename _Tp> _InputArray(const vector<vector<_Tp> >& vec);
|
template<typename _Tp> _InputArray(const std::vector<std::vector<_Tp> >& vec);
|
||||||
_InputArray(const vector<Mat>& vec);
|
_InputArray(const std::vector<Mat>& vec);
|
||||||
template<typename _Tp> _InputArray(const vector<Mat_<_Tp> >& vec);
|
template<typename _Tp> _InputArray(const std::vector<Mat_<_Tp> >& vec);
|
||||||
template<typename _Tp> _InputArray(const Mat_<_Tp>& m);
|
template<typename _Tp> _InputArray(const Mat_<_Tp>& m);
|
||||||
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
|
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
|
||||||
_InputArray(const Scalar& s);
|
_InputArray(const Scalar& s);
|
||||||
@ -1330,7 +1324,7 @@ public:
|
|||||||
_InputArray(const gpu::GpuMat& d_mat);
|
_InputArray(const gpu::GpuMat& d_mat);
|
||||||
|
|
||||||
virtual Mat getMat(int i=-1) const;
|
virtual Mat getMat(int i=-1) const;
|
||||||
virtual void getMatVector(vector<Mat>& mv) const;
|
virtual void getMatVector(std::vector<Mat>& mv) const;
|
||||||
virtual GlBuffer getGlBuffer() const;
|
virtual GlBuffer getGlBuffer() const;
|
||||||
virtual GlTexture2D getGlTexture2D() const;
|
virtual GlTexture2D getGlTexture2D() const;
|
||||||
virtual gpu::GpuMat getGpuMat() const;
|
virtual gpu::GpuMat getGpuMat() const;
|
||||||
@ -1375,10 +1369,10 @@ public:
|
|||||||
_OutputArray();
|
_OutputArray();
|
||||||
|
|
||||||
_OutputArray(Mat& m);
|
_OutputArray(Mat& m);
|
||||||
template<typename _Tp> _OutputArray(vector<_Tp>& vec);
|
template<typename _Tp> _OutputArray(std::vector<_Tp>& vec);
|
||||||
template<typename _Tp> _OutputArray(vector<vector<_Tp> >& vec);
|
template<typename _Tp> _OutputArray(std::vector<std::vector<_Tp> >& vec);
|
||||||
_OutputArray(vector<Mat>& vec);
|
_OutputArray(std::vector<Mat>& vec);
|
||||||
template<typename _Tp> _OutputArray(vector<Mat_<_Tp> >& vec);
|
template<typename _Tp> _OutputArray(std::vector<Mat_<_Tp> >& vec);
|
||||||
template<typename _Tp> _OutputArray(Mat_<_Tp>& m);
|
template<typename _Tp> _OutputArray(Mat_<_Tp>& m);
|
||||||
template<typename _Tp, int m, int n> _OutputArray(Matx<_Tp, m, n>& matx);
|
template<typename _Tp, int m, int n> _OutputArray(Matx<_Tp, m, n>& matx);
|
||||||
template<typename _Tp> _OutputArray(_Tp* vec, int n);
|
template<typename _Tp> _OutputArray(_Tp* vec, int n);
|
||||||
@ -1387,10 +1381,10 @@ public:
|
|||||||
_OutputArray(GlTexture2D& tex);
|
_OutputArray(GlTexture2D& tex);
|
||||||
|
|
||||||
_OutputArray(const Mat& m);
|
_OutputArray(const Mat& m);
|
||||||
template<typename _Tp> _OutputArray(const vector<_Tp>& vec);
|
template<typename _Tp> _OutputArray(const std::vector<_Tp>& vec);
|
||||||
template<typename _Tp> _OutputArray(const vector<vector<_Tp> >& vec);
|
template<typename _Tp> _OutputArray(const std::vector<std::vector<_Tp> >& vec);
|
||||||
_OutputArray(const vector<Mat>& vec);
|
_OutputArray(const std::vector<Mat>& vec);
|
||||||
template<typename _Tp> _OutputArray(const vector<Mat_<_Tp> >& vec);
|
template<typename _Tp> _OutputArray(const std::vector<Mat_<_Tp> >& vec);
|
||||||
template<typename _Tp> _OutputArray(const Mat_<_Tp>& m);
|
template<typename _Tp> _OutputArray(const Mat_<_Tp>& m);
|
||||||
template<typename _Tp, int m, int n> _OutputArray(const Matx<_Tp, m, n>& matx);
|
template<typename _Tp, int m, int n> _OutputArray(const Matx<_Tp, m, n>& matx);
|
||||||
template<typename _Tp> _OutputArray(const _Tp* vec, int n);
|
template<typename _Tp> _OutputArray(const _Tp* vec, int n);
|
||||||
@ -1690,7 +1684,7 @@ public:
|
|||||||
//! converts old-style IplImage to the new matrix; the data is not copied by default
|
//! converts old-style IplImage to the new matrix; the data is not copied by default
|
||||||
Mat(const IplImage* img, bool copyData=false);
|
Mat(const IplImage* img, bool copyData=false);
|
||||||
//! builds matrix from std::vector with or without copying the data
|
//! builds matrix from std::vector with or without copying the data
|
||||||
template<typename _Tp> explicit Mat(const vector<_Tp>& vec, bool copyData=false);
|
template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
|
||||||
//! builds matrix from cv::Vec; the data is copied by default
|
//! builds matrix from cv::Vec; the data is copied by default
|
||||||
template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true);
|
template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true);
|
||||||
//! builds matrix from cv::Matx; the data is copied by default
|
//! builds matrix from cv::Matx; the data is copied by default
|
||||||
@ -1821,7 +1815,7 @@ public:
|
|||||||
//! converts header to IplImage; no data is copied
|
//! converts header to IplImage; no data is copied
|
||||||
operator IplImage() const;
|
operator IplImage() const;
|
||||||
|
|
||||||
template<typename _Tp> operator vector<_Tp>() const;
|
template<typename _Tp> operator std::vector<_Tp>() const;
|
||||||
template<typename _Tp, int n> operator Vec<_Tp, n>() const;
|
template<typename _Tp, int n> operator Vec<_Tp, n>() const;
|
||||||
template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const;
|
template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const;
|
||||||
|
|
||||||
@ -2155,10 +2149,10 @@ CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv);
|
|||||||
//! copies selected channels from the input arrays to the selected channels of the output arrays
|
//! copies selected channels from the input arrays to the selected channels of the output arrays
|
||||||
CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts,
|
CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts,
|
||||||
const int* fromTo, size_t npairs);
|
const int* fromTo, size_t npairs);
|
||||||
CV_EXPORTS void mixChannels(const vector<Mat>& src, vector<Mat>& dst,
|
CV_EXPORTS void mixChannels(const std::vector<Mat>& src, std::vector<Mat>& dst,
|
||||||
const int* fromTo, size_t npairs);
|
const int* fromTo, size_t npairs);
|
||||||
CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
|
CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
|
||||||
const vector<int>& fromTo);
|
const std::vector<int>& fromTo);
|
||||||
|
|
||||||
//! extracts a single channel from src (coi is 0-based index)
|
//! extracts a single channel from src (coi is 0-based index)
|
||||||
CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi);
|
CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi);
|
||||||
@ -2620,7 +2614,7 @@ public:
|
|||||||
//! converts elliptic arc to a polygonal curve
|
//! converts elliptic arc to a polygonal curve
|
||||||
CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle,
|
CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle,
|
||||||
int arcStart, int arcEnd, int delta,
|
int arcStart, int arcEnd, int delta,
|
||||||
CV_OUT vector<Point>& pts );
|
CV_OUT std::vector<Point>& pts );
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -2636,13 +2630,13 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! renders text string in the image
|
//! renders text string in the image
|
||||||
CV_EXPORTS_W void putText( Mat& img, const string& text, Point org,
|
CV_EXPORTS_W void putText( Mat& img, const std::string& text, Point org,
|
||||||
int fontFace, double fontScale, Scalar color,
|
int fontFace, double fontScale, Scalar color,
|
||||||
int thickness=1, int lineType=8,
|
int thickness=1, int lineType=8,
|
||||||
bool bottomLeftOrigin=false );
|
bool bottomLeftOrigin=false );
|
||||||
|
|
||||||
//! returns bounding box of the text string
|
//! returns bounding box of the text string
|
||||||
CV_EXPORTS_W Size getTextSize(const string& text, int fontFace,
|
CV_EXPORTS_W Size getTextSize(const std::string& text, int fontFace,
|
||||||
double fontScale, int thickness,
|
double fontScale, int thickness,
|
||||||
CV_OUT int* baseLine);
|
CV_OUT int* baseLine);
|
||||||
|
|
||||||
@ -2732,7 +2726,7 @@ public:
|
|||||||
//! from a matrix expression
|
//! from a matrix expression
|
||||||
explicit Mat_(const MatExpr& e);
|
explicit Mat_(const MatExpr& e);
|
||||||
//! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column
|
//! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column
|
||||||
explicit Mat_(const vector<_Tp>& vec, bool copyData=false);
|
explicit Mat_(const std::vector<_Tp>& vec, bool copyData=false);
|
||||||
template<int n> explicit Mat_(const Vec<typename DataType<_Tp>::channel_type, n>& vec, bool copyData=true);
|
template<int n> explicit Mat_(const Vec<typename DataType<_Tp>::channel_type, n>& vec, bool copyData=true);
|
||||||
template<int m, int n> explicit Mat_(const Matx<typename DataType<_Tp>::channel_type, m, n>& mtx, bool copyData=true);
|
template<int m, int n> explicit Mat_(const Matx<typename DataType<_Tp>::channel_type, m, n>& mtx, bool copyData=true);
|
||||||
explicit Mat_(const Point_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
|
explicit Mat_(const Point_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
|
||||||
@ -2825,7 +2819,7 @@ public:
|
|||||||
const _Tp& operator ()(Point pt) const;
|
const _Tp& operator ()(Point pt) const;
|
||||||
|
|
||||||
//! conversion to vector.
|
//! conversion to vector.
|
||||||
operator vector<_Tp>() const;
|
operator std::vector<_Tp>() const;
|
||||||
//! conversion to Vec
|
//! conversion to Vec
|
||||||
template<int n> operator Vec<typename DataType<_Tp>::channel_type, n>() const;
|
template<int n> operator Vec<typename DataType<_Tp>::channel_type, n>() const;
|
||||||
//! conversion to Matx
|
//! conversion to Matx
|
||||||
@ -3339,8 +3333,8 @@ public:
|
|||||||
size_t nodeSize;
|
size_t nodeSize;
|
||||||
size_t nodeCount;
|
size_t nodeCount;
|
||||||
size_t freeList;
|
size_t freeList;
|
||||||
vector<uchar> pool;
|
std::vector<uchar> pool;
|
||||||
vector<size_t> hashtab;
|
std::vector<size_t> hashtab;
|
||||||
int size[CV_MAX_DIM];
|
int size[CV_MAX_DIM];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3878,9 +3872,9 @@ public:
|
|||||||
//! returns the search space dimensionality
|
//! returns the search space dimensionality
|
||||||
CV_WRAP int dims() const;
|
CV_WRAP int dims() const;
|
||||||
|
|
||||||
vector<Node> nodes; //!< all the tree nodes
|
std::vector<Node> nodes; //!< all the tree nodes
|
||||||
CV_PROP Mat points; //!< all the points. It can be a reordered copy of the input vector set or the original vector set.
|
CV_PROP Mat points; //!< all the points. It can be a reordered copy of the input vector set or the original vector set.
|
||||||
CV_PROP vector<int> labels; //!< the parallel array of labels.
|
CV_PROP std::vector<int> labels; //!< the parallel array of labels.
|
||||||
CV_PROP int maxDepth; //!< maximum depth of the search tree. Do not modify it
|
CV_PROP int maxDepth; //!< maximum depth of the search tree. Do not modify it
|
||||||
CV_PROP_RW int normType; //!< type of the distance (cv::NORM_L1 or cv::NORM_L2) used for search. Initially set to cv::NORM_L2, but you can modify it
|
CV_PROP_RW int normType; //!< type of the distance (cv::NORM_L1 or cv::NORM_L2) used for search. Initially set to cv::NORM_L2, but you can modify it
|
||||||
};
|
};
|
||||||
@ -3954,7 +3948,7 @@ class CV_EXPORTS FileNode;
|
|||||||
FileStorage fs("test.yml", FileStorage::READ);
|
FileStorage fs("test.yml", FileStorage::READ);
|
||||||
int test_int = (int)fs["test_int"];
|
int test_int = (int)fs["test_int"];
|
||||||
double test_real = (double)fs["test_real"];
|
double test_real = (double)fs["test_real"];
|
||||||
string test_string = (string)fs["test_string"];
|
std::string test_string = (std::string)fs["test_string"];
|
||||||
|
|
||||||
Mat M;
|
Mat M;
|
||||||
fs["test_mat"] >> M;
|
fs["test_mat"] >> M;
|
||||||
@ -3965,7 +3959,7 @@ class CV_EXPORTS FileNode;
|
|||||||
int tl1 = (int)tl[1];
|
int tl1 = (int)tl[1];
|
||||||
double tl2 = (double)tl[2];
|
double tl2 = (double)tl[2];
|
||||||
int tl3 = (int)tl[3];
|
int tl3 = (int)tl[3];
|
||||||
string tl4 = (string)tl[4];
|
std::string tl4 = (std::string)tl[4];
|
||||||
CV_Assert(tl[5].type() == FileNode::MAP && tl[5].size() == 3);
|
CV_Assert(tl[5].type() == FileNode::MAP && tl[5].size() == 3);
|
||||||
|
|
||||||
int month = (int)tl[5]["month"];
|
int month = (int)tl[5]["month"];
|
||||||
@ -4011,27 +4005,27 @@ public:
|
|||||||
//! the default constructor
|
//! the default constructor
|
||||||
CV_WRAP FileStorage();
|
CV_WRAP FileStorage();
|
||||||
//! the full constructor that opens file storage for reading or writing
|
//! the full constructor that opens file storage for reading or writing
|
||||||
CV_WRAP FileStorage(const string& source, int flags, const string& encoding=string());
|
CV_WRAP FileStorage(const std::string& source, int flags, const std::string& encoding=std::string());
|
||||||
//! the constructor that takes pointer to the C FileStorage structure
|
//! the constructor that takes pointer to the C FileStorage structure
|
||||||
FileStorage(CvFileStorage* fs);
|
FileStorage(CvFileStorage* fs);
|
||||||
//! the destructor. calls release()
|
//! the destructor. calls release()
|
||||||
virtual ~FileStorage();
|
virtual ~FileStorage();
|
||||||
|
|
||||||
//! opens file storage for reading or writing. The previous storage is closed with release()
|
//! opens file storage for reading or writing. The previous storage is closed with release()
|
||||||
CV_WRAP virtual bool open(const string& filename, int flags, const string& encoding=string());
|
CV_WRAP virtual bool open(const std::string& filename, int flags, const std::string& encoding=std::string());
|
||||||
//! returns true if the object is associated with currently opened file.
|
//! returns true if the object is associated with currently opened file.
|
||||||
CV_WRAP virtual bool isOpened() const;
|
CV_WRAP virtual bool isOpened() const;
|
||||||
//! closes the file and releases all the memory buffers
|
//! closes the file and releases all the memory buffers
|
||||||
CV_WRAP virtual void release();
|
CV_WRAP virtual void release();
|
||||||
//! closes the file, releases all the memory buffers and returns the text string
|
//! closes the file, releases all the memory buffers and returns the text string
|
||||||
CV_WRAP virtual string releaseAndGetString();
|
CV_WRAP virtual std::string releaseAndGetString();
|
||||||
|
|
||||||
//! returns the first element of the top-level mapping
|
//! returns the first element of the top-level mapping
|
||||||
CV_WRAP FileNode getFirstTopLevelNode() const;
|
CV_WRAP FileNode getFirstTopLevelNode() const;
|
||||||
//! returns the top-level mapping. YAML supports multiple streams
|
//! returns the top-level mapping. YAML supports multiple streams
|
||||||
CV_WRAP FileNode root(int streamidx=0) const;
|
CV_WRAP FileNode root(int streamidx=0) const;
|
||||||
//! returns the specified element of the top-level mapping
|
//! returns the specified element of the top-level mapping
|
||||||
FileNode operator[](const string& nodename) const;
|
FileNode operator[](const std::string& nodename) const;
|
||||||
//! returns the specified element of the top-level mapping
|
//! returns the specified element of the top-level mapping
|
||||||
CV_WRAP FileNode operator[](const char* nodename) const;
|
CV_WRAP FileNode operator[](const char* nodename) const;
|
||||||
|
|
||||||
@ -4040,16 +4034,16 @@ public:
|
|||||||
//! returns pointer to the underlying C FileStorage structure
|
//! returns pointer to the underlying C FileStorage structure
|
||||||
const CvFileStorage* operator *() const { return fs; }
|
const CvFileStorage* operator *() const { return fs; }
|
||||||
//! writes one or more numbers of the specified format to the currently written structure
|
//! writes one or more numbers of the specified format to the currently written structure
|
||||||
void writeRaw( const string& fmt, const uchar* vec, size_t len );
|
void writeRaw( const std::string& fmt, const uchar* vec, size_t len );
|
||||||
//! writes the registered C structure (CvMat, CvMatND, CvSeq). See cvWrite()
|
//! writes the registered C structure (CvMat, CvMatND, CvSeq). See cvWrite()
|
||||||
void writeObj( const string& name, const void* obj );
|
void writeObj( const std::string& name, const void* obj );
|
||||||
|
|
||||||
//! returns the normalized object name for the specified file name
|
//! returns the normalized object name for the specified file name
|
||||||
static string getDefaultObjectName(const string& filename);
|
static std::string getDefaultObjectName(const std::string& filename);
|
||||||
|
|
||||||
Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure
|
Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure
|
||||||
string elname; //!< the currently written element
|
std::string elname; //!< the currently written element
|
||||||
vector<char> structs; //!< the stack of written structures
|
std::vector<char> structs; //!< the stack of written structures
|
||||||
int state; //!< the writer state
|
int state; //!< the writer state
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4093,7 +4087,7 @@ public:
|
|||||||
//! the copy constructor
|
//! the copy constructor
|
||||||
FileNode(const FileNode& node);
|
FileNode(const FileNode& node);
|
||||||
//! returns element of a mapping node
|
//! returns element of a mapping node
|
||||||
FileNode operator[](const string& nodename) const;
|
FileNode operator[](const std::string& nodename) const;
|
||||||
//! returns element of a mapping node
|
//! returns element of a mapping node
|
||||||
CV_WRAP FileNode operator[](const char* nodename) const;
|
CV_WRAP FileNode operator[](const char* nodename) const;
|
||||||
//! returns element of a sequence node
|
//! returns element of a sequence node
|
||||||
@ -4118,7 +4112,7 @@ public:
|
|||||||
//! returns true if the node has a name
|
//! returns true if the node has a name
|
||||||
CV_WRAP bool isNamed() const;
|
CV_WRAP bool isNamed() const;
|
||||||
//! returns the node name or an empty string if the node is nameless
|
//! returns the node name or an empty string if the node is nameless
|
||||||
CV_WRAP string name() const;
|
CV_WRAP std::string name() const;
|
||||||
//! returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise.
|
//! returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise.
|
||||||
CV_WRAP size_t size() const;
|
CV_WRAP size_t size() const;
|
||||||
//! returns the node content as an integer. If the node stores floating-point number, it is rounded.
|
//! returns the node content as an integer. If the node stores floating-point number, it is rounded.
|
||||||
@ -4128,7 +4122,7 @@ public:
|
|||||||
//! returns the node content as double
|
//! returns the node content as double
|
||||||
operator double() const;
|
operator double() const;
|
||||||
//! returns the node content as text string
|
//! returns the node content as text string
|
||||||
operator string() const;
|
operator std::string() const;
|
||||||
|
|
||||||
//! returns pointer to the underlying file node
|
//! returns pointer to the underlying file node
|
||||||
CvFileNode* operator *();
|
CvFileNode* operator *();
|
||||||
@ -4141,7 +4135,7 @@ public:
|
|||||||
FileNodeIterator end() const;
|
FileNodeIterator end() const;
|
||||||
|
|
||||||
//! reads node elements to the buffer with the specified format
|
//! reads node elements to the buffer with the specified format
|
||||||
void readRaw( const string& fmt, uchar* vec, size_t len ) const;
|
void readRaw( const std::string& fmt, uchar* vec, size_t len ) const;
|
||||||
//! reads the registered object and returns pointer to it
|
//! reads the registered object and returns pointer to it
|
||||||
void* readObj() const;
|
void* readObj() const;
|
||||||
|
|
||||||
@ -4184,7 +4178,7 @@ public:
|
|||||||
FileNodeIterator& operator -= (int ofs);
|
FileNodeIterator& operator -= (int ofs);
|
||||||
|
|
||||||
//! reads the next maxCount elements (or less, if the sequence/mapping last element occurs earlier) to the buffer with the specified format
|
//! reads the next maxCount elements (or less, if the sequence/mapping last element occurs earlier) to the buffer with the specified format
|
||||||
FileNodeIterator& readRaw( const string& fmt, uchar* vec,
|
FileNodeIterator& readRaw( const std::string& fmt, uchar* vec,
|
||||||
size_t maxCount=(size_t)INT_MAX );
|
size_t maxCount=(size_t)INT_MAX );
|
||||||
|
|
||||||
const CvFileStorage* fs;
|
const CvFileStorage* fs;
|
||||||
@ -4281,9 +4275,9 @@ public:
|
|||||||
void pop_back(_Tp* elems, size_t count);
|
void pop_back(_Tp* elems, size_t count);
|
||||||
|
|
||||||
//! copies the whole sequence or the sequence slice to the specified vector
|
//! copies the whole sequence or the sequence slice to the specified vector
|
||||||
void copyTo(vector<_Tp>& vec, const Range& range=Range::all()) const;
|
void copyTo(std::vector<_Tp>& vec, const Range& range=Range::all()) const;
|
||||||
//! returns the vector containing all the sequence elements
|
//! returns the vector containing all the sequence elements
|
||||||
operator vector<_Tp>() const;
|
operator std::vector<_Tp>() const;
|
||||||
|
|
||||||
CvSeq* seq;
|
CvSeq* seq;
|
||||||
};
|
};
|
||||||
@ -4340,59 +4334,59 @@ class CV_EXPORTS_W Algorithm
|
|||||||
public:
|
public:
|
||||||
Algorithm();
|
Algorithm();
|
||||||
virtual ~Algorithm();
|
virtual ~Algorithm();
|
||||||
string name() const;
|
std::string name() const;
|
||||||
|
|
||||||
template<typename _Tp> typename ParamType<_Tp>::member_type get(const string& name) const;
|
template<typename _Tp> typename ParamType<_Tp>::member_type get(const std::string& name) const;
|
||||||
template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const;
|
template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const;
|
||||||
|
|
||||||
CV_WRAP int getInt(const string& name) const;
|
CV_WRAP int getInt(const std::string& name) const;
|
||||||
CV_WRAP double getDouble(const string& name) const;
|
CV_WRAP double getDouble(const std::string& name) const;
|
||||||
CV_WRAP bool getBool(const string& name) const;
|
CV_WRAP bool getBool(const std::string& name) const;
|
||||||
CV_WRAP string getString(const string& name) const;
|
CV_WRAP std::string getString(const std::string& name) const;
|
||||||
CV_WRAP Mat getMat(const string& name) const;
|
CV_WRAP Mat getMat(const std::string& name) const;
|
||||||
CV_WRAP vector<Mat> getMatVector(const string& name) const;
|
CV_WRAP std::vector<Mat> getMatVector(const std::string& name) const;
|
||||||
CV_WRAP Ptr<Algorithm> getAlgorithm(const string& name) const;
|
CV_WRAP Ptr<Algorithm> getAlgorithm(const std::string& name) const;
|
||||||
|
|
||||||
void set(const string& name, int value);
|
void set(const std::string& name, int value);
|
||||||
void set(const string& name, double value);
|
void set(const std::string& name, double value);
|
||||||
void set(const string& name, bool value);
|
void set(const std::string& name, bool value);
|
||||||
void set(const string& name, const string& value);
|
void set(const std::string& name, const std::string& value);
|
||||||
void set(const string& name, const Mat& value);
|
void set(const std::string& name, const Mat& value);
|
||||||
void set(const string& name, const vector<Mat>& value);
|
void set(const std::string& name, const std::vector<Mat>& value);
|
||||||
void set(const string& name, const Ptr<Algorithm>& value);
|
void set(const std::string& name, const Ptr<Algorithm>& value);
|
||||||
template<typename _Tp> void set(const string& name, const Ptr<_Tp>& value);
|
template<typename _Tp> void set(const std::string& name, const Ptr<_Tp>& value);
|
||||||
|
|
||||||
CV_WRAP void setInt(const string& name, int value);
|
CV_WRAP void setInt(const std::string& name, int value);
|
||||||
CV_WRAP void setDouble(const string& name, double value);
|
CV_WRAP void setDouble(const std::string& name, double value);
|
||||||
CV_WRAP void setBool(const string& name, bool value);
|
CV_WRAP void setBool(const std::string& name, bool value);
|
||||||
CV_WRAP void setString(const string& name, const string& value);
|
CV_WRAP void setString(const std::string& name, const std::string& value);
|
||||||
CV_WRAP void setMat(const string& name, const Mat& value);
|
CV_WRAP void setMat(const std::string& name, const Mat& value);
|
||||||
CV_WRAP void setMatVector(const string& name, const vector<Mat>& value);
|
CV_WRAP void setMatVector(const std::string& name, const std::vector<Mat>& value);
|
||||||
CV_WRAP void setAlgorithm(const string& name, const Ptr<Algorithm>& value);
|
CV_WRAP void setAlgorithm(const std::string& name, const Ptr<Algorithm>& value);
|
||||||
template<typename _Tp> void setAlgorithm(const string& name, const Ptr<_Tp>& value);
|
template<typename _Tp> void setAlgorithm(const std::string& name, const Ptr<_Tp>& value);
|
||||||
|
|
||||||
void set(const char* name, int value);
|
void set(const char* name, int value);
|
||||||
void set(const char* name, double value);
|
void set(const char* name, double value);
|
||||||
void set(const char* name, bool value);
|
void set(const char* name, bool value);
|
||||||
void set(const char* name, const string& value);
|
void set(const char* name, const std::string& value);
|
||||||
void set(const char* name, const Mat& value);
|
void set(const char* name, const Mat& value);
|
||||||
void set(const char* name, const vector<Mat>& value);
|
void set(const char* name, const std::vector<Mat>& value);
|
||||||
void set(const char* name, const Ptr<Algorithm>& value);
|
void set(const char* name, const Ptr<Algorithm>& value);
|
||||||
template<typename _Tp> void set(const char* name, const Ptr<_Tp>& value);
|
template<typename _Tp> void set(const char* name, const Ptr<_Tp>& value);
|
||||||
|
|
||||||
void setInt(const char* name, int value);
|
void setInt(const char* name, int value);
|
||||||
void setDouble(const char* name, double value);
|
void setDouble(const char* name, double value);
|
||||||
void setBool(const char* name, bool value);
|
void setBool(const char* name, bool value);
|
||||||
void setString(const char* name, const string& value);
|
void setString(const char* name, const std::string& value);
|
||||||
void setMat(const char* name, const Mat& value);
|
void setMat(const char* name, const Mat& value);
|
||||||
void setMatVector(const char* name, const vector<Mat>& value);
|
void setMatVector(const char* name, const std::vector<Mat>& value);
|
||||||
void setAlgorithm(const char* name, const Ptr<Algorithm>& value);
|
void setAlgorithm(const char* name, const Ptr<Algorithm>& value);
|
||||||
template<typename _Tp> void setAlgorithm(const char* name, const Ptr<_Tp>& value);
|
template<typename _Tp> void setAlgorithm(const char* name, const Ptr<_Tp>& value);
|
||||||
|
|
||||||
CV_WRAP string paramHelp(const string& name) const;
|
CV_WRAP std::string paramHelp(const std::string& name) const;
|
||||||
int paramType(const char* name) const;
|
int paramType(const char* name) const;
|
||||||
CV_WRAP int paramType(const string& name) const;
|
CV_WRAP int paramType(const std::string& name) const;
|
||||||
CV_WRAP void getParams(CV_OUT vector<string>& names) const;
|
CV_WRAP void getParams(CV_OUT std::vector<std::string>& names) const;
|
||||||
|
|
||||||
|
|
||||||
virtual void write(FileStorage& fs) const;
|
virtual void write(FileStorage& fs) const;
|
||||||
@ -4402,9 +4396,9 @@ public:
|
|||||||
typedef int (Algorithm::*Getter)() const;
|
typedef int (Algorithm::*Getter)() const;
|
||||||
typedef void (Algorithm::*Setter)(int);
|
typedef void (Algorithm::*Setter)(int);
|
||||||
|
|
||||||
CV_WRAP static void getList(CV_OUT vector<string>& algorithms);
|
CV_WRAP static void getList(CV_OUT std::vector<std::string>& algorithms);
|
||||||
CV_WRAP static Ptr<Algorithm> _create(const string& name);
|
CV_WRAP static Ptr<Algorithm> _create(const std::string& name);
|
||||||
template<typename _Tp> static Ptr<_Tp> create(const string& name);
|
template<typename _Tp> static Ptr<_Tp> create(const std::string& name);
|
||||||
|
|
||||||
virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; }
|
virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; }
|
||||||
};
|
};
|
||||||
@ -4414,66 +4408,66 @@ class CV_EXPORTS AlgorithmInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
friend class Algorithm;
|
friend class Algorithm;
|
||||||
AlgorithmInfo(const string& name, Algorithm::Constructor create);
|
AlgorithmInfo(const std::string& name, Algorithm::Constructor create);
|
||||||
~AlgorithmInfo();
|
~AlgorithmInfo();
|
||||||
void get(const Algorithm* algo, const char* name, int argType, void* value) const;
|
void get(const Algorithm* algo, const char* name, int argType, void* value) const;
|
||||||
void addParam_(Algorithm& algo, const char* name, int argType,
|
void addParam_(Algorithm& algo, const char* name, int argType,
|
||||||
void* value, bool readOnly,
|
void* value, bool readOnly,
|
||||||
Algorithm::Getter getter, Algorithm::Setter setter,
|
Algorithm::Getter getter, Algorithm::Setter setter,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
string paramHelp(const char* name) const;
|
std::string paramHelp(const char* name) const;
|
||||||
int paramType(const char* name) const;
|
int paramType(const char* name) const;
|
||||||
void getParams(vector<string>& names) const;
|
void getParams(std::vector<std::string>& names) const;
|
||||||
|
|
||||||
void write(const Algorithm* algo, FileStorage& fs) const;
|
void write(const Algorithm* algo, FileStorage& fs) const;
|
||||||
void read(Algorithm* algo, const FileNode& fn) const;
|
void read(Algorithm* algo, const FileNode& fn) const;
|
||||||
string name() const;
|
std::string name() const;
|
||||||
|
|
||||||
void addParam(Algorithm& algo, const char* name,
|
void addParam(Algorithm& algo, const char* name,
|
||||||
int& value, bool readOnly=false,
|
int& value, bool readOnly=false,
|
||||||
int (Algorithm::*getter)()=0,
|
int (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(int)=0,
|
void (Algorithm::*setter)(int)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
void addParam(Algorithm& algo, const char* name,
|
void addParam(Algorithm& algo, const char* name,
|
||||||
bool& value, bool readOnly=false,
|
bool& value, bool readOnly=false,
|
||||||
int (Algorithm::*getter)()=0,
|
int (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(int)=0,
|
void (Algorithm::*setter)(int)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
void addParam(Algorithm& algo, const char* name,
|
void addParam(Algorithm& algo, const char* name,
|
||||||
double& value, bool readOnly=false,
|
double& value, bool readOnly=false,
|
||||||
double (Algorithm::*getter)()=0,
|
double (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(double)=0,
|
void (Algorithm::*setter)(double)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
void addParam(Algorithm& algo, const char* name,
|
void addParam(Algorithm& algo, const char* name,
|
||||||
string& value, bool readOnly=false,
|
std::string& value, bool readOnly=false,
|
||||||
string (Algorithm::*getter)()=0,
|
std::string (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(const string&)=0,
|
void (Algorithm::*setter)(const std::string&)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
void addParam(Algorithm& algo, const char* name,
|
void addParam(Algorithm& algo, const char* name,
|
||||||
Mat& value, bool readOnly=false,
|
Mat& value, bool readOnly=false,
|
||||||
Mat (Algorithm::*getter)()=0,
|
Mat (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(const Mat&)=0,
|
void (Algorithm::*setter)(const Mat&)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
void addParam(Algorithm& algo, const char* name,
|
void addParam(Algorithm& algo, const char* name,
|
||||||
vector<Mat>& value, bool readOnly=false,
|
std::vector<Mat>& value, bool readOnly=false,
|
||||||
vector<Mat> (Algorithm::*getter)()=0,
|
std::vector<Mat> (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(const vector<Mat>&)=0,
|
void (Algorithm::*setter)(const std::vector<Mat>&)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
void addParam(Algorithm& algo, const char* name,
|
void addParam(Algorithm& algo, const char* name,
|
||||||
Ptr<Algorithm>& value, bool readOnly=false,
|
Ptr<Algorithm>& value, bool readOnly=false,
|
||||||
Ptr<Algorithm> (Algorithm::*getter)()=0,
|
Ptr<Algorithm> (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(const Ptr<Algorithm>&)=0,
|
void (Algorithm::*setter)(const Ptr<Algorithm>&)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
template<typename _Tp, typename _Base> void addParam(Algorithm& algo, const char* name,
|
template<typename _Tp, typename _Base> void addParam(Algorithm& algo, const char* name,
|
||||||
Ptr<_Tp>& value, bool readOnly=false,
|
Ptr<_Tp>& value, bool readOnly=false,
|
||||||
Ptr<_Tp> (Algorithm::*getter)()=0,
|
Ptr<_Tp> (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
|
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
template<typename _Tp> void addParam(Algorithm& algo, const char* name,
|
template<typename _Tp> void addParam(Algorithm& algo, const char* name,
|
||||||
Ptr<_Tp>& value, bool readOnly=false,
|
Ptr<_Tp>& value, bool readOnly=false,
|
||||||
Ptr<_Tp> (Algorithm::*getter)()=0,
|
Ptr<_Tp> (Algorithm::*getter)()=0,
|
||||||
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
|
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
|
||||||
const string& help=string());
|
const std::string& help=std::string());
|
||||||
protected:
|
protected:
|
||||||
AlgorithmInfoData* data;
|
AlgorithmInfoData* data;
|
||||||
void set(Algorithm* algo, const char* name, int argType,
|
void set(Algorithm* algo, const char* name, int argType,
|
||||||
@ -4489,13 +4483,13 @@ struct CV_EXPORTS Param
|
|||||||
Param(int _type, bool _readonly, int _offset,
|
Param(int _type, bool _readonly, int _offset,
|
||||||
Algorithm::Getter _getter=0,
|
Algorithm::Getter _getter=0,
|
||||||
Algorithm::Setter _setter=0,
|
Algorithm::Setter _setter=0,
|
||||||
const string& _help=string());
|
const std::string& _help=std::string());
|
||||||
int type;
|
int type;
|
||||||
int offset;
|
int offset;
|
||||||
bool readonly;
|
bool readonly;
|
||||||
Algorithm::Getter getter;
|
Algorithm::Getter getter;
|
||||||
Algorithm::Setter setter;
|
Algorithm::Setter setter;
|
||||||
string help;
|
std::string help;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ParamType<bool>
|
template<> struct ParamType<bool>
|
||||||
@ -4522,10 +4516,10 @@ template<> struct ParamType<double>
|
|||||||
enum { type = Param::REAL };
|
enum { type = Param::REAL };
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ParamType<string>
|
template<> struct ParamType<std::string>
|
||||||
{
|
{
|
||||||
typedef const string& const_param_type;
|
typedef const std::string& const_param_type;
|
||||||
typedef string member_type;
|
typedef std::string member_type;
|
||||||
|
|
||||||
enum { type = Param::STRING };
|
enum { type = Param::STRING };
|
||||||
};
|
};
|
||||||
@ -4538,10 +4532,10 @@ template<> struct ParamType<Mat>
|
|||||||
enum { type = Param::MAT };
|
enum { type = Param::MAT };
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ParamType<vector<Mat> >
|
template<> struct ParamType<std::vector<Mat> >
|
||||||
{
|
{
|
||||||
typedef const vector<Mat>& const_param_type;
|
typedef const std::vector<Mat>& const_param_type;
|
||||||
typedef vector<Mat> member_type;
|
typedef std::vector<Mat> member_type;
|
||||||
|
|
||||||
enum { type = Param::MAT_VECTOR };
|
enum { type = Param::MAT_VECTOR };
|
||||||
};
|
};
|
||||||
@ -4584,14 +4578,14 @@ template<> struct ParamType<uint64>
|
|||||||
class CV_EXPORTS CommandLineParser
|
class CV_EXPORTS CommandLineParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandLineParser(int argc, const char* const argv[], const string& keys);
|
CommandLineParser(int argc, const char* const argv[], const std::string& keys);
|
||||||
CommandLineParser(const CommandLineParser& parser);
|
CommandLineParser(const CommandLineParser& parser);
|
||||||
CommandLineParser& operator = (const CommandLineParser& parser);
|
CommandLineParser& operator = (const CommandLineParser& parser);
|
||||||
|
|
||||||
string getPathToApplication() const;
|
std::string getPathToApplication() const;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T get(const string& name, bool space_delete = true) const
|
T get(const std::string& name, bool space_delete = true) const
|
||||||
{
|
{
|
||||||
T val = T();
|
T val = T();
|
||||||
getByName(name, space_delete, ParamType<T>::type, (void*)&val);
|
getByName(name, space_delete, ParamType<T>::type, (void*)&val);
|
||||||
@ -4606,17 +4600,17 @@ public:
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has(const string& name) const;
|
bool has(const std::string& name) const;
|
||||||
|
|
||||||
bool check() const;
|
bool check() const;
|
||||||
|
|
||||||
void about(const string& message);
|
void about(const std::string& message);
|
||||||
|
|
||||||
void printMessage() const;
|
void printMessage() const;
|
||||||
void printErrors() const;
|
void printErrors() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void getByName(const string& name, bool space_delete, int type, void* dst) const;
|
void getByName(const std::string& name, bool space_delete, int type, void* dst) const;
|
||||||
void getByIndex(int index, bool space_delete, int type, void* dst) const;
|
void getByIndex(int index, bool space_delete, int type, void* dst) const;
|
||||||
|
|
||||||
struct Impl;
|
struct Impl;
|
||||||
|
@ -171,7 +171,7 @@ inline Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename _Tp> inline Mat::Mat(const vector<_Tp>& vec, bool copyData)
|
template<typename _Tp> inline Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
|
||||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
|
||||||
dims(2), rows((int)vec.size()), cols(1), data(0), refcount(0),
|
dims(2), rows((int)vec.size()), cols(1), data(0), refcount(0),
|
||||||
datastart(0), dataend(0), allocator(0), size(&rows)
|
datastart(0), dataend(0), allocator(0), size(&rows)
|
||||||
@ -648,9 +648,9 @@ template<typename _Tp> inline MatIterator_<_Tp> Mat::end()
|
|||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline Mat::operator vector<_Tp>() const
|
template<typename _Tp> inline Mat::operator std::vector<_Tp>() const
|
||||||
{
|
{
|
||||||
vector<_Tp> v;
|
std::vector<_Tp> v;
|
||||||
copyTo(v);
|
copyTo(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -873,7 +873,7 @@ template<typename _Tp> inline Mat_<_Tp>::Mat_(const Point3_<typename DataType<_T
|
|||||||
template<typename _Tp> inline Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer)
|
template<typename _Tp> inline Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer)
|
||||||
: Mat(commaInitializer) {}
|
: Mat(commaInitializer) {}
|
||||||
|
|
||||||
template<typename _Tp> inline Mat_<_Tp>::Mat_(const vector<_Tp>& vec, bool copyData)
|
template<typename _Tp> inline Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData)
|
||||||
: Mat(vec, copyData) {}
|
: Mat(vec, copyData) {}
|
||||||
|
|
||||||
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m)
|
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m)
|
||||||
@ -1059,9 +1059,9 @@ template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(int i0, int i1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename _Tp> inline Mat_<_Tp>::operator vector<_Tp>() const
|
template<typename _Tp> inline Mat_<_Tp>::operator std::vector<_Tp>() const
|
||||||
{
|
{
|
||||||
vector<_Tp> v;
|
std::vector<_Tp> v;
|
||||||
copyTo(v);
|
copyTo(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -1116,13 +1116,13 @@ process( const Mat_<T1>& m1, const Mat_<T2>& m2, Mat_<T3>& m3, Op op )
|
|||||||
|
|
||||||
/////////////////////////////// Input/Output Arrays /////////////////////////////////
|
/////////////////////////////// Input/Output Arrays /////////////////////////////////
|
||||||
|
|
||||||
template<typename _Tp> inline _InputArray::_InputArray(const vector<_Tp>& vec)
|
template<typename _Tp> inline _InputArray::_InputArray(const std::vector<_Tp>& vec)
|
||||||
: flags(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
|
: flags(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
|
||||||
|
|
||||||
template<typename _Tp> inline _InputArray::_InputArray(const vector<vector<_Tp> >& vec)
|
template<typename _Tp> inline _InputArray::_InputArray(const std::vector<std::vector<_Tp> >& vec)
|
||||||
: flags(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
|
: flags(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {}
|
||||||
|
|
||||||
template<typename _Tp> inline _InputArray::_InputArray(const vector<Mat_<_Tp> >& vec)
|
template<typename _Tp> inline _InputArray::_InputArray(const std::vector<Mat_<_Tp> >& vec)
|
||||||
: flags(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type), obj((void*)&vec) {}
|
: flags(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type), obj((void*)&vec) {}
|
||||||
|
|
||||||
template<typename _Tp, int m, int n> inline _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx)
|
template<typename _Tp, int m, int n> inline _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx)
|
||||||
@ -1137,11 +1137,11 @@ inline _InputArray::_InputArray(const Scalar& s)
|
|||||||
template<typename _Tp> inline _InputArray::_InputArray(const Mat_<_Tp>& m)
|
template<typename _Tp> inline _InputArray::_InputArray(const Mat_<_Tp>& m)
|
||||||
: flags(FIXED_TYPE + MAT + DataType<_Tp>::type), obj((void*)&m) {}
|
: flags(FIXED_TYPE + MAT + DataType<_Tp>::type), obj((void*)&m) {}
|
||||||
|
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(vector<_Tp>& vec)
|
template<typename _Tp> inline _OutputArray::_OutputArray(std::vector<_Tp>& vec)
|
||||||
: _InputArray(vec) {}
|
: _InputArray(vec) {}
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(vector<vector<_Tp> >& vec)
|
template<typename _Tp> inline _OutputArray::_OutputArray(std::vector<std::vector<_Tp> >& vec)
|
||||||
: _InputArray(vec) {}
|
: _InputArray(vec) {}
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(vector<Mat_<_Tp> >& vec)
|
template<typename _Tp> inline _OutputArray::_OutputArray(std::vector<Mat_<_Tp> >& vec)
|
||||||
: _InputArray(vec) {}
|
: _InputArray(vec) {}
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(Mat_<_Tp>& m)
|
template<typename _Tp> inline _OutputArray::_OutputArray(Mat_<_Tp>& m)
|
||||||
: _InputArray(m) {}
|
: _InputArray(m) {}
|
||||||
@ -1150,11 +1150,11 @@ template<typename _Tp, int m, int n> inline _OutputArray::_OutputArray(Matx<_Tp,
|
|||||||
template<typename _Tp> inline _OutputArray::_OutputArray(_Tp* vec, int n)
|
template<typename _Tp> inline _OutputArray::_OutputArray(_Tp* vec, int n)
|
||||||
: _InputArray(vec, n) {}
|
: _InputArray(vec, n) {}
|
||||||
|
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(const vector<_Tp>& vec)
|
template<typename _Tp> inline _OutputArray::_OutputArray(const std::vector<_Tp>& vec)
|
||||||
: _InputArray(vec) {flags |= FIXED_SIZE;}
|
: _InputArray(vec) {flags |= FIXED_SIZE;}
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(const vector<vector<_Tp> >& vec)
|
template<typename _Tp> inline _OutputArray::_OutputArray(const std::vector<std::vector<_Tp> >& vec)
|
||||||
: _InputArray(vec) {flags |= FIXED_SIZE;}
|
: _InputArray(vec) {flags |= FIXED_SIZE;}
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(const vector<Mat_<_Tp> >& vec)
|
template<typename _Tp> inline _OutputArray::_OutputArray(const std::vector<Mat_<_Tp> >& vec)
|
||||||
: _InputArray(vec) {flags |= FIXED_SIZE;}
|
: _InputArray(vec) {flags |= FIXED_SIZE;}
|
||||||
|
|
||||||
template<typename _Tp> inline _OutputArray::_OutputArray(const Mat_<_Tp>& m)
|
template<typename _Tp> inline _OutputArray::_OutputArray(const Mat_<_Tp>& m)
|
||||||
@ -1667,8 +1667,8 @@ operator ^= (const Mat_<_Tp>& a, const Scalar& s)
|
|||||||
|
|
||||||
/////////////////////////////// Miscellaneous operations //////////////////////////////
|
/////////////////////////////// Miscellaneous operations //////////////////////////////
|
||||||
|
|
||||||
template<typename _Tp> void split(const Mat& src, vector<Mat_<_Tp> >& mv)
|
template<typename _Tp> void split(const Mat& src, std::vector<Mat_<_Tp> >& mv)
|
||||||
{ split(src, (vector<Mat>&)mv ); }
|
{ split(src, (std::vector<Mat>&)mv ); }
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -101,16 +101,6 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
using std::cos;
|
|
||||||
using std::sin;
|
|
||||||
using std::max;
|
|
||||||
using std::min;
|
|
||||||
using std::exp;
|
|
||||||
using std::log;
|
|
||||||
using std::pow;
|
|
||||||
using std::sqrt;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////// saturate_cast (used in image & signal processing) ///////////////////
|
/////////////// saturate_cast (used in image & signal processing) ///////////////////
|
||||||
|
|
||||||
template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); }
|
template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); }
|
||||||
@ -2769,18 +2759,18 @@ template<> CV_EXPORTS void Ptr<CvFileStorage>::delete_obj();
|
|||||||
|
|
||||||
//////////////////////////////////////// XML & YAML I/O ////////////////////////////////////
|
//////////////////////////////////////// XML & YAML I/O ////////////////////////////////////
|
||||||
|
|
||||||
CV_EXPORTS_W void write( FileStorage& fs, const string& name, int value );
|
CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, int value );
|
||||||
CV_EXPORTS_W void write( FileStorage& fs, const string& name, float value );
|
CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, float value );
|
||||||
CV_EXPORTS_W void write( FileStorage& fs, const string& name, double value );
|
CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, double value );
|
||||||
CV_EXPORTS_W void write( FileStorage& fs, const string& name, const string& value );
|
CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, const std::string& value );
|
||||||
|
|
||||||
template<typename _Tp> inline void write(FileStorage& fs, const _Tp& value)
|
template<typename _Tp> inline void write(FileStorage& fs, const _Tp& value)
|
||||||
{ write(fs, string(), value); }
|
{ write(fs, std::string(), value); }
|
||||||
|
|
||||||
CV_EXPORTS void writeScalar( FileStorage& fs, int value );
|
CV_EXPORTS void writeScalar( FileStorage& fs, int value );
|
||||||
CV_EXPORTS void writeScalar( FileStorage& fs, float value );
|
CV_EXPORTS void writeScalar( FileStorage& fs, float value );
|
||||||
CV_EXPORTS void writeScalar( FileStorage& fs, double value );
|
CV_EXPORTS void writeScalar( FileStorage& fs, double value );
|
||||||
CV_EXPORTS void writeScalar( FileStorage& fs, const string& value );
|
CV_EXPORTS void writeScalar( FileStorage& fs, const std::string& value );
|
||||||
|
|
||||||
template<> inline void write( FileStorage& fs, const int& value )
|
template<> inline void write( FileStorage& fs, const int& value )
|
||||||
{
|
{
|
||||||
@ -2797,7 +2787,7 @@ template<> inline void write( FileStorage& fs, const double& value )
|
|||||||
writeScalar(fs, value);
|
writeScalar(fs, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> inline void write( FileStorage& fs, const string& value )
|
template<> inline void write( FileStorage& fs, const std::string& value )
|
||||||
{
|
{
|
||||||
writeScalar(fs, value);
|
writeScalar(fs, value);
|
||||||
}
|
}
|
||||||
@ -2858,20 +2848,20 @@ inline void write(FileStorage& fs, const Range& r )
|
|||||||
class CV_EXPORTS WriteStructContext
|
class CV_EXPORTS WriteStructContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WriteStructContext(FileStorage& _fs, const string& name,
|
WriteStructContext(FileStorage& _fs, const std::string& name,
|
||||||
int flags, const string& typeName=string());
|
int flags, const std::string& typeName=std::string());
|
||||||
~WriteStructContext();
|
~WriteStructContext();
|
||||||
FileStorage* fs;
|
FileStorage* fs;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Point_<_Tp>& pt )
|
template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Point_<_Tp>& pt )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
write(fs, pt.x);
|
write(fs, pt.x);
|
||||||
write(fs, pt.y);
|
write(fs, pt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Point3_<_Tp>& pt )
|
template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Point3_<_Tp>& pt )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
write(fs, pt.x);
|
write(fs, pt.x);
|
||||||
@ -2879,21 +2869,21 @@ template<typename _Tp> inline void write(FileStorage& fs, const string& name, co
|
|||||||
write(fs, pt.z);
|
write(fs, pt.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Size_<_Tp>& sz )
|
template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Size_<_Tp>& sz )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
write(fs, sz.width);
|
write(fs, sz.width);
|
||||||
write(fs, sz.height);
|
write(fs, sz.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Complex<_Tp>& c )
|
template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Complex<_Tp>& c )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
write(fs, c.re);
|
write(fs, c.re);
|
||||||
write(fs, c.im);
|
write(fs, c.im);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Rect_<_Tp>& r )
|
template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Rect_<_Tp>& r )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
write(fs, r.x);
|
write(fs, r.x);
|
||||||
@ -2902,14 +2892,14 @@ template<typename _Tp> inline void write(FileStorage& fs, const string& name, co
|
|||||||
write(fs, r.height);
|
write(fs, r.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp, int cn> inline void write(FileStorage& fs, const string& name, const Vec<_Tp, cn>& v )
|
template<typename _Tp, int cn> inline void write(FileStorage& fs, const std::string& name, const Vec<_Tp, cn>& v )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
for(int i = 0; i < cn; i++)
|
for(int i = 0; i < cn; i++)
|
||||||
write(fs, v.val[i]);
|
write(fs, v.val[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Scalar_<_Tp>& s )
|
template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Scalar_<_Tp>& s )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
write(fs, s.val[0]);
|
write(fs, s.val[0]);
|
||||||
@ -2918,7 +2908,7 @@ template<typename _Tp> inline void write(FileStorage& fs, const string& name, co
|
|||||||
write(fs, s.val[3]);
|
write(fs, s.val[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void write(FileStorage& fs, const string& name, const Range& r )
|
inline void write(FileStorage& fs, const std::string& name, const Range& r )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||||
write(fs, r.start);
|
write(fs, r.start);
|
||||||
@ -2929,7 +2919,7 @@ template<typename _Tp, int numflag> class CV_EXPORTS VecWriterProxy
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VecWriterProxy( FileStorage* _fs ) : fs(_fs) {}
|
VecWriterProxy( FileStorage* _fs ) : fs(_fs) {}
|
||||||
void operator()(const vector<_Tp>& vec) const
|
void operator()(const std::vector<_Tp>& vec) const
|
||||||
{
|
{
|
||||||
size_t i, count = vec.size();
|
size_t i, count = vec.size();
|
||||||
for( i = 0; i < count; i++ )
|
for( i = 0; i < count; i++ )
|
||||||
@ -2942,30 +2932,30 @@ template<typename _Tp> class CV_EXPORTS VecWriterProxy<_Tp,1>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VecWriterProxy( FileStorage* _fs ) : fs(_fs) {}
|
VecWriterProxy( FileStorage* _fs ) : fs(_fs) {}
|
||||||
void operator()(const vector<_Tp>& vec) const
|
void operator()(const std::vector<_Tp>& vec) const
|
||||||
{
|
{
|
||||||
int _fmt = DataType<_Tp>::fmt;
|
int _fmt = DataType<_Tp>::fmt;
|
||||||
char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' };
|
char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' };
|
||||||
fs->writeRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) );
|
fs->writeRaw( std::string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) );
|
||||||
}
|
}
|
||||||
FileStorage* fs;
|
FileStorage* fs;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp> static inline void write( FileStorage& fs, const vector<_Tp>& vec )
|
template<typename _Tp> static inline void write( FileStorage& fs, const std::vector<_Tp>& vec )
|
||||||
{
|
{
|
||||||
VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs);
|
VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs);
|
||||||
w(vec);
|
w(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> static inline void write( FileStorage& fs, const string& name,
|
template<typename _Tp> static inline void write( FileStorage& fs, const std::string& name,
|
||||||
const vector<_Tp>& vec )
|
const std::vector<_Tp>& vec )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0));
|
WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0));
|
||||||
write(fs, vec);
|
write(fs, vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_EXPORTS_W void write( FileStorage& fs, const string& name, const Mat& value );
|
CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, const Mat& value );
|
||||||
CV_EXPORTS void write( FileStorage& fs, const string& name, const SparseMat& value );
|
CV_EXPORTS void write( FileStorage& fs, const std::string& name, const SparseMat& value );
|
||||||
|
|
||||||
template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs, const _Tp& value)
|
template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs, const _Tp& value)
|
||||||
{
|
{
|
||||||
@ -2979,10 +2969,10 @@ template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs,
|
|||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_EXPORTS FileStorage& operator << (FileStorage& fs, const string& str);
|
CV_EXPORTS FileStorage& operator << (FileStorage& fs, const std::string& str);
|
||||||
|
|
||||||
static inline FileStorage& operator << (FileStorage& fs, const char* str)
|
static inline FileStorage& operator << (FileStorage& fs, const char* str)
|
||||||
{ return (fs << string(str)); }
|
{ return (fs << std::string(str)); }
|
||||||
|
|
||||||
inline FileNode::FileNode() : fs(0), node(0) {}
|
inline FileNode::FileNode() : fs(0), node(0) {}
|
||||||
inline FileNode::FileNode(const CvFileStorage* _fs, const CvFileNode* _node)
|
inline FileNode::FileNode(const CvFileStorage* _fs, const CvFileNode* _node)
|
||||||
@ -3060,9 +3050,9 @@ static inline void read(const FileNode& node, double& value, double default_valu
|
|||||||
CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300;
|
CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void read(const FileNode& node, string& value, const string& default_value)
|
static inline void read(const FileNode& node, std::string& value, const std::string& default_value)
|
||||||
{
|
{
|
||||||
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? string(node.node->data.str.ptr) : string("");
|
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? std::string(node.node->data.str.ptr) : std::string("");
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() );
|
CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() );
|
||||||
@ -3086,14 +3076,14 @@ inline FileNode::operator double() const
|
|||||||
read(*this, value, 0.);
|
read(*this, value, 0.);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
inline FileNode::operator string() const
|
inline FileNode::operator std::string() const
|
||||||
{
|
{
|
||||||
string value;
|
std::string value;
|
||||||
read(*this, value, value);
|
read(*this, value, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FileNode::readRaw( const string& fmt, uchar* vec, size_t len ) const
|
inline void FileNode::readRaw( const std::string& fmt, uchar* vec, size_t len ) const
|
||||||
{
|
{
|
||||||
begin().readRaw( fmt, vec, len );
|
begin().readRaw( fmt, vec, len );
|
||||||
}
|
}
|
||||||
@ -3102,7 +3092,7 @@ template<typename _Tp, int numflag> class CV_EXPORTS VecReaderProxy
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VecReaderProxy( FileNodeIterator* _it ) : it(_it) {}
|
VecReaderProxy( FileNodeIterator* _it ) : it(_it) {}
|
||||||
void operator()(vector<_Tp>& vec, size_t count) const
|
void operator()(std::vector<_Tp>& vec, size_t count) const
|
||||||
{
|
{
|
||||||
count = std::min(count, it->remaining);
|
count = std::min(count, it->remaining);
|
||||||
vec.resize(count);
|
vec.resize(count);
|
||||||
@ -3116,7 +3106,7 @@ template<typename _Tp> class CV_EXPORTS VecReaderProxy<_Tp,1>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VecReaderProxy( FileNodeIterator* _it ) : it(_it) {}
|
VecReaderProxy( FileNodeIterator* _it ) : it(_it) {}
|
||||||
void operator()(vector<_Tp>& vec, size_t count) const
|
void operator()(std::vector<_Tp>& vec, size_t count) const
|
||||||
{
|
{
|
||||||
size_t remaining = it->remaining, cn = DataType<_Tp>::channels;
|
size_t remaining = it->remaining, cn = DataType<_Tp>::channels;
|
||||||
int _fmt = DataType<_Tp>::fmt;
|
int _fmt = DataType<_Tp>::fmt;
|
||||||
@ -3124,20 +3114,20 @@ public:
|
|||||||
size_t remaining1 = remaining/cn;
|
size_t remaining1 = remaining/cn;
|
||||||
count = count < remaining1 ? count : remaining1;
|
count = count < remaining1 ? count : remaining1;
|
||||||
vec.resize(count);
|
vec.resize(count);
|
||||||
it->readRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) );
|
it->readRaw( std::string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) );
|
||||||
}
|
}
|
||||||
FileNodeIterator* it;
|
FileNodeIterator* it;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp> static inline void
|
template<typename _Tp> static inline void
|
||||||
read( FileNodeIterator& it, vector<_Tp>& vec, size_t maxCount=(size_t)INT_MAX )
|
read( FileNodeIterator& it, std::vector<_Tp>& vec, size_t maxCount=(size_t)INT_MAX )
|
||||||
{
|
{
|
||||||
VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||||
r(vec, maxCount);
|
r(vec, maxCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> static inline void
|
template<typename _Tp> static inline void
|
||||||
read( const FileNode& node, vector<_Tp>& vec, const vector<_Tp>& default_value=vector<_Tp>() )
|
read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>& default_value=std::vector<_Tp>() )
|
||||||
{
|
{
|
||||||
if(!node.node)
|
if(!node.node)
|
||||||
vec = default_value;
|
vec = default_value;
|
||||||
@ -3168,7 +3158,7 @@ template<typename _Tp> static inline FileNodeIterator& operator >> (FileNodeIter
|
|||||||
{ read( *it, value, _Tp()); return ++it; }
|
{ read( *it, value, _Tp()); return ++it; }
|
||||||
|
|
||||||
template<typename _Tp> static inline
|
template<typename _Tp> static inline
|
||||||
FileNodeIterator& operator >> (FileNodeIterator& it, vector<_Tp>& vec)
|
FileNodeIterator& operator >> (FileNodeIterator& it, std::vector<_Tp>& vec)
|
||||||
{
|
{
|
||||||
VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||||
r(vec, (size_t)INT_MAX);
|
r(vec, (size_t)INT_MAX);
|
||||||
@ -3178,7 +3168,7 @@ FileNodeIterator& operator >> (FileNodeIterator& it, vector<_Tp>& vec)
|
|||||||
template<typename _Tp> static inline void operator >> (const FileNode& n, _Tp& value)
|
template<typename _Tp> static inline void operator >> (const FileNode& n, _Tp& value)
|
||||||
{ read( n, value, _Tp()); }
|
{ read( n, value, _Tp()); }
|
||||||
|
|
||||||
template<typename _Tp> static inline void operator >> (const FileNode& n, vector<_Tp>& vec)
|
template<typename _Tp> static inline void operator >> (const FileNode& n, std::vector<_Tp>& vec)
|
||||||
{ FileNodeIterator it = n.begin(); it >> vec; }
|
{ FileNodeIterator it = n.begin(); it >> vec; }
|
||||||
|
|
||||||
static inline bool operator == (const FileNodeIterator& it1, const FileNodeIterator& it2)
|
static inline bool operator == (const FileNodeIterator& it1, const FileNodeIterator& it2)
|
||||||
@ -3264,7 +3254,7 @@ template<typename _Tp> static inline _Tp gcd(_Tp a, _Tp b)
|
|||||||
|
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
|
|
||||||
template<typename _Tp, class _LT> void sort( vector<_Tp>& vec, _LT LT=_LT() )
|
template<typename _Tp, class _LT> void sort( std::vector<_Tp>& vec, _LT LT=_LT() )
|
||||||
{
|
{
|
||||||
int isort_thresh = 7;
|
int isort_thresh = 7;
|
||||||
int sp = 0;
|
int sp = 0;
|
||||||
@ -3462,7 +3452,7 @@ public:
|
|||||||
// The algorithm is described in "Introduction to Algorithms"
|
// The algorithm is described in "Introduction to Algorithms"
|
||||||
// by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets"
|
// by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets"
|
||||||
template<typename _Tp, class _EqPredicate> int
|
template<typename _Tp, class _EqPredicate> int
|
||||||
partition( const vector<_Tp>& _vec, vector<int>& labels,
|
partition( const std::vector<_Tp>& _vec, std::vector<int>& labels,
|
||||||
_EqPredicate predicate=_EqPredicate())
|
_EqPredicate predicate=_EqPredicate())
|
||||||
{
|
{
|
||||||
int i, j, N = (int)_vec.size();
|
int i, j, N = (int)_vec.size();
|
||||||
@ -3471,7 +3461,7 @@ partition( const vector<_Tp>& _vec, vector<int>& labels,
|
|||||||
const int PARENT=0;
|
const int PARENT=0;
|
||||||
const int RANK=1;
|
const int RANK=1;
|
||||||
|
|
||||||
vector<int> _nodes(N*2);
|
std::vector<int> _nodes(N*2);
|
||||||
int (*nodes)[2] = (int(*)[2])&_nodes[0];
|
int (*nodes)[2] = (int(*)[2])&_nodes[0];
|
||||||
|
|
||||||
// The first O(N) pass: create N single-vertex trees
|
// The first O(N) pass: create N single-vertex trees
|
||||||
@ -3667,7 +3657,7 @@ template<typename _Tp> inline void Seq<_Tp>::remove(int idx)
|
|||||||
template<typename _Tp> inline void Seq<_Tp>::remove(const Range& r)
|
template<typename _Tp> inline void Seq<_Tp>::remove(const Range& r)
|
||||||
{ seqRemoveSlice(seq, r); }
|
{ seqRemoveSlice(seq, r); }
|
||||||
|
|
||||||
template<typename _Tp> inline void Seq<_Tp>::copyTo(vector<_Tp>& vec, const Range& range) const
|
template<typename _Tp> inline void Seq<_Tp>::copyTo(std::vector<_Tp>& vec, const Range& range) const
|
||||||
{
|
{
|
||||||
size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start;
|
size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start;
|
||||||
vec.resize(len);
|
vec.resize(len);
|
||||||
@ -3675,9 +3665,9 @@ template<typename _Tp> inline void Seq<_Tp>::copyTo(vector<_Tp>& vec, const Rang
|
|||||||
cvCvtSeqToArray(seq, &vec[0], range);
|
cvCvtSeqToArray(seq, &vec[0], range);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline Seq<_Tp>::operator vector<_Tp>() const
|
template<typename _Tp> inline Seq<_Tp>::operator std::vector<_Tp>() const
|
||||||
{
|
{
|
||||||
vector<_Tp> vec;
|
std::vector<_Tp> vec;
|
||||||
copyTo(vec);
|
copyTo(vec);
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
@ -3815,7 +3805,7 @@ public:
|
|||||||
{
|
{
|
||||||
FileStorage fs(_fs);
|
FileStorage fs(_fs);
|
||||||
fs.fs.addref();
|
fs.fs.addref();
|
||||||
((const _ClsName*)ptr)->write(fs, string(name));
|
((const _ClsName*)ptr)->write(fs, std::string(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3843,28 +3833,28 @@ public:
|
|||||||
struct CV_EXPORTS Formatted
|
struct CV_EXPORTS Formatted
|
||||||
{
|
{
|
||||||
Formatted(const Mat& m, const Formatter* fmt,
|
Formatted(const Mat& m, const Formatter* fmt,
|
||||||
const vector<int>& params);
|
const std::vector<int>& params);
|
||||||
Formatted(const Mat& m, const Formatter* fmt,
|
Formatted(const Mat& m, const Formatter* fmt,
|
||||||
const int* params=0);
|
const int* params=0);
|
||||||
Mat mtx;
|
Mat mtx;
|
||||||
const Formatter* fmt;
|
const Formatter* fmt;
|
||||||
vector<int> params;
|
std::vector<int> params;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline Formatted format(const Mat& mtx, const char* fmt,
|
static inline Formatted format(const Mat& mtx, const char* fmt,
|
||||||
const vector<int>& params=vector<int>())
|
const std::vector<int>& params=std::vector<int>())
|
||||||
{
|
{
|
||||||
return Formatted(mtx, Formatter::get(fmt), params);
|
return Formatted(mtx, Formatter::get(fmt), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> static inline Formatted format(const vector<Point_<_Tp> >& vec,
|
template<typename _Tp> static inline Formatted format(const std::vector<Point_<_Tp> >& vec,
|
||||||
const char* fmt, const vector<int>& params=vector<int>())
|
const char* fmt, const std::vector<int>& params=std::vector<int>())
|
||||||
{
|
{
|
||||||
return Formatted(Mat(vec), Formatter::get(fmt), params);
|
return Formatted(Mat(vec), Formatter::get(fmt), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> static inline Formatted format(const vector<Point3_<_Tp> >& vec,
|
template<typename _Tp> static inline Formatted format(const std::vector<Point3_<_Tp> >& vec,
|
||||||
const char* fmt, const vector<int>& params=vector<int>())
|
const char* fmt, const std::vector<int>& params=std::vector<int>())
|
||||||
{
|
{
|
||||||
return Formatted(Mat(vec), Formatter::get(fmt), params);
|
return Formatted(Mat(vec), Formatter::get(fmt), params);
|
||||||
}
|
}
|
||||||
@ -3897,7 +3887,7 @@ static inline std::ostream& operator << (std::ostream& out, const Formatted& fmt
|
|||||||
|
|
||||||
|
|
||||||
template<typename _Tp> static inline std::ostream& operator << (std::ostream& out,
|
template<typename _Tp> static inline std::ostream& operator << (std::ostream& out,
|
||||||
const vector<Point_<_Tp> >& vec)
|
const std::vector<Point_<_Tp> >& vec)
|
||||||
{
|
{
|
||||||
Formatter::get()->write(out, Mat(vec));
|
Formatter::get()->write(out, Mat(vec));
|
||||||
return out;
|
return out;
|
||||||
@ -3905,7 +3895,7 @@ template<typename _Tp> static inline std::ostream& operator << (std::ostream& ou
|
|||||||
|
|
||||||
|
|
||||||
template<typename _Tp> static inline std::ostream& operator << (std::ostream& out,
|
template<typename _Tp> static inline std::ostream& operator << (std::ostream& out,
|
||||||
const vector<Point3_<_Tp> >& vec)
|
const std::vector<Point3_<_Tp> >& vec)
|
||||||
{
|
{
|
||||||
Formatter::get()->write(out, Mat(vec));
|
Formatter::get()->write(out, Mat(vec));
|
||||||
return out;
|
return out;
|
||||||
@ -3977,7 +3967,7 @@ template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const string& name)
|
template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const std::string& name)
|
||||||
{
|
{
|
||||||
return _create(name).ptr<_Tp>();
|
return _create(name).ptr<_Tp>();
|
||||||
}
|
}
|
||||||
@ -3993,7 +3983,7 @@ inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline void Algorithm::set(const string& _name, const Ptr<_Tp>& value)
|
inline void Algorithm::set(const std::string& _name, const Ptr<_Tp>& value)
|
||||||
{
|
{
|
||||||
this->set<_Tp>(_name.c_str(), value);
|
this->set<_Tp>(_name.c_str(), value);
|
||||||
}
|
}
|
||||||
@ -4009,12 +3999,12 @@ inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
inline void Algorithm::setAlgorithm(const string& _name, const Ptr<_Tp>& value)
|
inline void Algorithm::setAlgorithm(const std::string& _name, const Ptr<_Tp>& value)
|
||||||
{
|
{
|
||||||
this->set<_Tp>(_name.c_str(), value);
|
this->set<_Tp>(_name.c_str(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const string& _name) const
|
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const std::string& _name) const
|
||||||
{
|
{
|
||||||
typename ParamType<_Tp>::member_type value;
|
typename ParamType<_Tp>::member_type value;
|
||||||
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
|
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
|
||||||
@ -4030,7 +4020,7 @@ template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::ge
|
|||||||
|
|
||||||
template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||||
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
|
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
//TODO: static assert: _Tp inherits from _Base
|
//TODO: static assert: _Tp inherits from _Base
|
||||||
addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly,
|
||||||
@ -4039,7 +4029,7 @@ template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algor
|
|||||||
|
|
||||||
template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||||
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
|
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
//TODO: static assert: _Tp inherits from Algorithm
|
//TODO: static assert: _Tp inherits from Algorithm
|
||||||
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
|
||||||
|
@ -45,8 +45,6 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
using std::pair;
|
|
||||||
|
|
||||||
template<typename _KeyTp, typename _ValueTp> struct sorted_vector
|
template<typename _KeyTp, typename _ValueTp> struct sorted_vector
|
||||||
{
|
{
|
||||||
sorted_vector() {}
|
sorted_vector() {}
|
||||||
@ -57,7 +55,7 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
|
|||||||
|
|
||||||
void add(const _KeyTp& k, const _ValueTp& val)
|
void add(const _KeyTp& k, const _ValueTp& val)
|
||||||
{
|
{
|
||||||
pair<_KeyTp, _ValueTp> p(k, val);
|
std::pair<_KeyTp, _ValueTp> p(k, val);
|
||||||
vec.push_back(p);
|
vec.push_back(p);
|
||||||
size_t i = vec.size()-1;
|
size_t i = vec.size()-1;
|
||||||
for( ; i > 0 && vec[i].first < vec[i-1].first; i-- )
|
for( ; i > 0 && vec[i].first < vec[i-1].first; i-- )
|
||||||
@ -85,7 +83,7 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_keys(vector<_KeyTp>& keys) const
|
void get_keys(std::vector<_KeyTp>& keys) const
|
||||||
{
|
{
|
||||||
size_t i = 0, n = vec.size();
|
size_t i = 0, n = vec.size();
|
||||||
keys.resize(n);
|
keys.resize(n);
|
||||||
@ -94,11 +92,11 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
|
|||||||
keys[i] = vec[i].first;
|
keys[i] = vec[i].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<pair<_KeyTp, _ValueTp> > vec;
|
std::vector<std::pair<_KeyTp, _ValueTp> > vec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<string, _ValueTp>& vec,
|
template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<std::string, _ValueTp>& vec,
|
||||||
const char* key)
|
const char* key)
|
||||||
{
|
{
|
||||||
if( !key )
|
if( !key )
|
||||||
@ -132,7 +130,7 @@ Param::Param()
|
|||||||
|
|
||||||
Param::Param(int _type, bool _readonly, int _offset,
|
Param::Param(int _type, bool _readonly, int _offset,
|
||||||
Algorithm::Getter _getter, Algorithm::Setter _setter,
|
Algorithm::Getter _getter, Algorithm::Setter _setter,
|
||||||
const string& _help)
|
const std::string& _help)
|
||||||
{
|
{
|
||||||
type = _type;
|
type = _type;
|
||||||
readonly = _readonly;
|
readonly = _readonly;
|
||||||
@ -144,23 +142,23 @@ Param::Param(int _type, bool _readonly, int _offset,
|
|||||||
|
|
||||||
struct CV_EXPORTS AlgorithmInfoData
|
struct CV_EXPORTS AlgorithmInfoData
|
||||||
{
|
{
|
||||||
sorted_vector<string, Param> params;
|
sorted_vector<std::string, Param> params;
|
||||||
string _name;
|
std::string _name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static sorted_vector<string, Algorithm::Constructor>& alglist()
|
static sorted_vector<std::string, Algorithm::Constructor>& alglist()
|
||||||
{
|
{
|
||||||
static sorted_vector<string, Algorithm::Constructor> alglist_var;
|
static sorted_vector<std::string, Algorithm::Constructor> alglist_var;
|
||||||
return alglist_var;
|
return alglist_var;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::getList(vector<string>& algorithms)
|
void Algorithm::getList(std::vector<std::string>& algorithms)
|
||||||
{
|
{
|
||||||
alglist().get_keys(algorithms);
|
alglist().get_keys(algorithms);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<Algorithm> Algorithm::_create(const string& name)
|
Ptr<Algorithm> Algorithm::_create(const std::string& name)
|
||||||
{
|
{
|
||||||
Algorithm::Constructor c = 0;
|
Algorithm::Constructor c = 0;
|
||||||
if( !alglist().find(name, c) )
|
if( !alglist().find(name, c) )
|
||||||
@ -176,42 +174,42 @@ Algorithm::~Algorithm()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
string Algorithm::name() const
|
std::string Algorithm::name() const
|
||||||
{
|
{
|
||||||
return info()->name();
|
return info()->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const string& parameter, int value)
|
void Algorithm::set(const std::string& parameter, int value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const string& parameter, double value)
|
void Algorithm::set(const std::string& parameter, double value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const string& parameter, bool value)
|
void Algorithm::set(const std::string& parameter, bool value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const string& parameter, const string& value)
|
void Algorithm::set(const std::string& parameter, const std::string& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<string>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<std::string>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const string& parameter, const Mat& value)
|
void Algorithm::set(const std::string& parameter, const Mat& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const string& parameter, const vector<Mat>& value)
|
void Algorithm::set(const std::string& parameter, const std::vector<Mat>& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<vector<Mat> >::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<std::vector<Mat> >::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const string& parameter, const Ptr<Algorithm>& value)
|
void Algorithm::set(const std::string& parameter, const Ptr<Algorithm>& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
|
||||||
}
|
}
|
||||||
@ -231,9 +229,9 @@ void Algorithm::set(const char* parameter, bool value)
|
|||||||
info()->set(this, parameter, ParamType<bool>::type, &value);
|
info()->set(this, parameter, ParamType<bool>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const char* parameter, const string& value)
|
void Algorithm::set(const char* parameter, const std::string& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter, ParamType<string>::type, &value);
|
info()->set(this, parameter, ParamType<std::string>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const char* parameter, const Mat& value)
|
void Algorithm::set(const char* parameter, const Mat& value)
|
||||||
@ -241,9 +239,9 @@ void Algorithm::set(const char* parameter, const Mat& value)
|
|||||||
info()->set(this, parameter, ParamType<Mat>::type, &value);
|
info()->set(this, parameter, ParamType<Mat>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const char* parameter, const vector<Mat>& value)
|
void Algorithm::set(const char* parameter, const std::vector<Mat>& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter, ParamType<vector<Mat> >::type, &value);
|
info()->set(this, parameter, ParamType<std::vector<Mat> >::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::set(const char* parameter, const Ptr<Algorithm>& value)
|
void Algorithm::set(const char* parameter, const Ptr<Algorithm>& value)
|
||||||
@ -252,37 +250,37 @@ void Algorithm::set(const char* parameter, const Ptr<Algorithm>& value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Algorithm::setInt(const string& parameter, int value)
|
void Algorithm::setInt(const std::string& parameter, int value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setDouble(const string& parameter, double value)
|
void Algorithm::setDouble(const std::string& parameter, double value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setBool(const string& parameter, bool value)
|
void Algorithm::setBool(const std::string& parameter, bool value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setString(const string& parameter, const string& value)
|
void Algorithm::setString(const std::string& parameter, const std::string& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<string>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<std::string>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setMat(const string& parameter, const Mat& value)
|
void Algorithm::setMat(const std::string& parameter, const Mat& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setMatVector(const string& parameter, const vector<Mat>& value)
|
void Algorithm::setMatVector(const std::string& parameter, const std::vector<Mat>& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<vector<Mat> >::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<std::vector<Mat> >::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setAlgorithm(const string& parameter, const Ptr<Algorithm>& value)
|
void Algorithm::setAlgorithm(const std::string& parameter, const Ptr<Algorithm>& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
|
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
|
||||||
}
|
}
|
||||||
@ -302,9 +300,9 @@ void Algorithm::setBool(const char* parameter, bool value)
|
|||||||
info()->set(this, parameter, ParamType<bool>::type, &value);
|
info()->set(this, parameter, ParamType<bool>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setString(const char* parameter, const string& value)
|
void Algorithm::setString(const char* parameter, const std::string& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter, ParamType<string>::type, &value);
|
info()->set(this, parameter, ParamType<std::string>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setMat(const char* parameter, const Mat& value)
|
void Algorithm::setMat(const char* parameter, const Mat& value)
|
||||||
@ -312,9 +310,9 @@ void Algorithm::setMat(const char* parameter, const Mat& value)
|
|||||||
info()->set(this, parameter, ParamType<Mat>::type, &value);
|
info()->set(this, parameter, ParamType<Mat>::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setMatVector(const char* parameter, const vector<Mat>& value)
|
void Algorithm::setMatVector(const char* parameter, const std::vector<Mat>& value)
|
||||||
{
|
{
|
||||||
info()->set(this, parameter, ParamType<vector<Mat> >::type, &value);
|
info()->set(this, parameter, ParamType<std::vector<Mat> >::type, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::setAlgorithm(const char* parameter, const Ptr<Algorithm>& value)
|
void Algorithm::setAlgorithm(const char* parameter, const Ptr<Algorithm>& value)
|
||||||
@ -324,47 +322,47 @@ void Algorithm::setAlgorithm(const char* parameter, const Ptr<Algorithm>& value)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int Algorithm::getInt(const string& parameter) const
|
int Algorithm::getInt(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return get<int>(parameter);
|
return get<int>(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Algorithm::getDouble(const string& parameter) const
|
double Algorithm::getDouble(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return get<double>(parameter);
|
return get<double>(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Algorithm::getBool(const string& parameter) const
|
bool Algorithm::getBool(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return get<bool>(parameter);
|
return get<bool>(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
string Algorithm::getString(const string& parameter) const
|
std::string Algorithm::getString(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return get<string>(parameter);
|
return get<std::string>(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat Algorithm::getMat(const string& parameter) const
|
Mat Algorithm::getMat(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return get<Mat>(parameter);
|
return get<Mat>(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Mat> Algorithm::getMatVector(const string& parameter) const
|
std::vector<Mat> Algorithm::getMatVector(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return get<vector<Mat> >(parameter);
|
return get<std::vector<Mat> >(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<Algorithm> Algorithm::getAlgorithm(const string& parameter) const
|
Ptr<Algorithm> Algorithm::getAlgorithm(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return get<Algorithm>(parameter);
|
return get<Algorithm>(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
string Algorithm::paramHelp(const string& parameter) const
|
std::string Algorithm::paramHelp(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return info()->paramHelp(parameter.c_str());
|
return info()->paramHelp(parameter.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Algorithm::paramType(const string& parameter) const
|
int Algorithm::paramType(const std::string& parameter) const
|
||||||
{
|
{
|
||||||
return info()->paramType(parameter.c_str());
|
return info()->paramType(parameter.c_str());
|
||||||
}
|
}
|
||||||
@ -374,7 +372,7 @@ int Algorithm::paramType(const char* parameter) const
|
|||||||
return info()->paramType(parameter);
|
return info()->paramType(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Algorithm::getParams(vector<string>& names) const
|
void Algorithm::getParams(std::vector<std::string>& names) const
|
||||||
{
|
{
|
||||||
info()->getParams(names);
|
info()->getParams(names);
|
||||||
}
|
}
|
||||||
@ -390,7 +388,7 @@ void Algorithm::read(const FileNode& fn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AlgorithmInfo::AlgorithmInfo(const string& _name, Algorithm::Constructor create)
|
AlgorithmInfo::AlgorithmInfo(const std::string& _name, Algorithm::Constructor create)
|
||||||
{
|
{
|
||||||
data = new AlgorithmInfoData;
|
data = new AlgorithmInfoData;
|
||||||
data->_name = _name;
|
data->_name = _name;
|
||||||
@ -410,7 +408,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
|||||||
for( i = 0; i < nparams; i++ )
|
for( i = 0; i < nparams; i++ )
|
||||||
{
|
{
|
||||||
const Param& p = data->params.vec[i].second;
|
const Param& p = data->params.vec[i].second;
|
||||||
const string& pname = data->params.vec[i].first;
|
const std::string& pname = data->params.vec[i].first;
|
||||||
if( p.type == Param::INT )
|
if( p.type == Param::INT )
|
||||||
cv::write(fs, pname, algo->get<int>(pname));
|
cv::write(fs, pname, algo->get<int>(pname));
|
||||||
else if( p.type == Param::BOOLEAN )
|
else if( p.type == Param::BOOLEAN )
|
||||||
@ -418,11 +416,11 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
|||||||
else if( p.type == Param::REAL )
|
else if( p.type == Param::REAL )
|
||||||
cv::write(fs, pname, algo->get<double>(pname));
|
cv::write(fs, pname, algo->get<double>(pname));
|
||||||
else if( p.type == Param::STRING )
|
else if( p.type == Param::STRING )
|
||||||
cv::write(fs, pname, algo->get<string>(pname));
|
cv::write(fs, pname, algo->get<std::string>(pname));
|
||||||
else if( p.type == Param::MAT )
|
else if( p.type == Param::MAT )
|
||||||
cv::write(fs, pname, algo->get<Mat>(pname));
|
cv::write(fs, pname, algo->get<Mat>(pname));
|
||||||
else if( p.type == Param::MAT_VECTOR )
|
else if( p.type == Param::MAT_VECTOR )
|
||||||
cv::write(fs, pname, algo->get<vector<Mat> >(pname));
|
cv::write(fs, pname, algo->get<std::vector<Mat> >(pname));
|
||||||
else if( p.type == Param::ALGORITHM )
|
else if( p.type == Param::ALGORITHM )
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, pname, CV_NODE_MAP);
|
WriteStructContext ws(fs, pname, CV_NODE_MAP);
|
||||||
@ -431,7 +429,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
||||||
CV_Error( CV_StsUnsupportedFormat, msg.c_str());
|
CV_Error( CV_StsUnsupportedFormat, msg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,7 +443,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
|||||||
for( i = 0; i < nparams; i++ )
|
for( i = 0; i < nparams; i++ )
|
||||||
{
|
{
|
||||||
const Param& p = data->params.vec[i].second;
|
const Param& p = data->params.vec[i].second;
|
||||||
const string& pname = data->params.vec[i].first;
|
const std::string& pname = data->params.vec[i].first;
|
||||||
const FileNode n = fn[pname];
|
const FileNode n = fn[pname];
|
||||||
if( n.empty() )
|
if( n.empty() )
|
||||||
continue;
|
continue;
|
||||||
@ -466,7 +464,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
|||||||
}
|
}
|
||||||
else if( p.type == Param::STRING )
|
else if( p.type == Param::STRING )
|
||||||
{
|
{
|
||||||
string val = (string)n;
|
std::string val = (std::string)n;
|
||||||
info->set(algo, pname.c_str(), p.type, &val, true);
|
info->set(algo, pname.c_str(), p.type, &val, true);
|
||||||
}
|
}
|
||||||
else if( p.type == Param::MAT )
|
else if( p.type == Param::MAT )
|
||||||
@ -477,26 +475,26 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
|||||||
}
|
}
|
||||||
else if( p.type == Param::MAT_VECTOR )
|
else if( p.type == Param::MAT_VECTOR )
|
||||||
{
|
{
|
||||||
vector<Mat> mv;
|
std::vector<Mat> mv;
|
||||||
cv::read(n, mv);
|
cv::read(n, mv);
|
||||||
info->set(algo, pname.c_str(), p.type, &mv, true);
|
info->set(algo, pname.c_str(), p.type, &mv, true);
|
||||||
}
|
}
|
||||||
else if( p.type == Param::ALGORITHM )
|
else if( p.type == Param::ALGORITHM )
|
||||||
{
|
{
|
||||||
Ptr<Algorithm> nestedAlgo = Algorithm::_create((string)n["name"]);
|
Ptr<Algorithm> nestedAlgo = Algorithm::_create((std::string)n["name"]);
|
||||||
CV_Assert( !nestedAlgo.empty() );
|
CV_Assert( !nestedAlgo.empty() );
|
||||||
nestedAlgo->read(n);
|
nestedAlgo->read(n);
|
||||||
info->set(algo, pname.c_str(), p.type, &nestedAlgo, true);
|
info->set(algo, pname.c_str(), p.type, &nestedAlgo, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
||||||
CV_Error( CV_StsUnsupportedFormat, msg.c_str());
|
CV_Error( CV_StsUnsupportedFormat, msg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string AlgorithmInfo::name() const
|
std::string AlgorithmInfo::name() const
|
||||||
{
|
{
|
||||||
return data->_name;
|
return data->_name;
|
||||||
}
|
}
|
||||||
@ -506,23 +504,23 @@ union GetSetParam
|
|||||||
int (Algorithm::*get_int)() const;
|
int (Algorithm::*get_int)() const;
|
||||||
bool (Algorithm::*get_bool)() const;
|
bool (Algorithm::*get_bool)() const;
|
||||||
double (Algorithm::*get_double)() const;
|
double (Algorithm::*get_double)() const;
|
||||||
string (Algorithm::*get_string)() const;
|
std::string (Algorithm::*get_string)() const;
|
||||||
Mat (Algorithm::*get_mat)() const;
|
Mat (Algorithm::*get_mat)() const;
|
||||||
vector<Mat> (Algorithm::*get_mat_vector)() const;
|
std::vector<Mat> (Algorithm::*get_mat_vector)() const;
|
||||||
Ptr<Algorithm> (Algorithm::*get_algo)() const;
|
Ptr<Algorithm> (Algorithm::*get_algo)() const;
|
||||||
|
|
||||||
void (Algorithm::*set_int)(int);
|
void (Algorithm::*set_int)(int);
|
||||||
void (Algorithm::*set_bool)(bool);
|
void (Algorithm::*set_bool)(bool);
|
||||||
void (Algorithm::*set_double)(double);
|
void (Algorithm::*set_double)(double);
|
||||||
void (Algorithm::*set_string)(const string&);
|
void (Algorithm::*set_string)(const std::string&);
|
||||||
void (Algorithm::*set_mat)(const Mat&);
|
void (Algorithm::*set_mat)(const Mat&);
|
||||||
void (Algorithm::*set_mat_vector)(const vector<Mat>&);
|
void (Algorithm::*set_mat_vector)(const std::vector<Mat>&);
|
||||||
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
|
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
|
||||||
};
|
};
|
||||||
|
|
||||||
static string getNameOfType(int argType);
|
static std::string getNameOfType(int argType);
|
||||||
|
|
||||||
static string getNameOfType(int argType)
|
static std::string getNameOfType(int argType)
|
||||||
{
|
{
|
||||||
switch(argType)
|
switch(argType)
|
||||||
{
|
{
|
||||||
@ -537,10 +535,10 @@ static string getNameOfType(int argType)
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
static string getErrorMessageForWrongArgumentInSetter(string algoName, string paramName, int paramType, int argType);
|
|
||||||
static string getErrorMessageForWrongArgumentInSetter(string algoName, string paramName, int paramType, int argType)
|
static std::string getErrorMessageForWrongArgumentInSetter(std::string algoName, std::string paramName, int paramType, int argType)
|
||||||
{
|
{
|
||||||
string message = string("Argument error: the setter")
|
std::string message = std::string("Argument error: the setter")
|
||||||
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
|
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
|
||||||
+"', the parameter has " + getNameOfType(paramType) + " type, ";
|
+"', the parameter has " + getNameOfType(paramType) + " type, ";
|
||||||
|
|
||||||
@ -553,10 +551,9 @@ static string getErrorMessageForWrongArgumentInSetter(string algoName, string pa
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string getErrorMessageForWrongArgumentInGetter(string algoName, string paramName, int paramType, int argType);
|
static std::string getErrorMessageForWrongArgumentInGetter(std::string algoName, std::string paramName, int paramType, int argType)
|
||||||
static string getErrorMessageForWrongArgumentInGetter(string algoName, string paramName, int paramType, int argType)
|
|
||||||
{
|
{
|
||||||
string message = string("Argument error: the getter")
|
std::string message = std::string("Argument error: the getter")
|
||||||
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
|
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
|
||||||
+"', the parameter has " + getNameOfType(paramType) + " type, ";
|
+"', the parameter has " + getNameOfType(paramType) + " type, ";
|
||||||
|
|
||||||
@ -590,7 +587,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
|||||||
{
|
{
|
||||||
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN) )
|
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN) )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,21 +626,21 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
|||||||
{
|
{
|
||||||
if( p->type != Param::STRING )
|
if( p->type != Param::STRING )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const string& val = *(const string*)value;
|
const std::string& val = *(const std::string*)value;
|
||||||
if( p->setter )
|
if( p->setter )
|
||||||
(algo->*f.set_string)(val);
|
(algo->*f.set_string)(val);
|
||||||
else
|
else
|
||||||
*(string*)((uchar*)algo + p->offset) = val;
|
*(std::string*)((uchar*)algo + p->offset) = val;
|
||||||
}
|
}
|
||||||
else if( argType == Param::MAT )
|
else if( argType == Param::MAT )
|
||||||
{
|
{
|
||||||
if( p->type != Param::MAT )
|
if( p->type != Param::MAT )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,21 +654,21 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
|||||||
{
|
{
|
||||||
if( p->type != Param::MAT_VECTOR )
|
if( p->type != Param::MAT_VECTOR )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<Mat>& val = *(const vector<Mat>*)value;
|
const std::vector<Mat>& val = *(const std::vector<Mat>*)value;
|
||||||
if( p->setter )
|
if( p->setter )
|
||||||
(algo->*f.set_mat_vector)(val);
|
(algo->*f.set_mat_vector)(val);
|
||||||
else
|
else
|
||||||
*(vector<Mat>*)((uchar*)algo + p->offset) = val;
|
*(std::vector<Mat>*)((uchar*)algo + p->offset) = val;
|
||||||
}
|
}
|
||||||
else if( argType == Param::ALGORITHM )
|
else if( argType == Param::ALGORITHM )
|
||||||
{
|
{
|
||||||
if( p->type != Param::ALGORITHM )
|
if( p->type != Param::ALGORITHM )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,7 +697,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|||||||
{
|
{
|
||||||
if (!( argType == Param::INT || argType == Param::REAL ))
|
if (!( argType == Param::INT || argType == Param::REAL ))
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset);
|
int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset);
|
||||||
@ -714,7 +711,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|||||||
{
|
{
|
||||||
if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL ))
|
if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL ))
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
bool val = p->getter ? (algo->*f.get_bool)() : *(bool*)((uchar*)algo + p->offset);
|
bool val = p->getter ? (algo->*f.get_bool)() : *(bool*)((uchar*)algo + p->offset);
|
||||||
@ -730,7 +727,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|||||||
{
|
{
|
||||||
if( argType != Param::REAL )
|
if( argType != Param::REAL )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset);
|
double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset);
|
||||||
@ -742,18 +739,18 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|||||||
{
|
{
|
||||||
if( p->type != Param::STRING )
|
if( p->type != Param::STRING )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
*(string*)value = p->getter ? (algo->*f.get_string)() :
|
*(std::string*)value = p->getter ? (algo->*f.get_string)() :
|
||||||
*(string*)((uchar*)algo + p->offset);
|
*(std::string*)((uchar*)algo + p->offset);
|
||||||
}
|
}
|
||||||
else if( argType == Param::MAT )
|
else if( argType == Param::MAT )
|
||||||
{
|
{
|
||||||
if( p->type != Param::MAT )
|
if( p->type != Param::MAT )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,18 +761,18 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|||||||
{
|
{
|
||||||
if( p->type != Param::MAT_VECTOR )
|
if( p->type != Param::MAT_VECTOR )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
*(vector<Mat>*)value = p->getter ? (algo->*f.get_mat_vector)() :
|
*(std::vector<Mat>*)value = p->getter ? (algo->*f.get_mat_vector)() :
|
||||||
*(vector<Mat>*)((uchar*)algo + p->offset);
|
*(std::vector<Mat>*)((uchar*)algo + p->offset);
|
||||||
}
|
}
|
||||||
else if( argType == Param::ALGORITHM )
|
else if( argType == Param::ALGORITHM )
|
||||||
{
|
{
|
||||||
if( p->type != Param::ALGORITHM )
|
if( p->type != Param::ALGORITHM )
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,7 +781,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||||
CV_Error(CV_StsBadArg, message);
|
CV_Error(CV_StsBadArg, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -799,7 +796,7 @@ int AlgorithmInfo::paramType(const char* parameter) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string AlgorithmInfo::paramHelp(const char* parameter) const
|
std::string AlgorithmInfo::paramHelp(const char* parameter) const
|
||||||
{
|
{
|
||||||
const Param* p = findstr(data->params, parameter);
|
const Param* p = findstr(data->params, parameter);
|
||||||
if( !p )
|
if( !p )
|
||||||
@ -808,7 +805,7 @@ string AlgorithmInfo::paramHelp(const char* parameter) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AlgorithmInfo::getParams(vector<string>& names) const
|
void AlgorithmInfo::getParams(std::vector<std::string>& names) const
|
||||||
{
|
{
|
||||||
data->params.get_keys(names);
|
data->params.get_keys(names);
|
||||||
}
|
}
|
||||||
@ -817,13 +814,13 @@ void AlgorithmInfo::getParams(vector<string>& names) const
|
|||||||
void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argType,
|
void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argType,
|
||||||
void* value, bool readOnly,
|
void* value, bool readOnly,
|
||||||
Algorithm::Getter getter, Algorithm::Setter setter,
|
Algorithm::Getter getter, Algorithm::Setter setter,
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
|
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
|
||||||
argType == Param::REAL || argType == Param::STRING ||
|
argType == Param::REAL || argType == Param::STRING ||
|
||||||
argType == Param::MAT || argType == Param::MAT_VECTOR ||
|
argType == Param::MAT || argType == Param::MAT_VECTOR ||
|
||||||
argType == Param::ALGORITHM );
|
argType == Param::ALGORITHM );
|
||||||
data->params.add(string(parameter), Param(argType, readOnly,
|
data->params.add(std::string(parameter), Param(argType, readOnly,
|
||||||
(int)((size_t)value - (size_t)(void*)&algo),
|
(int)((size_t)value - (size_t)(void*)&algo),
|
||||||
getter, setter, help));
|
getter, setter, help));
|
||||||
}
|
}
|
||||||
@ -833,7 +830,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|||||||
int& value, bool readOnly,
|
int& value, bool readOnly,
|
||||||
int (Algorithm::*getter)(),
|
int (Algorithm::*getter)(),
|
||||||
void (Algorithm::*setter)(int),
|
void (Algorithm::*setter)(int),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
|
||||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||||
@ -843,7 +840,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|||||||
bool& value, bool readOnly,
|
bool& value, bool readOnly,
|
||||||
int (Algorithm::*getter)(),
|
int (Algorithm::*getter)(),
|
||||||
void (Algorithm::*setter)(int),
|
void (Algorithm::*setter)(int),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
addParam_(algo, parameter, ParamType<bool>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<bool>::type, &value, readOnly,
|
||||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||||
@ -853,19 +850,19 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|||||||
double& value, bool readOnly,
|
double& value, bool readOnly,
|
||||||
double (Algorithm::*getter)(),
|
double (Algorithm::*getter)(),
|
||||||
void (Algorithm::*setter)(double),
|
void (Algorithm::*setter)(double),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
addParam_(algo, parameter, ParamType<double>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<double>::type, &value, readOnly,
|
||||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||||
string& value, bool readOnly,
|
std::string& value, bool readOnly,
|
||||||
string (Algorithm::*getter)(),
|
std::string (Algorithm::*getter)(),
|
||||||
void (Algorithm::*setter)(const string&),
|
void (Algorithm::*setter)(const std::string&),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
addParam_(algo, parameter, ParamType<string>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<std::string>::type, &value, readOnly,
|
||||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,19 +870,19 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|||||||
Mat& value, bool readOnly,
|
Mat& value, bool readOnly,
|
||||||
Mat (Algorithm::*getter)(),
|
Mat (Algorithm::*getter)(),
|
||||||
void (Algorithm::*setter)(const Mat&),
|
void (Algorithm::*setter)(const Mat&),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
addParam_(algo, parameter, ParamType<Mat>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<Mat>::type, &value, readOnly,
|
||||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||||
vector<Mat>& value, bool readOnly,
|
std::vector<Mat>& value, bool readOnly,
|
||||||
vector<Mat> (Algorithm::*getter)(),
|
std::vector<Mat> (Algorithm::*getter)(),
|
||||||
void (Algorithm::*setter)(const vector<Mat>&),
|
void (Algorithm::*setter)(const std::vector<Mat>&),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
addParam_(algo, parameter, ParamType<vector<Mat> >::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<std::vector<Mat> >::type, &value, readOnly,
|
||||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -893,7 +890,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|||||||
Ptr<Algorithm>& value, bool readOnly,
|
Ptr<Algorithm>& value, bool readOnly,
|
||||||
Ptr<Algorithm> (Algorithm::*getter)(),
|
Ptr<Algorithm> (Algorithm::*getter)(),
|
||||||
void (Algorithm::*setter)(const Ptr<Algorithm>&),
|
void (Algorithm::*setter)(const Ptr<Algorithm>&),
|
||||||
const string& help)
|
const std::string& help)
|
||||||
{
|
{
|
||||||
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
|
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
|
||||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||||
|
@ -9,9 +9,9 @@ namespace cv
|
|||||||
struct CommandLineParserParams
|
struct CommandLineParserParams
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
string help_message;
|
std::string help_message;
|
||||||
string def_value;
|
std::string def_value;
|
||||||
vector<string> keys;
|
std::vector<std::string> keys;
|
||||||
int number;
|
int number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,27 +19,27 @@ public:
|
|||||||
struct CommandLineParser::Impl
|
struct CommandLineParser::Impl
|
||||||
{
|
{
|
||||||
bool error;
|
bool error;
|
||||||
string error_message;
|
std::string error_message;
|
||||||
string about_message;
|
std::string about_message;
|
||||||
|
|
||||||
string path_to_app;
|
std::string path_to_app;
|
||||||
string app_name;
|
std::string app_name;
|
||||||
|
|
||||||
vector<CommandLineParserParams> data;
|
std::vector<CommandLineParserParams> data;
|
||||||
|
|
||||||
vector<string> split_range_string(const string& str, char fs, char ss) const;
|
std::vector<std::string> split_range_string(const std::string& str, char fs, char ss) const;
|
||||||
vector<string> split_string(const string& str, char symbol = ' ', bool create_empty_item = false) const;
|
std::vector<std::string> split_string(const std::string& str, char symbol = ' ', bool create_empty_item = false) const;
|
||||||
string cat_string(const string& str) const;
|
std::string cat_string(const std::string& str) const;
|
||||||
|
|
||||||
void apply_params(const string& key, const string& value);
|
void apply_params(const std::string& key, const std::string& value);
|
||||||
void apply_params(int i, string value);
|
void apply_params(int i, std::string value);
|
||||||
|
|
||||||
void sort_params();
|
void sort_params();
|
||||||
int refcount;
|
int refcount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static string get_type_name(int type)
|
static std::string get_type_name(int type)
|
||||||
{
|
{
|
||||||
if( type == Param::INT )
|
if( type == Param::INT )
|
||||||
return "int";
|
return "int";
|
||||||
@ -56,7 +56,7 @@ static string get_type_name(int type)
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void from_str(const string& str, int type, void* dst)
|
static void from_str(const std::string& str, int type, void* dst)
|
||||||
{
|
{
|
||||||
std::stringstream ss(str);
|
std::stringstream ss(str);
|
||||||
if( type == Param::INT )
|
if( type == Param::INT )
|
||||||
@ -70,20 +70,20 @@ static void from_str(const string& str, int type, void* dst)
|
|||||||
else if( type == Param::REAL )
|
else if( type == Param::REAL )
|
||||||
ss >> *(double*)dst;
|
ss >> *(double*)dst;
|
||||||
else if( type == Param::STRING )
|
else if( type == Param::STRING )
|
||||||
*(string*)dst = str;
|
*(std::string*)dst = str;
|
||||||
else
|
else
|
||||||
throw cv::Exception(CV_StsBadArg, "unknown/unsupported parameter type", "", __FILE__, __LINE__);
|
throw cv::Exception(CV_StsBadArg, "unknown/unsupported parameter type", "", __FILE__, __LINE__);
|
||||||
|
|
||||||
if (ss.fail())
|
if (ss.fail())
|
||||||
{
|
{
|
||||||
string err_msg = "can not convert: [" + str +
|
std::string err_msg = "can not convert: [" + str +
|
||||||
+ "] to [" + get_type_name(type) + "]";
|
+ "] to [" + get_type_name(type) + "]";
|
||||||
|
|
||||||
throw cv::Exception(CV_StsBadArg, err_msg, "", __FILE__, __LINE__);
|
throw cv::Exception(CV_StsBadArg, err_msg, "", __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineParser::getByName(const string& name, bool space_delete, int type, void* dst) const
|
void CommandLineParser::getByName(const std::string& name, bool space_delete, int type, void* dst) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ void CommandLineParser::getByName(const string& name, bool space_delete, int typ
|
|||||||
{
|
{
|
||||||
if (name.compare(impl->data[i].keys[j]) == 0)
|
if (name.compare(impl->data[i].keys[j]) == 0)
|
||||||
{
|
{
|
||||||
string v = impl->data[i].def_value;
|
std::string v = impl->data[i].def_value;
|
||||||
if (space_delete)
|
if (space_delete)
|
||||||
v = impl->cat_string(v);
|
v = impl->cat_string(v);
|
||||||
from_str(v, type, dst);
|
from_str(v, type, dst);
|
||||||
@ -107,7 +107,7 @@ void CommandLineParser::getByName(const string& name, bool space_delete, int typ
|
|||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
impl->error = true;
|
impl->error = true;
|
||||||
impl->error_message += "Exception: " + string(e.what()) + "\n";
|
impl->error_message += "Exception: " + std::string(e.what()) + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
|
|||||||
{
|
{
|
||||||
if (impl->data[i].number == index)
|
if (impl->data[i].number == index)
|
||||||
{
|
{
|
||||||
string v = impl->data[i].def_value;
|
std::string v = impl->data[i].def_value;
|
||||||
if (space_delete == true) v = impl->cat_string(v);
|
if (space_delete == true) v = impl->cat_string(v);
|
||||||
from_str(v, type, dst);
|
from_str(v, type, dst);
|
||||||
return;
|
return;
|
||||||
@ -132,7 +132,7 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
|
|||||||
catch(std::exception & e)
|
catch(std::exception & e)
|
||||||
{
|
{
|
||||||
impl->error = true;
|
impl->error = true;
|
||||||
impl->error_message += "Exception: " + string(e.what()) + "\n";
|
impl->error_message += "Exception: " + std::string(e.what()) + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,34 +152,34 @@ static bool cmp_params(const CommandLineParserParams & p1, const CommandLinePars
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const string& keys)
|
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const std::string& keys)
|
||||||
{
|
{
|
||||||
impl = new Impl;
|
impl = new Impl;
|
||||||
impl->refcount = 1;
|
impl->refcount = 1;
|
||||||
|
|
||||||
// path to application
|
// path to application
|
||||||
size_t pos_s = string(argv[0]).find_last_of("/\\");
|
size_t pos_s = std::string(argv[0]).find_last_of("/\\");
|
||||||
if (pos_s == string::npos)
|
if (pos_s == std::string::npos)
|
||||||
{
|
{
|
||||||
impl->path_to_app = "";
|
impl->path_to_app = "";
|
||||||
impl->app_name = string(argv[0]);
|
impl->app_name = std::string(argv[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
impl->path_to_app = string(argv[0]).substr(0, pos_s);
|
impl->path_to_app = std::string(argv[0]).substr(0, pos_s);
|
||||||
impl->app_name = string(argv[0]).substr(pos_s + 1, string(argv[0]).length() - pos_s);
|
impl->app_name = std::string(argv[0]).substr(pos_s + 1, std::string(argv[0]).length() - pos_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->error = false;
|
impl->error = false;
|
||||||
impl->error_message = "";
|
impl->error_message = "";
|
||||||
|
|
||||||
// parse keys
|
// parse keys
|
||||||
vector<string> k = impl->split_range_string(keys, '{', '}');
|
std::vector<std::string> k = impl->split_range_string(keys, '{', '}');
|
||||||
|
|
||||||
int jj = 0;
|
int jj = 0;
|
||||||
for (size_t i = 0; i < k.size(); i++)
|
for (size_t i = 0; i < k.size(); i++)
|
||||||
{
|
{
|
||||||
vector<string> l = impl->split_string(k[i], '|', true);
|
std::vector<std::string> l = impl->split_string(k[i], '|', true);
|
||||||
CommandLineParserParams p;
|
CommandLineParserParams p;
|
||||||
p.keys = impl->split_string(l[0]);
|
p.keys = impl->split_string(l[0]);
|
||||||
p.def_value = l[1];
|
p.def_value = l[1];
|
||||||
@ -206,11 +206,11 @@ CommandLineParser::CommandLineParser(int argc, const char* const argv[], const s
|
|||||||
jj = 0;
|
jj = 0;
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
string s = string(argv[i]);
|
std::string s = std::string(argv[i]);
|
||||||
|
|
||||||
if (s.find('=') != string::npos && s.find('=') < s.length())
|
if (s.find('=') != std::string::npos && s.find('=') < s.length())
|
||||||
{
|
{
|
||||||
vector<string> k_v = impl->split_string(s, '=', true);
|
std::vector<std::string> k_v = impl->split_string(s, '=', true);
|
||||||
for (int h = 0; h < 2; h++)
|
for (int h = 0; h < 2; h++)
|
||||||
{
|
{
|
||||||
if (k_v[0][0] == '-')
|
if (k_v[0][0] == '-')
|
||||||
@ -256,12 +256,12 @@ CommandLineParser& CommandLineParser::operator = (const CommandLineParser& parse
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineParser::about(const string& message)
|
void CommandLineParser::about(const std::string& message)
|
||||||
{
|
{
|
||||||
impl->about_message = message;
|
impl->about_message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineParser::Impl::apply_params(const string& key, const string& value)
|
void CommandLineParser::Impl::apply_params(const std::string& key, const std::string& value)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < data.size(); i++)
|
for (size_t i = 0; i < data.size(); i++)
|
||||||
{
|
{
|
||||||
@ -276,7 +276,7 @@ void CommandLineParser::Impl::apply_params(const string& key, const string& valu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineParser::Impl::apply_params(int i, string value)
|
void CommandLineParser::Impl::apply_params(int i, std::string value)
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < data.size(); j++)
|
for (size_t j = 0; j < data.size(); j++)
|
||||||
{
|
{
|
||||||
@ -298,28 +298,28 @@ void CommandLineParser::Impl::sort_params()
|
|||||||
std::sort (data.begin(), data.end(), cmp_params);
|
std::sort (data.begin(), data.end(), cmp_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
string CommandLineParser::Impl::cat_string(const string& str) const
|
std::string CommandLineParser::Impl::cat_string(const std::string& str) const
|
||||||
{
|
{
|
||||||
int left = 0, right = (int)str.length();
|
int left = 0, right = (int)str.length();
|
||||||
while( left <= right && str[left] == ' ' )
|
while( left <= right && str[left] == ' ' )
|
||||||
left++;
|
left++;
|
||||||
while( right > left && str[right-1] == ' ' )
|
while( right > left && str[right-1] == ' ' )
|
||||||
right--;
|
right--;
|
||||||
return left >= right ? string("") : str.substr(left, right-left);
|
return left >= right ? std::string("") : str.substr(left, right-left);
|
||||||
}
|
}
|
||||||
|
|
||||||
string CommandLineParser::getPathToApplication() const
|
std::string CommandLineParser::getPathToApplication() const
|
||||||
{
|
{
|
||||||
return impl->path_to_app;
|
return impl->path_to_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandLineParser::has(const string& name) const
|
bool CommandLineParser::has(const std::string& name) const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < impl->data.size(); i++)
|
for (size_t i = 0; i < impl->data.size(); i++)
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
||||||
{
|
{
|
||||||
if (name.compare(impl->data[i].keys[j]) == 0 && string("true").compare(impl->data[i].def_value) == 0)
|
if (name.compare(impl->data[i].keys[j]) == 0 && std::string("true").compare(impl->data[i].def_value) == 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ void CommandLineParser::printMessage() const
|
|||||||
{
|
{
|
||||||
if (impl->data[i].number > -1)
|
if (impl->data[i].number > -1)
|
||||||
{
|
{
|
||||||
string name = impl->data[i].keys[0].substr(1, impl->data[i].keys[0].length() - 1);
|
std::string name = impl->data[i].keys[0].substr(1, impl->data[i].keys[0].length() - 1);
|
||||||
std::cout << name << " ";
|
std::cout << name << " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,7 +366,7 @@ void CommandLineParser::printMessage() const
|
|||||||
std::cout << "\t";
|
std::cout << "\t";
|
||||||
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
||||||
{
|
{
|
||||||
string k = impl->data[i].keys[j];
|
std::string k = impl->data[i].keys[j];
|
||||||
if (k.length() > 1)
|
if (k.length() > 1)
|
||||||
{
|
{
|
||||||
std::cout << "--";
|
std::cout << "--";
|
||||||
@ -382,7 +382,7 @@ void CommandLineParser::printMessage() const
|
|||||||
std::cout << ", ";
|
std::cout << ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string dv = impl->cat_string(impl->data[i].def_value);
|
std::string dv = impl->cat_string(impl->data[i].def_value);
|
||||||
if (dv.compare("") != 0)
|
if (dv.compare("") != 0)
|
||||||
{
|
{
|
||||||
std::cout << " (value:" << dv << ")";
|
std::cout << " (value:" << dv << ")";
|
||||||
@ -397,12 +397,12 @@ void CommandLineParser::printMessage() const
|
|||||||
if (impl->data[i].number != -1)
|
if (impl->data[i].number != -1)
|
||||||
{
|
{
|
||||||
std::cout << "\t";
|
std::cout << "\t";
|
||||||
string k = impl->data[i].keys[0];
|
std::string k = impl->data[i].keys[0];
|
||||||
k = k.substr(1, k.length() - 1);
|
k = k.substr(1, k.length() - 1);
|
||||||
|
|
||||||
std::cout << k;
|
std::cout << k;
|
||||||
|
|
||||||
string dv = impl->cat_string(impl->data[i].def_value);
|
std::string dv = impl->cat_string(impl->data[i].def_value);
|
||||||
if (dv.compare("") != 0)
|
if (dv.compare("") != 0)
|
||||||
{
|
{
|
||||||
std::cout << " (value:" << dv << ")";
|
std::cout << " (value:" << dv << ")";
|
||||||
@ -412,11 +412,11 @@ void CommandLineParser::printMessage() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> CommandLineParser::Impl::split_range_string(const string& _str, char fs, char ss) const
|
std::vector<std::string> CommandLineParser::Impl::split_range_string(const std::string& _str, char fs, char ss) const
|
||||||
{
|
{
|
||||||
string str = _str;
|
std::string str = _str;
|
||||||
vector<string> vec;
|
std::vector<std::string> vec;
|
||||||
string word = "";
|
std::string word = "";
|
||||||
bool begin = false;
|
bool begin = false;
|
||||||
|
|
||||||
while (!str.empty())
|
while (!str.empty())
|
||||||
@ -426,13 +426,13 @@ vector<string> CommandLineParser::Impl::split_range_string(const string& _str, c
|
|||||||
if (begin == true)
|
if (begin == true)
|
||||||
{
|
{
|
||||||
throw cv::Exception(CV_StsParseError,
|
throw cv::Exception(CV_StsParseError,
|
||||||
string("error in split_range_string(")
|
std::string("error in split_range_string(")
|
||||||
+ str
|
+ str
|
||||||
+ string(", ")
|
+ std::string(", ")
|
||||||
+ string(1, fs)
|
+ std::string(1, fs)
|
||||||
+ string(", ")
|
+ std::string(", ")
|
||||||
+ string(1, ss)
|
+ std::string(1, ss)
|
||||||
+ string(")"),
|
+ std::string(")"),
|
||||||
"", __FILE__, __LINE__
|
"", __FILE__, __LINE__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -446,13 +446,13 @@ vector<string> CommandLineParser::Impl::split_range_string(const string& _str, c
|
|||||||
if (begin == false)
|
if (begin == false)
|
||||||
{
|
{
|
||||||
throw cv::Exception(CV_StsParseError,
|
throw cv::Exception(CV_StsParseError,
|
||||||
string("error in split_range_string(")
|
std::string("error in split_range_string(")
|
||||||
+ str
|
+ str
|
||||||
+ string(", ")
|
+ std::string(", ")
|
||||||
+ string(1, fs)
|
+ std::string(1, fs)
|
||||||
+ string(", ")
|
+ std::string(", ")
|
||||||
+ string(1, ss)
|
+ std::string(1, ss)
|
||||||
+ string(")"),
|
+ std::string(")"),
|
||||||
"", __FILE__, __LINE__
|
"", __FILE__, __LINE__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -470,13 +470,13 @@ vector<string> CommandLineParser::Impl::split_range_string(const string& _str, c
|
|||||||
if (begin == true)
|
if (begin == true)
|
||||||
{
|
{
|
||||||
throw cv::Exception(CV_StsParseError,
|
throw cv::Exception(CV_StsParseError,
|
||||||
string("error in split_range_string(")
|
std::string("error in split_range_string(")
|
||||||
+ str
|
+ str
|
||||||
+ string(", ")
|
+ std::string(", ")
|
||||||
+ string(1, fs)
|
+ std::string(1, fs)
|
||||||
+ string(", ")
|
+ std::string(", ")
|
||||||
+ string(1, ss)
|
+ std::string(1, ss)
|
||||||
+ string(")"),
|
+ std::string(")"),
|
||||||
"", __FILE__, __LINE__
|
"", __FILE__, __LINE__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -484,11 +484,11 @@ vector<string> CommandLineParser::Impl::split_range_string(const string& _str, c
|
|||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> CommandLineParser::Impl::split_string(const string& _str, char symbol, bool create_empty_item) const
|
std::vector<std::string> CommandLineParser::Impl::split_string(const std::string& _str, char symbol, bool create_empty_item) const
|
||||||
{
|
{
|
||||||
string str = _str;
|
std::string str = _str;
|
||||||
vector<string> vec;
|
std::vector<std::string> vec;
|
||||||
string word = "";
|
std::string word = "";
|
||||||
|
|
||||||
while (!str.empty())
|
while (!str.empty())
|
||||||
{
|
{
|
||||||
|
@ -344,7 +344,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
|
|||||||
|
|
||||||
void cv::merge(InputArrayOfArrays _mv, OutputArray _dst)
|
void cv::merge(InputArrayOfArrays _mv, OutputArray _dst)
|
||||||
{
|
{
|
||||||
vector<Mat> mv;
|
std::vector<Mat> mv;
|
||||||
_mv.getMatVector(mv);
|
_mv.getMatVector(mv);
|
||||||
merge(!mv.empty() ? &mv[0] : 0, mv.size(), _dst);
|
merge(!mv.empty() ? &mv[0] : 0, mv.size(), _dst);
|
||||||
}
|
}
|
||||||
@ -505,7 +505,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cv::mixChannels(const vector<Mat>& src, vector<Mat>& dst,
|
void cv::mixChannels(const std::vector<Mat>& src, std::vector<Mat>& dst,
|
||||||
const int* fromTo, size_t npairs)
|
const int* fromTo, size_t npairs)
|
||||||
{
|
{
|
||||||
mixChannels(!src.empty() ? &src[0] : 0, src.size(),
|
mixChannels(!src.empty() ? &src[0] : 0, src.size(),
|
||||||
@ -513,7 +513,7 @@ void cv::mixChannels(const vector<Mat>& src, vector<Mat>& dst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
|
void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
|
||||||
const vector<int>& fromTo)
|
const std::vector<int>& fromTo)
|
||||||
{
|
{
|
||||||
if(fromTo.empty())
|
if(fromTo.empty())
|
||||||
return;
|
return;
|
||||||
@ -1247,8 +1247,8 @@ cvSplit( const void* srcarr, void* dstarr0, void* dstarr1, void* dstarr2, void*
|
|||||||
for( i = 0; i < 4; i++ )
|
for( i = 0; i < 4; i++ )
|
||||||
nz += dptrs[i] != 0;
|
nz += dptrs[i] != 0;
|
||||||
CV_Assert( nz > 0 );
|
CV_Assert( nz > 0 );
|
||||||
cv::vector<cv::Mat> dvec(nz);
|
std::vector<cv::Mat> dvec(nz);
|
||||||
cv::vector<int> pairs(nz*2);
|
std::vector<int> pairs(nz*2);
|
||||||
|
|
||||||
for( i = j = 0; i < 4; i++ )
|
for( i = j = 0; i < 4; i++ )
|
||||||
{
|
{
|
||||||
@ -1283,8 +1283,8 @@ cvMerge( const void* srcarr0, const void* srcarr1, const void* srcarr2,
|
|||||||
for( i = 0; i < 4; i++ )
|
for( i = 0; i < 4; i++ )
|
||||||
nz += sptrs[i] != 0;
|
nz += sptrs[i] != 0;
|
||||||
CV_Assert( nz > 0 );
|
CV_Assert( nz > 0 );
|
||||||
cv::vector<cv::Mat> svec(nz);
|
std::vector<cv::Mat> svec(nz);
|
||||||
cv::vector<int> pairs(nz*2);
|
std::vector<int> pairs(nz*2);
|
||||||
|
|
||||||
for( i = j = 0; i < 4; i++ )
|
for( i = j = 0; i < 4; i++ )
|
||||||
{
|
{
|
||||||
|
@ -3643,7 +3643,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
|
|||||||
{
|
{
|
||||||
Mat _points = __points.getMat(), _labels = __labels.getMat();
|
Mat _points = __points.getMat(), _labels = __labels.getMat();
|
||||||
CV_Assert(_points.type() == CV_32F && !_points.empty());
|
CV_Assert(_points.type() == CV_32F && !_points.empty());
|
||||||
vector<KDTree::Node>().swap(nodes);
|
std::vector<KDTree::Node>().swap(nodes);
|
||||||
|
|
||||||
if( !_copyData )
|
if( !_copyData )
|
||||||
points = _points;
|
points = _points;
|
||||||
@ -3672,7 +3672,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
|
|||||||
Mat sumstack(MAX_TREE_DEPTH*2, ptdims*2, CV_64F);
|
Mat sumstack(MAX_TREE_DEPTH*2, ptdims*2, CV_64F);
|
||||||
SubTree stack[MAX_TREE_DEPTH*2];
|
SubTree stack[MAX_TREE_DEPTH*2];
|
||||||
|
|
||||||
vector<size_t> _ptofs(n);
|
std::vector<size_t> _ptofs(n);
|
||||||
size_t* ptofs = &_ptofs[0];
|
size_t* ptofs = &_ptofs[0];
|
||||||
|
|
||||||
for( i = 0; i < n; i++ )
|
for( i = 0; i < n; i++ )
|
||||||
@ -3909,7 +3909,7 @@ void KDTree::findOrthoRange(InputArray _lowerBound,
|
|||||||
const float* L = lowerBound.ptr<float>();
|
const float* L = lowerBound.ptr<float>();
|
||||||
const float* R = upperBound.ptr<float>();
|
const float* R = upperBound.ptr<float>();
|
||||||
|
|
||||||
vector<int> idx;
|
std::vector<int> idx;
|
||||||
AutoBuffer<int> _stack(MAX_TREE_DEPTH*2 + 1);
|
AutoBuffer<int> _stack(MAX_TREE_DEPTH*2 + 1);
|
||||||
int* stack = _stack;
|
int* stack = _stack;
|
||||||
int top = 0;
|
int top = 0;
|
||||||
|
@ -57,11 +57,11 @@ struct PolyEdge
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
CollectPolyEdges( Mat& img, const Point* v, int npts,
|
CollectPolyEdges( Mat& img, const Point* v, int npts,
|
||||||
vector<PolyEdge>& edges, const void* color, int line_type,
|
std::vector<PolyEdge>& edges, const void* color, int line_type,
|
||||||
int shift, Point offset=Point() );
|
int shift, Point offset=Point() );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FillEdgeCollection( Mat& img, vector<PolyEdge>& edges, const void* color );
|
FillEdgeCollection( Mat& img, std::vector<PolyEdge>& edges, const void* color );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
PolyLine( Mat& img, const Point* v, int npts, bool closed,
|
PolyLine( Mat& img, const Point* v, int npts, bool closed,
|
||||||
@ -835,7 +835,7 @@ sincos( int angle, float& cosval, float& sinval )
|
|||||||
*/
|
*/
|
||||||
void ellipse2Poly( Point center, Size axes, int angle,
|
void ellipse2Poly( Point center, Size axes, int angle,
|
||||||
int arc_start, int arc_end,
|
int arc_start, int arc_end,
|
||||||
int delta, vector<Point>& pts )
|
int delta, std::vector<Point>& pts )
|
||||||
{
|
{
|
||||||
float alpha, beta;
|
float alpha, beta;
|
||||||
double size_a = axes.width, size_b = axes.height;
|
double size_a = axes.width, size_b = axes.height;
|
||||||
@ -904,7 +904,7 @@ EllipseEx( Mat& img, Point center, Size axes,
|
|||||||
int delta = (std::max(axes.width,axes.height)+(XY_ONE>>1))>>XY_SHIFT;
|
int delta = (std::max(axes.width,axes.height)+(XY_ONE>>1))>>XY_SHIFT;
|
||||||
delta = delta < 3 ? 90 : delta < 10 ? 30 : delta < 15 ? 18 : 5;
|
delta = delta < 3 ? 90 : delta < 10 ? 30 : delta < 15 ? 18 : 5;
|
||||||
|
|
||||||
vector<Point> v;
|
std::vector<Point> v;
|
||||||
ellipse2Poly( center, axes, angle, arc_start, arc_end, delta, v );
|
ellipse2Poly( center, axes, angle, arc_start, arc_end, delta, v );
|
||||||
|
|
||||||
if( thickness >= 0 )
|
if( thickness >= 0 )
|
||||||
@ -914,7 +914,7 @@ EllipseEx( Mat& img, Point center, Size axes,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
v.push_back(center);
|
v.push_back(center);
|
||||||
vector<PolyEdge> edges;
|
std::vector<PolyEdge> edges;
|
||||||
CollectPolyEdges( img, &v[0], (int)v.size(), edges, color, line_type, XY_SHIFT );
|
CollectPolyEdges( img, &v[0], (int)v.size(), edges, color, line_type, XY_SHIFT );
|
||||||
FillEdgeCollection( img, edges, color );
|
FillEdgeCollection( img, edges, color );
|
||||||
}
|
}
|
||||||
@ -1104,7 +1104,7 @@ FillConvexPoly( Mat& img, const Point* v, int npts, const void* color, int line_
|
|||||||
/******** Arbitrary polygon **********/
|
/******** Arbitrary polygon **********/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CollectPolyEdges( Mat& img, const Point* v, int count, vector<PolyEdge>& edges,
|
CollectPolyEdges( Mat& img, const Point* v, int count, std::vector<PolyEdge>& edges,
|
||||||
const void* color, int line_type, int shift, Point offset )
|
const void* color, int line_type, int shift, Point offset )
|
||||||
{
|
{
|
||||||
int i, delta = offset.y + (shift ? 1 << (shift - 1) : 0);
|
int i, delta = offset.y + (shift ? 1 << (shift - 1) : 0);
|
||||||
@ -1170,7 +1170,7 @@ struct CmpEdges
|
|||||||
/**************** helper macros and functions for sequence/contour processing ***********/
|
/**************** helper macros and functions for sequence/contour processing ***********/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FillEdgeCollection( Mat& img, vector<PolyEdge>& edges, const void* color )
|
FillEdgeCollection( Mat& img, std::vector<PolyEdge>& edges, const void* color )
|
||||||
{
|
{
|
||||||
PolyEdge tmp;
|
PolyEdge tmp;
|
||||||
int i, y, total = (int)edges.size();
|
int i, y, total = (int)edges.size();
|
||||||
@ -1716,7 +1716,7 @@ void fillPoly( Mat& img, const Point** pts, const int* npts, int ncontours,
|
|||||||
double buf[4];
|
double buf[4];
|
||||||
scalarToRawData(color, buf, img.type(), 0);
|
scalarToRawData(color, buf, img.type(), 0);
|
||||||
|
|
||||||
vector<PolyEdge> edges;
|
std::vector<PolyEdge> edges;
|
||||||
|
|
||||||
int i, total = 0;
|
int i, total = 0;
|
||||||
for( i = 0; i < ncontours; i++ )
|
for( i = 0; i < ncontours; i++ )
|
||||||
@ -1914,7 +1914,7 @@ static const int* getFontData(int fontFace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void putText( Mat& img, const string& text, Point org,
|
void putText( Mat& img, const std::string& text, Point org,
|
||||||
int fontFace, double fontScale, Scalar color,
|
int fontFace, double fontScale, Scalar color,
|
||||||
int thickness, int line_type, bool bottomLeftOrigin )
|
int thickness, int line_type, bool bottomLeftOrigin )
|
||||||
|
|
||||||
@ -1935,7 +1935,7 @@ void putText( Mat& img, const string& text, Point org,
|
|||||||
|
|
||||||
int view_x = org.x << XY_SHIFT;
|
int view_x = org.x << XY_SHIFT;
|
||||||
int view_y = (org.y << XY_SHIFT) + base_line*vscale;
|
int view_y = (org.y << XY_SHIFT) + base_line*vscale;
|
||||||
vector<Point> pts;
|
std::vector<Point> pts;
|
||||||
pts.reserve(1 << 10);
|
pts.reserve(1 << 10);
|
||||||
const char **faces = cv::g_HersheyGlyphs;
|
const char **faces = cv::g_HersheyGlyphs;
|
||||||
|
|
||||||
@ -1976,7 +1976,7 @@ void putText( Mat& img, const string& text, Point org,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Size getTextSize( const string& text, int fontFace, double fontScale, int thickness, int* _base_line)
|
Size getTextSize( const std::string& text, int fontFace, double fontScale, int thickness, int* _base_line)
|
||||||
{
|
{
|
||||||
Size size;
|
Size size;
|
||||||
double view_x = 0;
|
double view_x = 0;
|
||||||
@ -2076,8 +2076,8 @@ using namespace cv;
|
|||||||
static void addChildContour(InputArrayOfArrays contours,
|
static void addChildContour(InputArrayOfArrays contours,
|
||||||
size_t ncontours,
|
size_t ncontours,
|
||||||
const Vec4i* hierarchy,
|
const Vec4i* hierarchy,
|
||||||
int i, vector<CvSeq>& seq,
|
int i, std::vector<CvSeq>& seq,
|
||||||
vector<CvSeqBlock>& block)
|
std::vector<CvSeqBlock>& block)
|
||||||
{
|
{
|
||||||
for( ; i >= 0; i = hierarchy[i][0] )
|
for( ; i >= 0; i = hierarchy[i][0] )
|
||||||
{
|
{
|
||||||
@ -2109,8 +2109,8 @@ void cv::drawContours( InputOutputArray _image, InputArrayOfArrays _contours,
|
|||||||
|
|
||||||
size_t ncontours = _contours.total();
|
size_t ncontours = _contours.total();
|
||||||
size_t i = 0, first = 0, last = ncontours;
|
size_t i = 0, first = 0, last = ncontours;
|
||||||
vector<CvSeq> seq;
|
std::vector<CvSeq> seq;
|
||||||
vector<CvSeqBlock> block;
|
std::vector<CvSeqBlock> block;
|
||||||
|
|
||||||
if( !last )
|
if( !last )
|
||||||
return;
|
return;
|
||||||
@ -2194,8 +2194,8 @@ cvDrawContours( void* _img, CvSeq* contour,
|
|||||||
{
|
{
|
||||||
CvSeq *contour0 = contour, *h_next = 0;
|
CvSeq *contour0 = contour, *h_next = 0;
|
||||||
CvTreeNodeIterator iterator;
|
CvTreeNodeIterator iterator;
|
||||||
cv::vector<cv::PolyEdge> edges;
|
std::vector<cv::PolyEdge> edges;
|
||||||
cv::vector<cv::Point> pts;
|
std::vector<cv::Point> pts;
|
||||||
cv::Scalar externalColor = _externalColor, holeColor = _holeColor;
|
cv::Scalar externalColor = _externalColor, holeColor = _holeColor;
|
||||||
cv::Mat img = cv::cvarrToMat(_img);
|
cv::Mat img = cv::cvarrToMat(_img);
|
||||||
cv::Point offset = _offset;
|
cv::Point offset = _offset;
|
||||||
@ -2318,7 +2318,7 @@ CV_IMPL int
|
|||||||
cvEllipse2Poly( CvPoint center, CvSize axes, int angle,
|
cvEllipse2Poly( CvPoint center, CvSize axes, int angle,
|
||||||
int arc_start, int arc_end, CvPoint* _pts, int delta )
|
int arc_start, int arc_end, CvPoint* _pts, int delta )
|
||||||
{
|
{
|
||||||
cv::vector<cv::Point> pts;
|
std::vector<cv::Point> pts;
|
||||||
cv::ellipse2Poly( center, axes, angle, arc_start, arc_end, delta, pts );
|
cv::ellipse2Poly( center, axes, angle, arc_start, arc_end, delta, pts );
|
||||||
memcpy( _pts, &pts[0], pts.size()*sizeof(_pts[0]) );
|
memcpy( _pts, &pts[0], pts.size()*sizeof(_pts[0]) );
|
||||||
return (int)pts.size();
|
return (int)pts.size();
|
||||||
|
@ -60,10 +60,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace cv;
|
|
||||||
using namespace cv::gpu;
|
|
||||||
|
|
||||||
//////////////////////////////// Initialization & Info ////////////////////////
|
//////////////////////////////// Initialization & Info ////////////////////////
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -73,7 +69,7 @@ namespace
|
|||||||
public:
|
public:
|
||||||
CudaArch();
|
CudaArch();
|
||||||
|
|
||||||
bool builtWith(FeatureSet feature_set) const;
|
bool builtWith(cv::gpu::FeatureSet feature_set) const;
|
||||||
bool hasPtx(int major, int minor) const;
|
bool hasPtx(int major, int minor) const;
|
||||||
bool hasBin(int major, int minor) const;
|
bool hasBin(int major, int minor) const;
|
||||||
bool hasEqualOrLessPtx(int major, int minor) const;
|
bool hasEqualOrLessPtx(int major, int minor) const;
|
||||||
@ -81,11 +77,11 @@ namespace
|
|||||||
bool hasEqualOrGreaterBin(int major, int minor) const;
|
bool hasEqualOrGreaterBin(int major, int minor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void fromStr(const string& set_as_str, vector<int>& arr);
|
static void fromStr(const std::string& set_as_str, std::vector<int>& arr);
|
||||||
|
|
||||||
vector<int> bin;
|
std::vector<int> bin;
|
||||||
vector<int> ptx;
|
std::vector<int> ptx;
|
||||||
vector<int> features;
|
std::vector<int> features;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CudaArch cudaArch;
|
const CudaArch cudaArch;
|
||||||
@ -99,19 +95,19 @@ namespace
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CudaArch::builtWith(FeatureSet feature_set) const
|
bool CudaArch::builtWith(cv::gpu::FeatureSet feature_set) const
|
||||||
{
|
{
|
||||||
return !features.empty() && (features.back() >= feature_set);
|
return !features.empty() && (features.back() >= feature_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CudaArch::hasPtx(int major, int minor) const
|
bool CudaArch::hasPtx(int major, int minor) const
|
||||||
{
|
{
|
||||||
return find(ptx.begin(), ptx.end(), major * 10 + minor) != ptx.end();
|
return std::find(ptx.begin(), ptx.end(), major * 10 + minor) != ptx.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CudaArch::hasBin(int major, int minor) const
|
bool CudaArch::hasBin(int major, int minor) const
|
||||||
{
|
{
|
||||||
return find(bin.begin(), bin.end(), major * 10 + minor) != bin.end();
|
return std::find(bin.begin(), bin.end(), major * 10 + minor) != bin.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CudaArch::hasEqualOrLessPtx(int major, int minor) const
|
bool CudaArch::hasEqualOrLessPtx(int major, int minor) const
|
||||||
@ -129,12 +125,12 @@ namespace
|
|||||||
return !bin.empty() && (bin.back() >= major * 10 + minor);
|
return !bin.empty() && (bin.back() >= major * 10 + minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CudaArch::fromStr(const string& set_as_str, vector<int>& arr)
|
void CudaArch::fromStr(const std::string& set_as_str, std::vector<int>& arr)
|
||||||
{
|
{
|
||||||
if (set_as_str.find_first_not_of(" ") == string::npos)
|
if (set_as_str.find_first_not_of(" ") == std::string::npos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
istringstream stream(set_as_str);
|
std::istringstream stream(set_as_str);
|
||||||
int cur_value;
|
int cur_value;
|
||||||
|
|
||||||
while (!stream.eof())
|
while (!stream.eof())
|
||||||
@ -143,7 +139,7 @@ namespace
|
|||||||
arr.push_back(cur_value);
|
arr.push_back(cur_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(arr.begin(), arr.end());
|
std::sort(arr.begin(), arr.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +642,7 @@ cv::gpu::GpuMat::GpuMat(const Mat& m) :
|
|||||||
upload(m);
|
upload(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuMat& cv::gpu::GpuMat::operator = (const GpuMat& m)
|
cv::gpu::GpuMat& cv::gpu::GpuMat::operator = (const cv::gpu::GpuMat& m)
|
||||||
{
|
{
|
||||||
if (this != &m)
|
if (this != &m)
|
||||||
{
|
{
|
||||||
@ -693,7 +689,7 @@ void cv::gpu::GpuMat::locateROI(Size& wholeSize, Point& ofs) const
|
|||||||
wholeSize.width = std::max(static_cast<int>((delta2 - step * (wholeSize.height - 1)) / esz), ofs.x + cols);
|
wholeSize.width = std::max(static_cast<int>((delta2 - step * (wholeSize.height - 1)) / esz), ofs.x + cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuMat& cv::gpu::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright)
|
cv::gpu::GpuMat& cv::gpu::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright)
|
||||||
{
|
{
|
||||||
Size wholeSize;
|
Size wholeSize;
|
||||||
Point ofs;
|
Point ofs;
|
||||||
@ -719,7 +715,7 @@ GpuMat& cv::gpu::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuMat cv::gpu::GpuMat::reshape(int new_cn, int new_rows) const
|
cv::gpu::GpuMat cv::gpu::GpuMat::reshape(int new_cn, int new_rows) const
|
||||||
{
|
{
|
||||||
GpuMat hdr = *this;
|
GpuMat hdr = *this;
|
||||||
|
|
||||||
@ -762,7 +758,7 @@ GpuMat cv::gpu::GpuMat::reshape(int new_cn, int new_rows) const
|
|||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Mat::Mat(const GpuMat& m) : flags(0), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
cv::Mat::Mat(const cv::gpu::GpuMat& m) : flags(0), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
||||||
{
|
{
|
||||||
m.download(*this);
|
m.download(*this);
|
||||||
}
|
}
|
||||||
@ -804,7 +800,7 @@ void cv::gpu::ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuMat cv::gpu::allocMatFromBuf(int rows, int cols, int type, GpuMat &mat)
|
cv::gpu::GpuMat cv::gpu::allocMatFromBuf(int rows, int cols, int type, GpuMat &mat)
|
||||||
{
|
{
|
||||||
if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols)
|
if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols)
|
||||||
return mat(Rect(0, 0, cols, rows));
|
return mat(Rect(0, 0, cols, rows));
|
||||||
@ -818,16 +814,16 @@ namespace
|
|||||||
public:
|
public:
|
||||||
virtual ~GpuFuncTable() {}
|
virtual ~GpuFuncTable() {}
|
||||||
|
|
||||||
virtual void copy(const Mat& src, GpuMat& dst) const = 0;
|
virtual void copy(const cv::Mat& src, cv::gpu::GpuMat& dst) const = 0;
|
||||||
virtual void copy(const GpuMat& src, Mat& dst) const = 0;
|
virtual void copy(const cv::gpu::GpuMat& src, cv::Mat& dst) const = 0;
|
||||||
virtual void copy(const GpuMat& src, GpuMat& dst) const = 0;
|
virtual void copy(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const = 0;
|
||||||
|
|
||||||
virtual void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask) const = 0;
|
virtual void copyWithMask(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask) const = 0;
|
||||||
|
|
||||||
virtual void convert(const GpuMat& src, GpuMat& dst) const = 0;
|
virtual void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const = 0;
|
||||||
virtual void convert(const GpuMat& src, GpuMat& dst, double alpha, double beta) const = 0;
|
virtual void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, double alpha, double beta) const = 0;
|
||||||
|
|
||||||
virtual void setTo(GpuMat& m, Scalar s, const GpuMat& mask) const = 0;
|
virtual void setTo(cv::gpu::GpuMat& m, cv::Scalar s, const cv::gpu::GpuMat& mask) const = 0;
|
||||||
|
|
||||||
virtual void mallocPitch(void** devPtr, size_t* step, size_t width, size_t height) const = 0;
|
virtual void mallocPitch(void** devPtr, size_t* step, size_t width, size_t height) const = 0;
|
||||||
virtual void free(void* devPtr) const = 0;
|
virtual void free(void* devPtr) const = 0;
|
||||||
@ -841,16 +837,16 @@ namespace
|
|||||||
class EmptyFuncTable : public GpuFuncTable
|
class EmptyFuncTable : public GpuFuncTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void copy(const Mat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void copy(const cv::Mat&, cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
void copy(const GpuMat&, Mat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void copy(const cv::gpu::GpuMat&, cv::Mat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
void copy(const GpuMat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void copy(const cv::gpu::GpuMat&, cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
|
|
||||||
void copyWithMask(const GpuMat&, GpuMat&, const GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void copyWithMask(const cv::gpu::GpuMat&, cv::gpu::GpuMat&, const cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
|
|
||||||
void convert(const GpuMat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void convert(const cv::gpu::GpuMat&, cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
void convert(const GpuMat&, GpuMat&, double, double) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void convert(const cv::gpu::GpuMat&, cv::gpu::GpuMat&, double, double) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
|
|
||||||
void setTo(GpuMat&, Scalar, const GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void setTo(cv::gpu::GpuMat&, cv::Scalar, const cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
|
|
||||||
void mallocPitch(void**, size_t*, size_t, size_t) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
void mallocPitch(void**, size_t*, size_t, size_t) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||||
void free(void*) const {}
|
void free(void*) const {}
|
||||||
@ -880,15 +876,15 @@ namespace cv { namespace gpu { namespace device
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
template <typename T> void kernelSetCaller(GpuMat& src, Scalar s, cudaStream_t stream)
|
template <typename T> void kernelSetCaller(cv::gpu::GpuMat& src, cv::Scalar s, cudaStream_t stream)
|
||||||
{
|
{
|
||||||
Scalar_<T> sf = s;
|
cv::Scalar_<T> sf = s;
|
||||||
cv::gpu::device::set_to_gpu(src, sf.val, src.channels(), stream);
|
cv::gpu::device::set_to_gpu(src, sf.val, src.channels(), stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void kernelSetCaller(GpuMat& src, Scalar s, const GpuMat& mask, cudaStream_t stream)
|
template <typename T> void kernelSetCaller(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask, cudaStream_t stream)
|
||||||
{
|
{
|
||||||
Scalar_<T> sf = s;
|
cv::Scalar_<T> sf = s;
|
||||||
cv::gpu::device::set_to_gpu(src, sf.val, mask, src.channels(), stream);
|
cv::gpu::device::set_to_gpu(src, sf.val, mask, src.channels(), stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -996,7 +992,7 @@ namespace
|
|||||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||||
typedef typename NPPTypeTraits<DDEPTH>::npp_type dst_t;
|
typedef typename NPPTypeTraits<DDEPTH>::npp_type dst_t;
|
||||||
|
|
||||||
static void call(const GpuMat& src, GpuMat& dst)
|
static void call(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst)
|
||||||
{
|
{
|
||||||
NppiSize sz;
|
NppiSize sz;
|
||||||
sz.width = src.cols;
|
sz.width = src.cols;
|
||||||
@ -1011,7 +1007,7 @@ namespace
|
|||||||
{
|
{
|
||||||
typedef typename NPPTypeTraits<DDEPTH>::npp_type dst_t;
|
typedef typename NPPTypeTraits<DDEPTH>::npp_type dst_t;
|
||||||
|
|
||||||
static void call(const GpuMat& src, GpuMat& dst)
|
static void call(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst)
|
||||||
{
|
{
|
||||||
NppiSize sz;
|
NppiSize sz;
|
||||||
sz.width = src.cols;
|
sz.width = src.cols;
|
||||||
@ -1051,13 +1047,13 @@ namespace
|
|||||||
{
|
{
|
||||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||||
|
|
||||||
static void call(GpuMat& src, Scalar s)
|
static void call(cv::gpu::GpuMat& src, cv::Scalar s)
|
||||||
{
|
{
|
||||||
NppiSize sz;
|
NppiSize sz;
|
||||||
sz.width = src.cols;
|
sz.width = src.cols;
|
||||||
sz.height = src.rows;
|
sz.height = src.rows;
|
||||||
|
|
||||||
Scalar_<src_t> nppS = s;
|
cv::Scalar_<src_t> nppS = s;
|
||||||
|
|
||||||
nppSafeCall( func(nppS.val, src.ptr<src_t>(), static_cast<int>(src.step), sz) );
|
nppSafeCall( func(nppS.val, src.ptr<src_t>(), static_cast<int>(src.step), sz) );
|
||||||
|
|
||||||
@ -1068,13 +1064,13 @@ namespace
|
|||||||
{
|
{
|
||||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||||
|
|
||||||
static void call(GpuMat& src, Scalar s)
|
static void call(cv::gpu::GpuMat& src, cv::Scalar s)
|
||||||
{
|
{
|
||||||
NppiSize sz;
|
NppiSize sz;
|
||||||
sz.width = src.cols;
|
sz.width = src.cols;
|
||||||
sz.height = src.rows;
|
sz.height = src.rows;
|
||||||
|
|
||||||
Scalar_<src_t> nppS = s;
|
cv::Scalar_<src_t> nppS = s;
|
||||||
|
|
||||||
nppSafeCall( func(nppS[0], src.ptr<src_t>(), static_cast<int>(src.step), sz) );
|
nppSafeCall( func(nppS[0], src.ptr<src_t>(), static_cast<int>(src.step), sz) );
|
||||||
|
|
||||||
@ -1099,13 +1095,13 @@ namespace
|
|||||||
{
|
{
|
||||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||||
|
|
||||||
static void call(GpuMat& src, Scalar s, const GpuMat& mask)
|
static void call(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask)
|
||||||
{
|
{
|
||||||
NppiSize sz;
|
NppiSize sz;
|
||||||
sz.width = src.cols;
|
sz.width = src.cols;
|
||||||
sz.height = src.rows;
|
sz.height = src.rows;
|
||||||
|
|
||||||
Scalar_<src_t> nppS = s;
|
cv::Scalar_<src_t> nppS = s;
|
||||||
|
|
||||||
nppSafeCall( func(nppS.val, src.ptr<src_t>(), static_cast<int>(src.step), sz, mask.ptr<Npp8u>(), static_cast<int>(mask.step)) );
|
nppSafeCall( func(nppS.val, src.ptr<src_t>(), static_cast<int>(src.step), sz, mask.ptr<Npp8u>(), static_cast<int>(mask.step)) );
|
||||||
|
|
||||||
@ -1116,13 +1112,13 @@ namespace
|
|||||||
{
|
{
|
||||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||||
|
|
||||||
static void call(GpuMat& src, Scalar s, const GpuMat& mask)
|
static void call(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask)
|
||||||
{
|
{
|
||||||
NppiSize sz;
|
NppiSize sz;
|
||||||
sz.width = src.cols;
|
sz.width = src.cols;
|
||||||
sz.height = src.rows;
|
sz.height = src.rows;
|
||||||
|
|
||||||
Scalar_<src_t> nppS = s;
|
cv::Scalar_<src_t> nppS = s;
|
||||||
|
|
||||||
nppSafeCall( func(nppS[0], src.ptr<src_t>(), static_cast<int>(src.step), sz, mask.ptr<Npp8u>(), static_cast<int>(mask.step)) );
|
nppSafeCall( func(nppS[0], src.ptr<src_t>(), static_cast<int>(src.step), sz, mask.ptr<Npp8u>(), static_cast<int>(mask.step)) );
|
||||||
|
|
||||||
@ -1144,7 +1140,7 @@ namespace
|
|||||||
{
|
{
|
||||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||||
|
|
||||||
static void call(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t /*stream*/)
|
static void call(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask, cudaStream_t /*stream*/)
|
||||||
{
|
{
|
||||||
NppiSize sz;
|
NppiSize sz;
|
||||||
sz.width = src.cols;
|
sz.width = src.cols;
|
||||||
@ -1167,20 +1163,20 @@ namespace
|
|||||||
class CudaFuncTable : public GpuFuncTable
|
class CudaFuncTable : public GpuFuncTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void copy(const Mat& src, GpuMat& dst) const
|
void copy(const cv::Mat& src, cv::gpu::GpuMat& dst) const
|
||||||
{
|
{
|
||||||
cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyHostToDevice) );
|
cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyHostToDevice) );
|
||||||
}
|
}
|
||||||
void copy(const GpuMat& src, Mat& dst) const
|
void copy(const cv::gpu::GpuMat& src, cv::Mat& dst) const
|
||||||
{
|
{
|
||||||
cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToHost) );
|
cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToHost) );
|
||||||
}
|
}
|
||||||
void copy(const GpuMat& src, GpuMat& dst) const
|
void copy(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const
|
||||||
{
|
{
|
||||||
cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToDevice) );
|
cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToDevice) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask) const
|
void copyWithMask(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask) const
|
||||||
{
|
{
|
||||||
CV_Assert(src.depth() <= CV_64F && src.channels() <= 4);
|
CV_Assert(src.depth() <= CV_64F && src.channels() <= 4);
|
||||||
CV_Assert(src.size() == dst.size() && src.type() == dst.type());
|
CV_Assert(src.size() == dst.size() && src.type() == dst.type());
|
||||||
@ -1188,11 +1184,11 @@ namespace
|
|||||||
|
|
||||||
if (src.depth() == CV_64F)
|
if (src.depth() == CV_64F)
|
||||||
{
|
{
|
||||||
if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE))
|
if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE))
|
||||||
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*func_t)(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t stream);
|
typedef void (*func_t)(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask, cudaStream_t stream);
|
||||||
static const func_t funcs[7][4] =
|
static const func_t funcs[7][4] =
|
||||||
{
|
{
|
||||||
/* 8U */ {NppCopyMasked<CV_8U , nppiCopy_8u_C1MR >::call, cv::gpu::copyWithMask, NppCopyMasked<CV_8U , nppiCopy_8u_C3MR >::call, NppCopyMasked<CV_8U , nppiCopy_8u_C4MR >::call},
|
/* 8U */ {NppCopyMasked<CV_8U , nppiCopy_8u_C1MR >::call, cv::gpu::copyWithMask, NppCopyMasked<CV_8U , nppiCopy_8u_C3MR >::call, NppCopyMasked<CV_8U , nppiCopy_8u_C4MR >::call},
|
||||||
@ -1209,9 +1205,9 @@ namespace
|
|||||||
func(src, dst, mask, 0);
|
func(src, dst, mask, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(const GpuMat& src, GpuMat& dst) const
|
void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const
|
||||||
{
|
{
|
||||||
typedef void (*func_t)(const GpuMat& src, GpuMat& dst);
|
typedef void (*func_t)(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst);
|
||||||
static const func_t funcs[7][7][4] =
|
static const func_t funcs[7][7][4] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -1285,7 +1281,7 @@ namespace
|
|||||||
|
|
||||||
if (src.depth() == CV_64F || dst.depth() == CV_64F)
|
if (src.depth() == CV_64F || dst.depth() == CV_64F)
|
||||||
{
|
{
|
||||||
if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE))
|
if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE))
|
||||||
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,21 +1298,21 @@ namespace
|
|||||||
func(src, dst);
|
func(src, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(const GpuMat& src, GpuMat& dst, double alpha, double beta) const
|
void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, double alpha, double beta) const
|
||||||
{
|
{
|
||||||
CV_Assert(src.depth() <= CV_64F && src.channels() <= 4);
|
CV_Assert(src.depth() <= CV_64F && src.channels() <= 4);
|
||||||
CV_Assert(dst.depth() <= CV_64F);
|
CV_Assert(dst.depth() <= CV_64F);
|
||||||
|
|
||||||
if (src.depth() == CV_64F || dst.depth() == CV_64F)
|
if (src.depth() == CV_64F || dst.depth() == CV_64F)
|
||||||
{
|
{
|
||||||
if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE))
|
if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE))
|
||||||
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::gpu::convertTo(src, dst, alpha, beta);
|
cv::gpu::convertTo(src, dst, alpha, beta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTo(GpuMat& m, Scalar s, const GpuMat& mask) const
|
void setTo(cv::gpu::GpuMat& m, cv::Scalar s, const cv::gpu::GpuMat& mask) const
|
||||||
{
|
{
|
||||||
if (mask.empty())
|
if (mask.empty())
|
||||||
{
|
{
|
||||||
@ -1332,13 +1328,13 @@ namespace
|
|||||||
|
|
||||||
if (cn == 1 || (cn == 2 && s[0] == s[1]) || (cn == 3 && s[0] == s[1] && s[0] == s[2]) || (cn == 4 && s[0] == s[1] && s[0] == s[2] && s[0] == s[3]))
|
if (cn == 1 || (cn == 2 && s[0] == s[1]) || (cn == 3 && s[0] == s[1] && s[0] == s[2]) || (cn == 4 && s[0] == s[1] && s[0] == s[2] && s[0] == s[3]))
|
||||||
{
|
{
|
||||||
int val = saturate_cast<uchar>(s[0]);
|
int val = cv::saturate_cast<uchar>(s[0]);
|
||||||
cudaSafeCall( cudaMemset2D(m.data, m.step, val, m.cols * m.elemSize(), m.rows) );
|
cudaSafeCall( cudaMemset2D(m.data, m.step, val, m.cols * m.elemSize(), m.rows) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*func_t)(GpuMat& src, Scalar s);
|
typedef void (*func_t)(cv::gpu::GpuMat& src, cv::Scalar s);
|
||||||
static const func_t funcs[7][4] =
|
static const func_t funcs[7][4] =
|
||||||
{
|
{
|
||||||
{NppSet<CV_8U , 1, nppiSet_8u_C1R >::call, cv::gpu::setTo , cv::gpu::setTo , NppSet<CV_8U , 4, nppiSet_8u_C4R >::call},
|
{NppSet<CV_8U , 1, nppiSet_8u_C1R >::call, cv::gpu::setTo , cv::gpu::setTo , NppSet<CV_8U , 4, nppiSet_8u_C4R >::call},
|
||||||
@ -1354,7 +1350,7 @@ namespace
|
|||||||
|
|
||||||
if (m.depth() == CV_64F)
|
if (m.depth() == CV_64F)
|
||||||
{
|
{
|
||||||
if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE))
|
if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE))
|
||||||
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1362,7 +1358,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
typedef void (*func_t)(GpuMat& src, Scalar s, const GpuMat& mask);
|
typedef void (*func_t)(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask);
|
||||||
static const func_t funcs[7][4] =
|
static const func_t funcs[7][4] =
|
||||||
{
|
{
|
||||||
{NppSetMask<CV_8U , 1, nppiSet_8u_C1MR >::call, cv::gpu::setTo, cv::gpu::setTo, NppSetMask<CV_8U , 4, nppiSet_8u_C4MR >::call},
|
{NppSetMask<CV_8U , 1, nppiSet_8u_C1MR >::call, cv::gpu::setTo, cv::gpu::setTo, NppSetMask<CV_8U , 4, nppiSet_8u_C4MR >::call},
|
||||||
@ -1378,7 +1374,7 @@ namespace
|
|||||||
|
|
||||||
if (m.depth() == CV_64F)
|
if (m.depth() == CV_64F)
|
||||||
{
|
{
|
||||||
if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE))
|
if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE))
|
||||||
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1406,7 +1402,7 @@ namespace
|
|||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
|
||||||
void cv::gpu::GpuMat::upload(const Mat& m)
|
void cv::gpu::GpuMat::upload(const cv::Mat& m)
|
||||||
{
|
{
|
||||||
CV_DbgAssert(!m.empty());
|
CV_DbgAssert(!m.empty());
|
||||||
|
|
||||||
@ -1415,7 +1411,7 @@ void cv::gpu::GpuMat::upload(const Mat& m)
|
|||||||
gpuFuncTable()->copy(m, *this);
|
gpuFuncTable()->copy(m, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::gpu::GpuMat::download(Mat& m) const
|
void cv::gpu::GpuMat::download(cv::Mat& m) const
|
||||||
{
|
{
|
||||||
CV_DbgAssert(!empty());
|
CV_DbgAssert(!empty());
|
||||||
|
|
||||||
@ -1424,7 +1420,7 @@ void cv::gpu::GpuMat::download(Mat& m) const
|
|||||||
gpuFuncTable()->copy(*this, m);
|
gpuFuncTable()->copy(*this, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::gpu::GpuMat::copyTo(GpuMat& m) const
|
void cv::gpu::GpuMat::copyTo(cv::gpu::GpuMat& m) const
|
||||||
{
|
{
|
||||||
CV_DbgAssert(!empty());
|
CV_DbgAssert(!empty());
|
||||||
|
|
||||||
@ -1433,7 +1429,7 @@ void cv::gpu::GpuMat::copyTo(GpuMat& m) const
|
|||||||
gpuFuncTable()->copy(*this, m);
|
gpuFuncTable()->copy(*this, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::gpu::GpuMat::copyTo(GpuMat& mat, const GpuMat& mask) const
|
void cv::gpu::GpuMat::copyTo(cv::gpu::GpuMat& mat, const cv::gpu::GpuMat& mask) const
|
||||||
{
|
{
|
||||||
if (mask.empty())
|
if (mask.empty())
|
||||||
copyTo(mat);
|
copyTo(mat);
|
||||||
@ -1445,9 +1441,9 @@ void cv::gpu::GpuMat::copyTo(GpuMat& mat, const GpuMat& mask) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::gpu::GpuMat::convertTo(GpuMat& dst, int rtype, double alpha, double beta) const
|
void cv::gpu::GpuMat::convertTo(cv::gpu::GpuMat& dst, int rtype, double alpha, double beta) const
|
||||||
{
|
{
|
||||||
bool noScale = fabs(alpha - 1) < numeric_limits<double>::epsilon() && fabs(beta) < numeric_limits<double>::epsilon();
|
bool noScale = fabs(alpha - 1) < std::numeric_limits<double>::epsilon() && fabs(beta) < std::numeric_limits<double>::epsilon();
|
||||||
|
|
||||||
if (rtype < 0)
|
if (rtype < 0)
|
||||||
rtype = type();
|
rtype = type();
|
||||||
@ -1462,8 +1458,8 @@ void cv::gpu::GpuMat::convertTo(GpuMat& dst, int rtype, double alpha, double bet
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuMat temp;
|
cv::gpu::GpuMat temp;
|
||||||
const GpuMat* psrc = this;
|
const cv::gpu::GpuMat* psrc = this;
|
||||||
if (sdepth != ddepth && psrc == &dst)
|
if (sdepth != ddepth && psrc == &dst)
|
||||||
{
|
{
|
||||||
temp = *this;
|
temp = *this;
|
||||||
@ -1478,7 +1474,7 @@ void cv::gpu::GpuMat::convertTo(GpuMat& dst, int rtype, double alpha, double bet
|
|||||||
gpuFuncTable()->convert(*psrc, dst, alpha, beta);
|
gpuFuncTable()->convert(*psrc, dst, alpha, beta);
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuMat& cv::gpu::GpuMat::setTo(Scalar s, const GpuMat& mask)
|
cv::gpu::GpuMat& cv::gpu::GpuMat::setTo(cv::Scalar s, const cv::gpu::GpuMat& mask)
|
||||||
{
|
{
|
||||||
CV_Assert(mask.empty() || mask.type() == CV_8UC1);
|
CV_Assert(mask.empty() || mask.type() == CV_8UC1);
|
||||||
CV_DbgAssert(!empty());
|
CV_DbgAssert(!empty());
|
||||||
@ -1502,7 +1498,7 @@ void cv::gpu::GpuMat::create(int _rows, int _cols, int _type)
|
|||||||
|
|
||||||
if (_rows > 0 && _cols > 0)
|
if (_rows > 0 && _cols > 0)
|
||||||
{
|
{
|
||||||
flags = Mat::MAGIC_VAL + _type;
|
flags = cv::Mat::MAGIC_VAL + _type;
|
||||||
rows = _rows;
|
rows = _rows;
|
||||||
cols = _cols;
|
cols = _cols;
|
||||||
|
|
||||||
@ -1516,7 +1512,7 @@ void cv::gpu::GpuMat::create(int _rows, int _cols, int _type)
|
|||||||
step = esz * cols;
|
step = esz * cols;
|
||||||
|
|
||||||
if (esz * cols == step)
|
if (esz * cols == step)
|
||||||
flags |= Mat::CONTINUOUS_FLAG;
|
flags |= cv::Mat::CONTINUOUS_FLAG;
|
||||||
|
|
||||||
int64 _nettosize = static_cast<int64>(step) * rows;
|
int64 _nettosize = static_cast<int64>(step) * rows;
|
||||||
size_t nettosize = static_cast<size_t>(_nettosize);
|
size_t nettosize = static_cast<size_t>(_nettosize);
|
||||||
@ -1550,13 +1546,13 @@ void cv::gpu::error(const char *error_string, const char *file, const int line,
|
|||||||
{
|
{
|
||||||
int code = CV_GpuApiCallError;
|
int code = CV_GpuApiCallError;
|
||||||
|
|
||||||
if (uncaught_exception())
|
if (std::uncaught_exception())
|
||||||
{
|
{
|
||||||
const char* errorStr = cvErrorStr(code);
|
const char* errorStr = cvErrorStr(code);
|
||||||
const char* function = func ? func : "unknown function";
|
const char* function = func ? func : "unknown function";
|
||||||
|
|
||||||
cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line;
|
std::cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line;
|
||||||
cerr.flush();
|
std::cerr.flush();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cv::error( cv::Exception(code, error_string, func, file, line) );
|
cv::error( cv::Exception(code, error_string, func, file, line) );
|
||||||
|
@ -1991,7 +1991,7 @@ void pow( InputArray _src, double power, OutputArray _dst )
|
|||||||
|
|
||||||
void sqrt(InputArray a, OutputArray b)
|
void sqrt(InputArray a, OutputArray b)
|
||||||
{
|
{
|
||||||
pow(a, 0.5, b);
|
cv::pow(a, 0.5, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************** CheckArray for NaN's, Inf's *********************************/
|
/************************** CheckArray for NaN's, Inf's *********************************/
|
||||||
@ -2396,7 +2396,7 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
|||||||
double d = a2*a2 - 4*a1*a3;
|
double d = a2*a2 - 4*a1*a3;
|
||||||
if( d >= 0 )
|
if( d >= 0 )
|
||||||
{
|
{
|
||||||
d = sqrt(d);
|
d = std::sqrt(d);
|
||||||
double q1 = (-a2 + d) * 0.5;
|
double q1 = (-a2 + d) * 0.5;
|
||||||
double q2 = (a2 + d) * -0.5;
|
double q2 = (a2 + d) * -0.5;
|
||||||
if( fabs(q1) > fabs(q2) )
|
if( fabs(q1) > fabs(q2) )
|
||||||
@ -2427,8 +2427,8 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
|||||||
|
|
||||||
if( d >= 0 )
|
if( d >= 0 )
|
||||||
{
|
{
|
||||||
double theta = acos(R / sqrt(Qcubed));
|
double theta = acos(R / std::sqrt(Qcubed));
|
||||||
double sqrtQ = sqrt(Q);
|
double sqrtQ = std::sqrt(Q);
|
||||||
double t0 = -2 * sqrtQ;
|
double t0 = -2 * sqrtQ;
|
||||||
double t1 = theta * (1./3);
|
double t1 = theta * (1./3);
|
||||||
double t2 = a1 * (1./3);
|
double t2 = a1 * (1./3);
|
||||||
@ -2440,8 +2440,8 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
double e;
|
double e;
|
||||||
d = sqrt(-d);
|
d = std::sqrt(-d);
|
||||||
e = pow(d + fabs(R), 0.333333333333);
|
e = std::pow(d + fabs(R), 0.333333333333);
|
||||||
if( R > 0 )
|
if( R > 0 )
|
||||||
e = -e;
|
e = -e;
|
||||||
x0 = (e + Q / e) - a1 * (1./3);
|
x0 = (e + Q / e) - a1 * (1./3);
|
||||||
@ -2519,7 +2519,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
|
|||||||
}
|
}
|
||||||
num /= denom;
|
num /= denom;
|
||||||
roots[i] = p - num;
|
roots[i] = p - num;
|
||||||
maxDiff = max(maxDiff, abs(num));
|
maxDiff = std::max(maxDiff, cv::abs(num));
|
||||||
}
|
}
|
||||||
if( maxDiff <= 0 )
|
if( maxDiff <= 0 )
|
||||||
break;
|
break;
|
||||||
|
@ -2151,7 +2151,7 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray
|
|||||||
Mat _data(static_cast<int>(src.size()), size.area(), type);
|
Mat _data(static_cast<int>(src.size()), size.area(), type);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(vector<cv::Mat>::iterator each = src.begin(); each != src.end(); each++, i++ )
|
for(std::vector<cv::Mat>::iterator each = src.begin(); each != src.end(); each++, i++ )
|
||||||
{
|
{
|
||||||
CV_Assert( (*each).size() == size && (*each).type() == type );
|
CV_Assert( (*each).size() == size && (*each).type() == type );
|
||||||
Mat dataRow(size.height, size.width, type, _data.ptr(i));
|
Mat dataRow(size.height, size.width, type, _data.ptr(i));
|
||||||
|
@ -931,7 +931,7 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to)
|
|||||||
_InputArray::_InputArray() : flags(0), obj(0) {}
|
_InputArray::_InputArray() : flags(0), obj(0) {}
|
||||||
_InputArray::~_InputArray() {}
|
_InputArray::~_InputArray() {}
|
||||||
_InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {}
|
_InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {}
|
||||||
_InputArray::_InputArray(const vector<Mat>& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {}
|
_InputArray::_InputArray(const std::vector<Mat>& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {}
|
||||||
_InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {}
|
_InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {}
|
||||||
_InputArray::_InputArray(const MatExpr& expr) : flags(FIXED_TYPE + FIXED_SIZE + EXPR), obj((void*)&expr) {}
|
_InputArray::_InputArray(const MatExpr& expr) : flags(FIXED_TYPE + FIXED_SIZE + EXPR), obj((void*)&expr) {}
|
||||||
_InputArray::_InputArray(const GlBuffer& buf) : flags(OPENGL_BUFFER), obj((void*)&buf) {}
|
_InputArray::_InputArray(const GlBuffer& buf) : flags(OPENGL_BUFFER), obj((void*)&buf) {}
|
||||||
@ -966,7 +966,7 @@ Mat _InputArray::getMat(int i) const
|
|||||||
{
|
{
|
||||||
CV_Assert( i < 0 );
|
CV_Assert( i < 0 );
|
||||||
int t = CV_MAT_TYPE(flags);
|
int t = CV_MAT_TYPE(flags);
|
||||||
const vector<uchar>& v = *(const vector<uchar>*)obj;
|
const std::vector<uchar>& v = *(const std::vector<uchar>*)obj;
|
||||||
|
|
||||||
return !v.empty() ? Mat(size(), t, (void*)&v[0]) : Mat();
|
return !v.empty() ? Mat(size(), t, (void*)&v[0]) : Mat();
|
||||||
}
|
}
|
||||||
@ -977,9 +977,9 @@ Mat _InputArray::getMat(int i) const
|
|||||||
if( k == STD_VECTOR_VECTOR )
|
if( k == STD_VECTOR_VECTOR )
|
||||||
{
|
{
|
||||||
int t = type(i);
|
int t = type(i);
|
||||||
const vector<vector<uchar> >& vv = *(const vector<vector<uchar> >*)obj;
|
const std::vector<std::vector<uchar> >& vv = *(const std::vector<std::vector<uchar> >*)obj;
|
||||||
CV_Assert( 0 <= i && i < (int)vv.size() );
|
CV_Assert( 0 <= i && i < (int)vv.size() );
|
||||||
const vector<uchar>& v = vv[i];
|
const std::vector<uchar>& v = vv[i];
|
||||||
|
|
||||||
return !v.empty() ? Mat(size(i), t, (void*)&v[0]) : Mat();
|
return !v.empty() ? Mat(size(i), t, (void*)&v[0]) : Mat();
|
||||||
}
|
}
|
||||||
@ -987,7 +987,7 @@ Mat _InputArray::getMat(int i) const
|
|||||||
CV_Assert( k == STD_VECTOR_MAT );
|
CV_Assert( k == STD_VECTOR_MAT );
|
||||||
//if( k == STD_VECTOR_MAT )
|
//if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
const vector<Mat>& v = *(const vector<Mat>*)obj;
|
const std::vector<Mat>& v = *(const std::vector<Mat>*)obj;
|
||||||
CV_Assert( 0 <= i && i < (int)v.size() );
|
CV_Assert( 0 <= i && i < (int)v.size() );
|
||||||
|
|
||||||
return v[i];
|
return v[i];
|
||||||
@ -995,7 +995,7 @@ Mat _InputArray::getMat(int i) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _InputArray::getMatVector(vector<Mat>& mv) const
|
void _InputArray::getMatVector(std::vector<Mat>& mv) const
|
||||||
{
|
{
|
||||||
int k = kind();
|
int k = kind();
|
||||||
|
|
||||||
@ -1034,7 +1034,7 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
|
|||||||
|
|
||||||
if( k == STD_VECTOR )
|
if( k == STD_VECTOR )
|
||||||
{
|
{
|
||||||
const vector<uchar>& v = *(const vector<uchar>*)obj;
|
const std::vector<uchar>& v = *(const std::vector<uchar>*)obj;
|
||||||
|
|
||||||
size_t i, n = v.size(), esz = CV_ELEM_SIZE(flags);
|
size_t i, n = v.size(), esz = CV_ELEM_SIZE(flags);
|
||||||
int t = CV_MAT_DEPTH(flags), cn = CV_MAT_CN(flags);
|
int t = CV_MAT_DEPTH(flags), cn = CV_MAT_CN(flags);
|
||||||
@ -1053,14 +1053,14 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
|
|||||||
|
|
||||||
if( k == STD_VECTOR_VECTOR )
|
if( k == STD_VECTOR_VECTOR )
|
||||||
{
|
{
|
||||||
const vector<vector<uchar> >& vv = *(const vector<vector<uchar> >*)obj;
|
const std::vector<std::vector<uchar> >& vv = *(const std::vector<std::vector<uchar> >*)obj;
|
||||||
int i, n = (int)vv.size();
|
int i, n = (int)vv.size();
|
||||||
int t = CV_MAT_TYPE(flags);
|
int t = CV_MAT_TYPE(flags);
|
||||||
mv.resize(n);
|
mv.resize(n);
|
||||||
|
|
||||||
for( i = 0; i < n; i++ )
|
for( i = 0; i < n; i++ )
|
||||||
{
|
{
|
||||||
const vector<uchar>& v = vv[i];
|
const std::vector<uchar>& v = vv[i];
|
||||||
mv[i] = Mat(size(i), t, (void*)&v[0]);
|
mv[i] = Mat(size(i), t, (void*)&v[0]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1069,7 +1069,7 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
|
|||||||
CV_Assert( k == STD_VECTOR_MAT );
|
CV_Assert( k == STD_VECTOR_MAT );
|
||||||
//if( k == STD_VECTOR_MAT )
|
//if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
const vector<Mat>& v = *(const vector<Mat>*)obj;
|
const std::vector<Mat>& v = *(const std::vector<Mat>*)obj;
|
||||||
mv.resize(v.size());
|
mv.resize(v.size());
|
||||||
std::copy(v.begin(), v.end(), mv.begin());
|
std::copy(v.begin(), v.end(), mv.begin());
|
||||||
return;
|
return;
|
||||||
@ -1142,8 +1142,8 @@ Size _InputArray::size(int i) const
|
|||||||
if( k == STD_VECTOR )
|
if( k == STD_VECTOR )
|
||||||
{
|
{
|
||||||
CV_Assert( i < 0 );
|
CV_Assert( i < 0 );
|
||||||
const vector<uchar>& v = *(const vector<uchar>*)obj;
|
const std::vector<uchar>& v = *(const std::vector<uchar>*)obj;
|
||||||
const vector<int>& iv = *(const vector<int>*)obj;
|
const std::vector<int>& iv = *(const std::vector<int>*)obj;
|
||||||
size_t szb = v.size(), szi = iv.size();
|
size_t szb = v.size(), szi = iv.size();
|
||||||
return szb == szi ? Size((int)szb, 1) : Size((int)(szb/CV_ELEM_SIZE(flags)), 1);
|
return szb == szi ? Size((int)szb, 1) : Size((int)(szb/CV_ELEM_SIZE(flags)), 1);
|
||||||
}
|
}
|
||||||
@ -1153,11 +1153,11 @@ Size _InputArray::size(int i) const
|
|||||||
|
|
||||||
if( k == STD_VECTOR_VECTOR )
|
if( k == STD_VECTOR_VECTOR )
|
||||||
{
|
{
|
||||||
const vector<vector<uchar> >& vv = *(const vector<vector<uchar> >*)obj;
|
const std::vector<std::vector<uchar> >& vv = *(const std::vector<std::vector<uchar> >*)obj;
|
||||||
if( i < 0 )
|
if( i < 0 )
|
||||||
return vv.empty() ? Size() : Size((int)vv.size(), 1);
|
return vv.empty() ? Size() : Size((int)vv.size(), 1);
|
||||||
CV_Assert( i < (int)vv.size() );
|
CV_Assert( i < (int)vv.size() );
|
||||||
const vector<vector<int> >& ivv = *(const vector<vector<int> >*)obj;
|
const std::vector<std::vector<int> >& ivv = *(const std::vector<std::vector<int> >*)obj;
|
||||||
|
|
||||||
size_t szb = vv[i].size(), szi = ivv[i].size();
|
size_t szb = vv[i].size(), szi = ivv[i].size();
|
||||||
return szb == szi ? Size((int)szb, 1) : Size((int)(szb/CV_ELEM_SIZE(flags)), 1);
|
return szb == szi ? Size((int)szb, 1) : Size((int)(szb/CV_ELEM_SIZE(flags)), 1);
|
||||||
@ -1165,7 +1165,7 @@ Size _InputArray::size(int i) const
|
|||||||
|
|
||||||
if( k == STD_VECTOR_MAT )
|
if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
const vector<Mat>& vv = *(const vector<Mat>*)obj;
|
const std::vector<Mat>& vv = *(const std::vector<Mat>*)obj;
|
||||||
if( i < 0 )
|
if( i < 0 )
|
||||||
return vv.empty() ? Size() : Size((int)vv.size(), 1);
|
return vv.empty() ? Size() : Size((int)vv.size(), 1);
|
||||||
CV_Assert( i < (int)vv.size() );
|
CV_Assert( i < (int)vv.size() );
|
||||||
@ -1208,7 +1208,7 @@ size_t _InputArray::total(int i) const
|
|||||||
|
|
||||||
if( k == STD_VECTOR_MAT )
|
if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
const vector<Mat>& vv = *(const vector<Mat>*)obj;
|
const std::vector<Mat>& vv = *(const std::vector<Mat>*)obj;
|
||||||
if( i < 0 )
|
if( i < 0 )
|
||||||
return vv.size();
|
return vv.size();
|
||||||
|
|
||||||
@ -1237,7 +1237,7 @@ int _InputArray::type(int i) const
|
|||||||
|
|
||||||
if( k == STD_VECTOR_MAT )
|
if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
const vector<Mat>& vv = *(const vector<Mat>*)obj;
|
const std::vector<Mat>& vv = *(const std::vector<Mat>*)obj;
|
||||||
CV_Assert( i < (int)vv.size() );
|
CV_Assert( i < (int)vv.size() );
|
||||||
|
|
||||||
return vv[i >= 0 ? i : 0].type();
|
return vv[i >= 0 ? i : 0].type();
|
||||||
@ -1276,7 +1276,7 @@ bool _InputArray::empty() const
|
|||||||
|
|
||||||
if( k == STD_VECTOR )
|
if( k == STD_VECTOR )
|
||||||
{
|
{
|
||||||
const vector<uchar>& v = *(const vector<uchar>*)obj;
|
const std::vector<uchar>& v = *(const std::vector<uchar>*)obj;
|
||||||
return v.empty();
|
return v.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1285,13 +1285,13 @@ bool _InputArray::empty() const
|
|||||||
|
|
||||||
if( k == STD_VECTOR_VECTOR )
|
if( k == STD_VECTOR_VECTOR )
|
||||||
{
|
{
|
||||||
const vector<vector<uchar> >& vv = *(const vector<vector<uchar> >*)obj;
|
const std::vector<std::vector<uchar> >& vv = *(const std::vector<std::vector<uchar> >*)obj;
|
||||||
return vv.empty();
|
return vv.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( k == STD_VECTOR_MAT )
|
if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
const vector<Mat>& vv = *(const vector<Mat>*)obj;
|
const std::vector<Mat>& vv = *(const std::vector<Mat>*)obj;
|
||||||
return vv.empty();
|
return vv.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1310,13 +1310,13 @@ bool _InputArray::empty() const
|
|||||||
_OutputArray::_OutputArray() {}
|
_OutputArray::_OutputArray() {}
|
||||||
_OutputArray::~_OutputArray() {}
|
_OutputArray::~_OutputArray() {}
|
||||||
_OutputArray::_OutputArray(Mat& m) : _InputArray(m) {}
|
_OutputArray::_OutputArray(Mat& m) : _InputArray(m) {}
|
||||||
_OutputArray::_OutputArray(vector<Mat>& vec) : _InputArray(vec) {}
|
_OutputArray::_OutputArray(std::vector<Mat>& vec) : _InputArray(vec) {}
|
||||||
_OutputArray::_OutputArray(gpu::GpuMat& d_mat) : _InputArray(d_mat) {}
|
_OutputArray::_OutputArray(gpu::GpuMat& d_mat) : _InputArray(d_mat) {}
|
||||||
_OutputArray::_OutputArray(GlBuffer& buf) : _InputArray(buf) {}
|
_OutputArray::_OutputArray(GlBuffer& buf) : _InputArray(buf) {}
|
||||||
_OutputArray::_OutputArray(GlTexture2D& tex) : _InputArray(tex) {}
|
_OutputArray::_OutputArray(GlTexture2D& tex) : _InputArray(tex) {}
|
||||||
|
|
||||||
_OutputArray::_OutputArray(const Mat& m) : _InputArray(m) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
_OutputArray::_OutputArray(const Mat& m) : _InputArray(m) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||||
_OutputArray::_OutputArray(const vector<Mat>& vec) : _InputArray(vec) {flags |= FIXED_SIZE;}
|
_OutputArray::_OutputArray(const std::vector<Mat>& vec) : _InputArray(vec) {flags |= FIXED_SIZE;}
|
||||||
_OutputArray::_OutputArray(const gpu::GpuMat& d_mat) : _InputArray(d_mat) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
_OutputArray::_OutputArray(const gpu::GpuMat& d_mat) : _InputArray(d_mat) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||||
_OutputArray::_OutputArray(const GlBuffer& buf) : _InputArray(buf) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
_OutputArray::_OutputArray(const GlBuffer& buf) : _InputArray(buf) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||||
_OutputArray::_OutputArray(const GlTexture2D& tex) : _InputArray(tex) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
_OutputArray::_OutputArray(const GlTexture2D& tex) : _InputArray(tex) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||||
@ -1441,11 +1441,11 @@ void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool all
|
|||||||
{
|
{
|
||||||
CV_Assert( dims == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
|
CV_Assert( dims == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
|
||||||
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0;
|
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0;
|
||||||
vector<uchar>* v = (vector<uchar>*)obj;
|
std::vector<uchar>* v = (std::vector<uchar>*)obj;
|
||||||
|
|
||||||
if( k == STD_VECTOR_VECTOR )
|
if( k == STD_VECTOR_VECTOR )
|
||||||
{
|
{
|
||||||
vector<vector<uchar> >& vv = *(vector<vector<uchar> >*)obj;
|
std::vector<std::vector<uchar> >& vv = *(std::vector<std::vector<uchar> >*)obj;
|
||||||
if( i < 0 )
|
if( i < 0 )
|
||||||
{
|
{
|
||||||
CV_Assert(!fixedSize() || len == vv.size());
|
CV_Assert(!fixedSize() || len == vv.size());
|
||||||
@ -1462,56 +1462,56 @@ void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool all
|
|||||||
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) );
|
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) );
|
||||||
|
|
||||||
int esz = CV_ELEM_SIZE(type0);
|
int esz = CV_ELEM_SIZE(type0);
|
||||||
CV_Assert(!fixedSize() || len == ((vector<uchar>*)v)->size() / esz);
|
CV_Assert(!fixedSize() || len == ((std::vector<uchar>*)v)->size() / esz);
|
||||||
switch( esz )
|
switch( esz )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
((vector<uchar>*)v)->resize(len);
|
((std::vector<uchar>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
((vector<Vec2b>*)v)->resize(len);
|
((std::vector<Vec2b>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
((vector<Vec3b>*)v)->resize(len);
|
((std::vector<Vec3b>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
((vector<int>*)v)->resize(len);
|
((std::vector<int>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
((vector<Vec3s>*)v)->resize(len);
|
((std::vector<Vec3s>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
((vector<Vec2i>*)v)->resize(len);
|
((std::vector<Vec2i>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
((vector<Vec3i>*)v)->resize(len);
|
((std::vector<Vec3i>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
((vector<Vec4i>*)v)->resize(len);
|
((std::vector<Vec4i>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
((vector<Vec6i>*)v)->resize(len);
|
((std::vector<Vec6i>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
((vector<Vec8i>*)v)->resize(len);
|
((std::vector<Vec8i>*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
((vector<Vec<int, 9> >*)v)->resize(len);
|
((std::vector<Vec<int, 9> >*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 48:
|
case 48:
|
||||||
((vector<Vec<int, 12> >*)v)->resize(len);
|
((std::vector<Vec<int, 12> >*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 64:
|
case 64:
|
||||||
((vector<Vec<int, 16> >*)v)->resize(len);
|
((std::vector<Vec<int, 16> >*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 128:
|
case 128:
|
||||||
((vector<Vec<int, 32> >*)v)->resize(len);
|
((std::vector<Vec<int, 32> >*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 256:
|
case 256:
|
||||||
((vector<Vec<int, 64> >*)v)->resize(len);
|
((std::vector<Vec<int, 64> >*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
case 512:
|
case 512:
|
||||||
((vector<Vec<int, 128> >*)v)->resize(len);
|
((std::vector<Vec<int, 128> >*)v)->resize(len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CV_Error_(CV_StsBadArg, ("Vectors with element size %d are not supported. Please, modify OutputArray::create()\n", esz));
|
CV_Error_(CV_StsBadArg, ("Vectors with element size %d are not supported. Please, modify OutputArray::create()\n", esz));
|
||||||
@ -1528,7 +1528,7 @@ void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool all
|
|||||||
CV_Assert( k == STD_VECTOR_MAT );
|
CV_Assert( k == STD_VECTOR_MAT );
|
||||||
//if( k == STD_VECTOR_MAT )
|
//if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
vector<Mat>& v = *(vector<Mat>*)obj;
|
std::vector<Mat>& v = *(std::vector<Mat>*)obj;
|
||||||
|
|
||||||
if( i < 0 )
|
if( i < 0 )
|
||||||
{
|
{
|
||||||
@ -1626,14 +1626,14 @@ void _OutputArray::release() const
|
|||||||
|
|
||||||
if( k == STD_VECTOR_VECTOR )
|
if( k == STD_VECTOR_VECTOR )
|
||||||
{
|
{
|
||||||
((vector<vector<uchar> >*)obj)->clear();
|
((std::vector<std::vector<uchar> >*)obj)->clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_Assert( k == STD_VECTOR_MAT );
|
CV_Assert( k == STD_VECTOR_MAT );
|
||||||
//if( k == STD_VECTOR_MAT )
|
//if( k == STD_VECTOR_MAT )
|
||||||
{
|
{
|
||||||
((vector<Mat>*)obj)->clear();
|
((std::vector<Mat>*)obj)->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1667,7 +1667,7 @@ Mat& _OutputArray::getMatRef(int i) const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_Assert( k == STD_VECTOR_MAT );
|
CV_Assert( k == STD_VECTOR_MAT );
|
||||||
vector<Mat>& v = *(vector<Mat>*)obj;
|
std::vector<Mat>& v = *(std::vector<Mat>*)obj;
|
||||||
CV_Assert( i < (int)v.size() );
|
CV_Assert( i < (int)v.size() );
|
||||||
return v[i];
|
return v[i];
|
||||||
}
|
}
|
||||||
@ -1738,7 +1738,7 @@ void cv::hconcat(InputArray src1, InputArray src2, OutputArray dst)
|
|||||||
|
|
||||||
void cv::hconcat(InputArray _src, OutputArray dst)
|
void cv::hconcat(InputArray _src, OutputArray dst)
|
||||||
{
|
{
|
||||||
vector<Mat> src;
|
std::vector<Mat> src;
|
||||||
_src.getMatVector(src);
|
_src.getMatVector(src);
|
||||||
hconcat(!src.empty() ? &src[0] : 0, src.size(), dst);
|
hconcat(!src.empty() ? &src[0] : 0, src.size(), dst);
|
||||||
}
|
}
|
||||||
@ -1778,7 +1778,7 @@ void cv::vconcat(InputArray src1, InputArray src2, OutputArray dst)
|
|||||||
|
|
||||||
void cv::vconcat(InputArray _src, OutputArray dst)
|
void cv::vconcat(InputArray _src, OutputArray dst)
|
||||||
{
|
{
|
||||||
vector<Mat> src;
|
std::vector<Mat> src;
|
||||||
_src.getMatVector(src);
|
_src.getMatVector(src);
|
||||||
vconcat(!src.empty() ? &src[0] : 0, src.size(), dst);
|
vconcat(!src.empty() ? &src[0] : 0, src.size(), dst);
|
||||||
}
|
}
|
||||||
@ -2504,7 +2504,7 @@ void cv::sortIdx( InputArray _src, OutputArray _dst, int flags )
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
static void generateRandomCenter(const vector<Vec2f>& box, float* center, RNG& rng)
|
static void generateRandomCenter(const std::vector<Vec2f>& box, float* center, RNG& rng)
|
||||||
{
|
{
|
||||||
size_t j, dims = box.size();
|
size_t j, dims = box.size();
|
||||||
float margin = 1.f/dims;
|
float margin = 1.f/dims;
|
||||||
@ -2560,9 +2560,9 @@ static void generateCentersPP(const Mat& _data, Mat& _out_centers,
|
|||||||
int i, j, k, dims = _data.cols, N = _data.rows;
|
int i, j, k, dims = _data.cols, N = _data.rows;
|
||||||
const float* data = _data.ptr<float>(0);
|
const float* data = _data.ptr<float>(0);
|
||||||
size_t step = _data.step/sizeof(data[0]);
|
size_t step = _data.step/sizeof(data[0]);
|
||||||
vector<int> _centers(K);
|
std::vector<int> _centers(K);
|
||||||
int* centers = &_centers[0];
|
int* centers = &_centers[0];
|
||||||
vector<float> _dist(N*3);
|
std::vector<float> _dist(N*3);
|
||||||
float* dist = &_dist[0], *tdist = dist + N, *tdist2 = tdist + N;
|
float* dist = &_dist[0], *tdist = dist + N, *tdist2 = tdist + N;
|
||||||
double sum0 = 0;
|
double sum0 = 0;
|
||||||
|
|
||||||
@ -2710,8 +2710,8 @@ double cv::kmeans( InputArray _data, int K,
|
|||||||
int* labels = _labels.ptr<int>();
|
int* labels = _labels.ptr<int>();
|
||||||
|
|
||||||
Mat centers(K, dims, type), old_centers(K, dims, type), temp(1, dims, type);
|
Mat centers(K, dims, type), old_centers(K, dims, type), temp(1, dims, type);
|
||||||
vector<int> counters(K);
|
std::vector<int> counters(K);
|
||||||
vector<Vec2f> _box(dims);
|
std::vector<Vec2f> _box(dims);
|
||||||
Vec2f* box = &_box[0];
|
Vec2f* box = &_box[0];
|
||||||
double best_compactness = DBL_MAX, compactness = 0;
|
double best_compactness = DBL_MAX, compactness = 0;
|
||||||
RNG& rng = theRNG();
|
RNG& rng = theRNG();
|
||||||
@ -3973,7 +3973,7 @@ void SparseMat::resizeHashTab(size_t newsize)
|
|||||||
newsize = (size_t)1 << cvCeil(std::log((double)newsize)/CV_LOG2);
|
newsize = (size_t)1 << cvCeil(std::log((double)newsize)/CV_LOG2);
|
||||||
|
|
||||||
size_t i, hsize = hdr->hashtab.size();
|
size_t i, hsize = hdr->hashtab.size();
|
||||||
vector<size_t> _newh(newsize);
|
std::vector<size_t> _newh(newsize);
|
||||||
size_t* newh = &_newh[0];
|
size_t* newh = &_newh[0];
|
||||||
for( i = 0; i < newsize; i++ )
|
for( i = 0; i < newsize; i++ )
|
||||||
newh[i] = 0;
|
newh[i] = 0;
|
||||||
@ -4062,7 +4062,7 @@ SparseMatConstIterator::SparseMatConstIterator(const SparseMat* _m)
|
|||||||
if(!_m || !_m->hdr)
|
if(!_m || !_m->hdr)
|
||||||
return;
|
return;
|
||||||
SparseMat::Hdr& hdr = *m->hdr;
|
SparseMat::Hdr& hdr = *m->hdr;
|
||||||
const vector<size_t>& htab = hdr.hashtab;
|
const std::vector<size_t>& htab = hdr.hashtab;
|
||||||
size_t i, hsize = htab.size();
|
size_t i, hsize = htab.size();
|
||||||
for( i = 0; i < hsize; i++ )
|
for( i = 0; i < hsize; i++ )
|
||||||
{
|
{
|
||||||
@ -4252,10 +4252,10 @@ Rect RotatedRect::boundingRect() const
|
|||||||
{
|
{
|
||||||
Point2f pt[4];
|
Point2f pt[4];
|
||||||
points(pt);
|
points(pt);
|
||||||
Rect r(cvFloor(min(min(min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
|
Rect r(cvFloor(std::min(std::min(std::min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
|
||||||
cvFloor(min(min(min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
|
cvFloor(std::min(std::min(std::min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
|
||||||
cvCeil(max(max(max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
|
cvCeil(std::max(std::max(std::max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
|
||||||
cvCeil(max(max(max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
|
cvCeil(std::max(std::max(std::max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
|
||||||
r.width -= r.x - 1;
|
r.width -= r.x - 1;
|
||||||
r.height -= r.y - 1;
|
r.height -= r.y - 1;
|
||||||
return r;
|
return r;
|
||||||
|
@ -53,10 +53,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace cv;
|
|
||||||
using namespace cv::gpu;
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifndef HAVE_OPENGL
|
#ifndef HAVE_OPENGL
|
||||||
@ -363,7 +359,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
const Ptr<cv::GlBuffer::Impl>& cv::GlBuffer::Impl::empty()
|
const cv::Ptr<cv::GlBuffer::Impl>& cv::GlBuffer::Impl::empty()
|
||||||
{
|
{
|
||||||
static Ptr<Impl> p(new Impl);
|
static Ptr<Impl> p(new Impl);
|
||||||
return p;
|
return p;
|
||||||
@ -720,7 +716,7 @@ void cv::GlBuffer::copyTo(OutputArray arr, Target target, bool autoRelease) cons
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GlBuffer cv::GlBuffer::clone(Target target, bool autoRelease) const
|
cv::GlBuffer cv::GlBuffer::clone(Target target, bool autoRelease) const
|
||||||
{
|
{
|
||||||
#ifndef HAVE_OPENGL
|
#ifndef HAVE_OPENGL
|
||||||
(void) target;
|
(void) target;
|
||||||
@ -755,14 +751,14 @@ void cv::GlBuffer::unbind(Target target)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat cv::GlBuffer::mapHost(Access access)
|
cv::Mat cv::GlBuffer::mapHost(Access access)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_OPENGL
|
#ifndef HAVE_OPENGL
|
||||||
(void) access;
|
(void) access;
|
||||||
throw_nogl();
|
throw_nogl();
|
||||||
return Mat();
|
return cv::Mat();
|
||||||
#else
|
#else
|
||||||
return Mat(rows_, cols_, type_, impl_->mapHost(access));
|
return cv::Mat(rows_, cols_, type_, impl_->mapHost(access));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -775,17 +771,17 @@ void cv::GlBuffer::unmapHost()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuMat cv::GlBuffer::mapDevice()
|
cv::gpu::GpuMat cv::GlBuffer::mapDevice()
|
||||||
{
|
{
|
||||||
#ifndef HAVE_OPENGL
|
#ifndef HAVE_OPENGL
|
||||||
throw_nogl();
|
throw_nogl();
|
||||||
return GpuMat();
|
return cv::gpu::GpuMat();
|
||||||
#else
|
#else
|
||||||
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
|
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
|
||||||
throw_nocuda();
|
throw_nocuda();
|
||||||
return GpuMat();
|
return cv::gpu::GpuMat();
|
||||||
#else
|
#else
|
||||||
return GpuMat(rows_, cols_, type_, impl_->mapDevice());
|
return cv::gpu::GpuMat(rows_, cols_, type_, impl_->mapDevice());
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -854,7 +850,7 @@ private:
|
|||||||
bool autoRelease_;
|
bool autoRelease_;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Ptr<cv::GlTexture2D::Impl> cv::GlTexture2D::Impl::empty()
|
const cv::Ptr<cv::GlTexture2D::Impl> cv::GlTexture2D::Impl::empty()
|
||||||
{
|
{
|
||||||
static Ptr<Impl> p(new Impl);
|
static Ptr<Impl> p(new Impl);
|
||||||
return p;
|
return p;
|
||||||
|
@ -282,7 +282,7 @@ const Formatter* Formatter::setDefault(const Formatter* fmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Formatted::Formatted(const Mat& _m, const Formatter* _fmt,
|
Formatted::Formatted(const Mat& _m, const Formatter* _fmt,
|
||||||
const vector<int>& _params)
|
const std::vector<int>& _params)
|
||||||
{
|
{
|
||||||
mtx = _m;
|
mtx = _m;
|
||||||
fmt = _fmt ? _fmt : Formatter::get();
|
fmt = _fmt ? _fmt : Formatter::get();
|
||||||
|
@ -116,7 +116,7 @@ static char* icv_itoa( int _val, char* buffer, int /*radix*/ )
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::string cv::FileStorage::getDefaultObjectName(const string& _filename)
|
std::string cv::FileStorage::getDefaultObjectName(const std::string& _filename)
|
||||||
{
|
{
|
||||||
static const char* stubname = "unnamed";
|
static const char* stubname = "unnamed";
|
||||||
const char* filename = _filename.c_str();
|
const char* filename = _filename.c_str();
|
||||||
@ -152,7 +152,7 @@ cv::string cv::FileStorage::getDefaultObjectName(const string& _filename)
|
|||||||
name = name_buf;
|
name = name_buf;
|
||||||
if( strcmp( name, "_" ) == 0 )
|
if( strcmp( name, "_" ) == 0 )
|
||||||
strcpy( name, stubname );
|
strcpy( name, stubname );
|
||||||
return cv::string(name);
|
return std::string(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct CvGenericHash
|
typedef struct CvGenericHash
|
||||||
@ -5011,7 +5011,7 @@ cvSave( const char* filename, const void* struct_ptr,
|
|||||||
if( !fs )
|
if( !fs )
|
||||||
CV_Error( CV_StsError, "Could not open the file storage. Check the path and permissions" );
|
CV_Error( CV_StsError, "Could not open the file storage. Check the path and permissions" );
|
||||||
|
|
||||||
cv::string name = _name ? cv::string(_name) : cv::FileStorage::getDefaultObjectName(filename);
|
std::string name = _name ? std::string(_name) : cv::FileStorage::getDefaultObjectName(filename);
|
||||||
|
|
||||||
if( comment )
|
if( comment )
|
||||||
cvWriteComment( fs, comment, 0 );
|
cvWriteComment( fs, comment, 0 );
|
||||||
@ -5105,7 +5105,7 @@ stop_search:
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
static void getElemSize( const string& fmt, size_t& elemSize, size_t& cn )
|
static void getElemSize( const std::string& fmt, size_t& elemSize, size_t& cn )
|
||||||
{
|
{
|
||||||
const char* dt = fmt.c_str();
|
const char* dt = fmt.c_str();
|
||||||
cn = 1;
|
cn = 1;
|
||||||
@ -5125,7 +5125,7 @@ FileStorage::FileStorage()
|
|||||||
state = UNDEFINED;
|
state = UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStorage::FileStorage(const string& filename, int flags, const string& encoding)
|
FileStorage::FileStorage(const std::string& filename, int flags, const std::string& encoding)
|
||||||
{
|
{
|
||||||
state = UNDEFINED;
|
state = UNDEFINED;
|
||||||
open( filename, flags, encoding );
|
open( filename, flags, encoding );
|
||||||
@ -5146,7 +5146,7 @@ FileStorage::~FileStorage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileStorage::open(const string& filename, int flags, const string& encoding)
|
bool FileStorage::open(const std::string& filename, int flags, const std::string& encoding)
|
||||||
{
|
{
|
||||||
release();
|
release();
|
||||||
fs = Ptr<CvFileStorage>(cvOpenFileStorage( filename.c_str(), 0, flags,
|
fs = Ptr<CvFileStorage>(cvOpenFileStorage( filename.c_str(), 0, flags,
|
||||||
@ -5168,9 +5168,9 @@ void FileStorage::release()
|
|||||||
state = UNDEFINED;
|
state = UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
string FileStorage::releaseAndGetString()
|
std::string FileStorage::releaseAndGetString()
|
||||||
{
|
{
|
||||||
string buf;
|
std::string buf;
|
||||||
buf.reserve(16); // HACK: Work around for compiler bug
|
buf.reserve(16); // HACK: Work around for compiler bug
|
||||||
if( fs.obj && fs.obj->outbuf )
|
if( fs.obj && fs.obj->outbuf )
|
||||||
icvClose(fs.obj, &buf);
|
icvClose(fs.obj, &buf);
|
||||||
@ -5184,7 +5184,7 @@ FileNode FileStorage::root(int streamidx) const
|
|||||||
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
|
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStorage& operator << (FileStorage& fs, const string& str)
|
FileStorage& operator << (FileStorage& fs, const std::string& str)
|
||||||
{
|
{
|
||||||
enum { NAME_EXPECTED = FileStorage::NAME_EXPECTED,
|
enum { NAME_EXPECTED = FileStorage::NAME_EXPECTED,
|
||||||
VALUE_EXPECTED = FileStorage::VALUE_EXPECTED,
|
VALUE_EXPECTED = FileStorage::VALUE_EXPECTED,
|
||||||
@ -5203,7 +5203,7 @@ FileStorage& operator << (FileStorage& fs, const string& str)
|
|||||||
fs.state = fs.structs.empty() || fs.structs.back() == '{' ?
|
fs.state = fs.structs.empty() || fs.structs.back() == '{' ?
|
||||||
INSIDE_MAP + NAME_EXPECTED : VALUE_EXPECTED;
|
INSIDE_MAP + NAME_EXPECTED : VALUE_EXPECTED;
|
||||||
cvEndWriteStruct( *fs );
|
cvEndWriteStruct( *fs );
|
||||||
fs.elname = string();
|
fs.elname = std::string();
|
||||||
}
|
}
|
||||||
else if( fs.state == NAME_EXPECTED + INSIDE_MAP )
|
else if( fs.state == NAME_EXPECTED + INSIDE_MAP )
|
||||||
{
|
{
|
||||||
@ -5227,12 +5227,12 @@ FileStorage& operator << (FileStorage& fs, const string& str)
|
|||||||
}
|
}
|
||||||
cvStartWriteStruct( *fs, fs.elname.size() > 0 ? fs.elname.c_str() : 0,
|
cvStartWriteStruct( *fs, fs.elname.size() > 0 ? fs.elname.c_str() : 0,
|
||||||
flags, *_str ? _str : 0 );
|
flags, *_str ? _str : 0 );
|
||||||
fs.elname = string();
|
fs.elname = std::string();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write( fs, fs.elname, (_str[0] == '\\' && (_str[1] == '{' || _str[1] == '}' ||
|
write( fs, fs.elname, (_str[0] == '\\' && (_str[1] == '{' || _str[1] == '}' ||
|
||||||
_str[1] == '[' || _str[1] == ']')) ? string(_str+1) : str );
|
_str[1] == '[' || _str[1] == ']')) ? std::string(_str+1) : str );
|
||||||
if( fs.state == INSIDE_MAP + VALUE_EXPECTED )
|
if( fs.state == INSIDE_MAP + VALUE_EXPECTED )
|
||||||
fs.state = INSIDE_MAP + NAME_EXPECTED;
|
fs.state = INSIDE_MAP + NAME_EXPECTED;
|
||||||
}
|
}
|
||||||
@ -5243,7 +5243,7 @@ FileStorage& operator << (FileStorage& fs, const string& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FileStorage::writeRaw( const string& fmt, const uchar* vec, size_t len )
|
void FileStorage::writeRaw( const std::string& fmt, const uchar* vec, size_t len )
|
||||||
{
|
{
|
||||||
if( !isOpened() )
|
if( !isOpened() )
|
||||||
return;
|
return;
|
||||||
@ -5254,7 +5254,7 @@ void FileStorage::writeRaw( const string& fmt, const uchar* vec, size_t len )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FileStorage::writeObj( const string& name, const void* obj )
|
void FileStorage::writeObj( const std::string& name, const void* obj )
|
||||||
{
|
{
|
||||||
if( !isOpened() )
|
if( !isOpened() )
|
||||||
return;
|
return;
|
||||||
@ -5262,7 +5262,7 @@ void FileStorage::writeObj( const string& name, const void* obj )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileNode FileStorage::operator[](const string& nodename) const
|
FileNode FileStorage::operator[](const std::string& nodename) const
|
||||||
{
|
{
|
||||||
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename.c_str()));
|
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename.c_str()));
|
||||||
}
|
}
|
||||||
@ -5272,7 +5272,7 @@ FileNode FileStorage::operator[](const char* nodename) const
|
|||||||
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename));
|
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename));
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNode FileNode::operator[](const string& nodename) const
|
FileNode FileNode::operator[](const std::string& nodename) const
|
||||||
{
|
{
|
||||||
return FileNode(fs, cvGetFileNodeByName(fs, node, nodename.c_str()));
|
return FileNode(fs, cvGetFileNodeByName(fs, node, nodename.c_str()));
|
||||||
}
|
}
|
||||||
@ -5288,10 +5288,10 @@ FileNode FileNode::operator[](int i) const
|
|||||||
i == 0 ? *this : FileNode();
|
i == 0 ? *this : FileNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
string FileNode::name() const
|
std::string FileNode::name() const
|
||||||
{
|
{
|
||||||
const char* str;
|
const char* str;
|
||||||
return !node || (str = cvGetFileNodeName(node)) == 0 ? string() : string(str);
|
return !node || (str = cvGetFileNodeName(node)) == 0 ? std::string() : std::string(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FileNode::readObj() const
|
void* FileNode::readObj() const
|
||||||
@ -5406,7 +5406,7 @@ FileNodeIterator& FileNodeIterator::operator -= (int ofs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileNodeIterator& FileNodeIterator::readRaw( const string& fmt, uchar* vec, size_t maxCount )
|
FileNodeIterator& FileNodeIterator::readRaw( const std::string& fmt, uchar* vec, size_t maxCount )
|
||||||
{
|
{
|
||||||
if( fs && container && remaining > 0 )
|
if( fs && container && remaining > 0 )
|
||||||
{
|
{
|
||||||
@ -5430,16 +5430,16 @@ FileNodeIterator& FileNodeIterator::readRaw( const string& fmt, uchar* vec, size
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void write( FileStorage& fs, const string& name, int value )
|
void write( FileStorage& fs, const std::string& name, int value )
|
||||||
{ cvWriteInt( *fs, name.size() ? name.c_str() : 0, value ); }
|
{ cvWriteInt( *fs, name.size() ? name.c_str() : 0, value ); }
|
||||||
|
|
||||||
void write( FileStorage& fs, const string& name, float value )
|
void write( FileStorage& fs, const std::string& name, float value )
|
||||||
{ cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); }
|
{ cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); }
|
||||||
|
|
||||||
void write( FileStorage& fs, const string& name, double value )
|
void write( FileStorage& fs, const std::string& name, double value )
|
||||||
{ cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); }
|
{ cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); }
|
||||||
|
|
||||||
void write( FileStorage& fs, const string& name, const string& value )
|
void write( FileStorage& fs, const std::string& name, const std::string& value )
|
||||||
{ cvWriteString( *fs, name.size() ? name.c_str() : 0, value.c_str() ); }
|
{ cvWriteString( *fs, name.size() ? name.c_str() : 0, value.c_str() ); }
|
||||||
|
|
||||||
void writeScalar(FileStorage& fs, int value )
|
void writeScalar(FileStorage& fs, int value )
|
||||||
@ -5451,11 +5451,11 @@ void writeScalar(FileStorage& fs, float value )
|
|||||||
void writeScalar(FileStorage& fs, double value )
|
void writeScalar(FileStorage& fs, double value )
|
||||||
{ cvWriteReal( *fs, 0, value ); }
|
{ cvWriteReal( *fs, 0, value ); }
|
||||||
|
|
||||||
void writeScalar(FileStorage& fs, const string& value )
|
void writeScalar(FileStorage& fs, const std::string& value )
|
||||||
{ cvWriteString( *fs, 0, value.c_str() ); }
|
{ cvWriteString( *fs, 0, value.c_str() ); }
|
||||||
|
|
||||||
|
|
||||||
void write( FileStorage& fs, const string& name, const Mat& value )
|
void write( FileStorage& fs, const std::string& name, const Mat& value )
|
||||||
{
|
{
|
||||||
if( value.dims <= 2 )
|
if( value.dims <= 2 )
|
||||||
{
|
{
|
||||||
@ -5470,15 +5470,15 @@ void write( FileStorage& fs, const string& name, const Mat& value )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: the 4 functions below need to be implemented more efficiently
|
// TODO: the 4 functions below need to be implemented more efficiently
|
||||||
void write( FileStorage& fs, const string& name, const SparseMat& value )
|
void write( FileStorage& fs, const std::string& name, const SparseMat& value )
|
||||||
{
|
{
|
||||||
Ptr<CvSparseMat> mat = (CvSparseMat*)value;
|
Ptr<CvSparseMat> mat = (CvSparseMat*)value;
|
||||||
cvWrite( *fs, name.size() ? name.c_str() : 0, mat );
|
cvWrite( *fs, name.size() ? name.c_str() : 0, mat );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WriteStructContext::WriteStructContext(FileStorage& _fs, const string& name,
|
WriteStructContext::WriteStructContext(FileStorage& _fs, const std::string& name,
|
||||||
int flags, const string& typeName) : fs(&_fs)
|
int flags, const std::string& typeName) : fs(&_fs)
|
||||||
{
|
{
|
||||||
cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags,
|
cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags,
|
||||||
!typeName.empty() ? typeName.c_str() : 0);
|
!typeName.empty() ? typeName.c_str() : 0);
|
||||||
|
@ -537,13 +537,13 @@ void RNG::fill( InputOutputArray _mat, int disttype,
|
|||||||
ip = (Vec2i*)(parambuf + cn*2);
|
ip = (Vec2i*)(parambuf + cn*2);
|
||||||
for( j = 0, fast_int_mode = 1; j < cn; j++ )
|
for( j = 0, fast_int_mode = 1; j < cn; j++ )
|
||||||
{
|
{
|
||||||
double a = min(p1[j], p2[j]);
|
double a = std::min(p1[j], p2[j]);
|
||||||
double b = max(p1[j], p2[j]);
|
double b = std::max(p1[j], p2[j]);
|
||||||
if( saturateRange )
|
if( saturateRange )
|
||||||
{
|
{
|
||||||
a = max(a, depth == CV_8U || depth == CV_16U ? 0. :
|
a = std::max(a, depth == CV_8U || depth == CV_16U ? 0. :
|
||||||
depth == CV_8S ? -128. : depth == CV_16S ? -32768. : (double)INT_MIN);
|
depth == CV_8S ? -128. : depth == CV_16S ? -32768. : (double)INT_MIN);
|
||||||
b = min(b, depth == CV_8U ? 256. : depth == CV_16U ? 65536. :
|
b = std::min(b, depth == CV_8U ? 256. : depth == CV_16U ? 65536. :
|
||||||
depth == CV_8S ? 128. : depth == CV_16S ? 32768. : (double)INT_MAX);
|
depth == CV_8S ? 128. : depth == CV_16S ? 32768. : (double)INT_MAX);
|
||||||
}
|
}
|
||||||
ip[j][1] = cvCeil(a);
|
ip[j][1] = cvCeil(a);
|
||||||
@ -573,8 +573,8 @@ void RNG::fill( InputOutputArray _mat, int disttype,
|
|||||||
while(((uint64)1 << l) < d)
|
while(((uint64)1 << l) < d)
|
||||||
l++;
|
l++;
|
||||||
ds[j].M = (unsigned)(((uint64)1 << 32)*(((uint64)1 << l) - d)/d) + 1;
|
ds[j].M = (unsigned)(((uint64)1 << 32)*(((uint64)1 << l) - d)/d) + 1;
|
||||||
ds[j].sh1 = min(l, 1);
|
ds[j].sh1 = std::min(l, 1);
|
||||||
ds[j].sh2 = max(l - 1, 0);
|
ds[j].sh2 = std::max(l - 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ namespace cv
|
|||||||
|
|
||||||
Exception::Exception() { code = 0; line = 0; }
|
Exception::Exception() { code = 0; line = 0; }
|
||||||
|
|
||||||
Exception::Exception(int _code, const string& _err, const string& _func, const string& _file, int _line)
|
Exception::Exception(int _code, const std::string& _err, const std::string& _func, const std::string& _file, int _line)
|
||||||
: code(_code), err(_err), func(_func), file(_file), line(_line)
|
: code(_code), err(_err), func(_func), file(_file), line(_line)
|
||||||
{
|
{
|
||||||
formatMessage();
|
formatMessage();
|
||||||
@ -348,19 +348,19 @@ const std::string& getBuildInformation()
|
|||||||
return build_info;
|
return build_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
string format( const char* fmt, ... )
|
std::string format( const char* fmt, ... )
|
||||||
{
|
{
|
||||||
char buf[1 << 16];
|
char buf[1 << 16];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start( args, fmt );
|
va_start( args, fmt );
|
||||||
vsprintf( buf, fmt, args );
|
vsprintf( buf, fmt, args );
|
||||||
return string(buf);
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
string tempfile( const char* suffix )
|
std::string tempfile( const char* suffix )
|
||||||
{
|
{
|
||||||
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||||
string fname;
|
std::string fname;
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
char temp_dir2[MAX_PATH + 1] = { 0 };
|
char temp_dir2[MAX_PATH + 1] = { 0 };
|
||||||
@ -372,7 +372,7 @@ string tempfile( const char* suffix )
|
|||||||
temp_dir = temp_dir2;
|
temp_dir = temp_dir2;
|
||||||
}
|
}
|
||||||
if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file))
|
if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file))
|
||||||
return string();
|
return std::string();
|
||||||
|
|
||||||
DeleteFileA(temp_file);
|
DeleteFileA(temp_file);
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ string tempfile( const char* suffix )
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int fd = mkstemp((char*)fname.c_str());
|
const int fd = mkstemp((char*)fname.c_str());
|
||||||
if (fd == -1) return string();
|
if (fd == -1) return std::string();
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
remove(fname.c_str());
|
remove(fname.c_str());
|
||||||
|
@ -85,12 +85,12 @@ public:
|
|||||||
size_t hash() const;
|
size_t hash() const;
|
||||||
|
|
||||||
//! converts vector of keypoints to vector of points
|
//! converts vector of keypoints to vector of points
|
||||||
static void convert(const vector<KeyPoint>& keypoints,
|
static void convert(const std::vector<KeyPoint>& keypoints,
|
||||||
CV_OUT vector<Point2f>& points2f,
|
CV_OUT std::vector<Point2f>& points2f,
|
||||||
const vector<int>& keypointIndexes=vector<int>());
|
const std::vector<int>& keypointIndexes=std::vector<int>());
|
||||||
//! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation
|
//! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation
|
||||||
static void convert(const vector<Point2f>& points2f,
|
static void convert(const std::vector<Point2f>& points2f,
|
||||||
CV_OUT vector<KeyPoint>& keypoints,
|
CV_OUT std::vector<KeyPoint>& keypoints,
|
||||||
float size=1, float response=1, int octave=0, int class_id=-1);
|
float size=1, float response=1, int octave=0, int class_id=-1);
|
||||||
|
|
||||||
//! computes overlap for pair of keypoints;
|
//! computes overlap for pair of keypoints;
|
||||||
@ -109,9 +109,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! writes vector of keypoints to the file storage
|
//! writes vector of keypoints to the file storage
|
||||||
CV_EXPORTS void write(FileStorage& fs, const string& name, const vector<KeyPoint>& keypoints);
|
CV_EXPORTS void write(FileStorage& fs, const std::string& name, const std::vector<KeyPoint>& keypoints);
|
||||||
//! reads vector of keypoints from the specified file storage node
|
//! reads vector of keypoints from the specified file storage node
|
||||||
CV_EXPORTS void read(const FileNode& node, CV_OUT vector<KeyPoint>& keypoints);
|
CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector<KeyPoint>& keypoints);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A class filters a vector of keypoints.
|
* A class filters a vector of keypoints.
|
||||||
@ -126,25 +126,25 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Remove keypoints within borderPixels of an image edge.
|
* Remove keypoints within borderPixels of an image edge.
|
||||||
*/
|
*/
|
||||||
static void runByImageBorder( vector<KeyPoint>& keypoints, Size imageSize, int borderSize );
|
static void runByImageBorder( std::vector<KeyPoint>& keypoints, Size imageSize, int borderSize );
|
||||||
/*
|
/*
|
||||||
* Remove keypoints of sizes out of range.
|
* Remove keypoints of sizes out of range.
|
||||||
*/
|
*/
|
||||||
static void runByKeypointSize( vector<KeyPoint>& keypoints, float minSize,
|
static void runByKeypointSize( std::vector<KeyPoint>& keypoints, float minSize,
|
||||||
float maxSize=FLT_MAX );
|
float maxSize=FLT_MAX );
|
||||||
/*
|
/*
|
||||||
* Remove keypoints from some image by mask for pixels of this image.
|
* Remove keypoints from some image by mask for pixels of this image.
|
||||||
*/
|
*/
|
||||||
static void runByPixelsMask( vector<KeyPoint>& keypoints, const Mat& mask );
|
static void runByPixelsMask( std::vector<KeyPoint>& keypoints, const Mat& mask );
|
||||||
/*
|
/*
|
||||||
* Remove duplicated keypoints.
|
* Remove duplicated keypoints.
|
||||||
*/
|
*/
|
||||||
static void removeDuplicated( vector<KeyPoint>& keypoints );
|
static void removeDuplicated( std::vector<KeyPoint>& keypoints );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retain the specified number of the best keypoints (according to the response)
|
* Retain the specified number of the best keypoints (according to the response)
|
||||||
*/
|
*/
|
||||||
static void retainBest( vector<KeyPoint>& keypoints, int npoints );
|
static void retainBest( std::vector<KeyPoint>& keypoints, int npoints );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public:
|
|||||||
* mask Mask specifying where to look for keypoints (optional). Must be a char
|
* mask Mask specifying where to look for keypoints (optional). Must be a char
|
||||||
* matrix with non-zero values in the region of interest.
|
* matrix with non-zero values in the region of interest.
|
||||||
*/
|
*/
|
||||||
CV_WRAP void detect( const Mat& image, CV_OUT vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
CV_WRAP void detect( const Mat& image, CV_OUT std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detect keypoints in an image set.
|
* Detect keypoints in an image set.
|
||||||
@ -173,23 +173,23 @@ public:
|
|||||||
* keypoints Collection of keypoints detected in an input images. keypoints[i] is a set of keypoints detected in an images[i].
|
* keypoints Collection of keypoints detected in an input images. keypoints[i] is a set of keypoints detected in an images[i].
|
||||||
* masks Masks for image set. masks[i] is a mask for images[i].
|
* masks Masks for image set. masks[i] is a mask for images[i].
|
||||||
*/
|
*/
|
||||||
void detect( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, const vector<Mat>& masks=vector<Mat>() ) const;
|
void detect( const std::vector<Mat>& images, std::vector<std::vector<KeyPoint> >& keypoints, const std::vector<Mat>& masks=std::vector<Mat>() ) const;
|
||||||
|
|
||||||
// Return true if detector object is empty
|
// Return true if detector object is empty
|
||||||
CV_WRAP virtual bool empty() const;
|
CV_WRAP virtual bool empty() const;
|
||||||
|
|
||||||
// Create feature detector by detector name.
|
// Create feature detector by detector name.
|
||||||
CV_WRAP static Ptr<FeatureDetector> create( const string& detectorType );
|
CV_WRAP static Ptr<FeatureDetector> create( const std::string& detectorType );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const = 0;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove keypoints that are not in the mask.
|
* Remove keypoints that are not in the mask.
|
||||||
* Helper function, useful when wrapping a library call for keypoint detection that
|
* Helper function, useful when wrapping a library call for keypoint detection that
|
||||||
* does not support a mask argument.
|
* does not support a mask argument.
|
||||||
*/
|
*/
|
||||||
static void removeInvalidPoints( const Mat& mask, vector<KeyPoint>& keypoints );
|
static void removeInvalidPoints( const Mat& mask, std::vector<KeyPoint>& keypoints );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ public:
|
|||||||
* keypoints The input keypoints. Keypoints for which a descriptor cannot be computed are removed.
|
* keypoints The input keypoints. Keypoints for which a descriptor cannot be computed are removed.
|
||||||
* descriptors Copmputed descriptors. Row i is the descriptor for keypoint i.
|
* descriptors Copmputed descriptors. Row i is the descriptor for keypoint i.
|
||||||
*/
|
*/
|
||||||
CV_WRAP void compute( const Mat& image, CV_OUT CV_IN_OUT vector<KeyPoint>& keypoints, CV_OUT Mat& descriptors ) const;
|
CV_WRAP void compute( const Mat& image, CV_OUT CV_IN_OUT std::vector<KeyPoint>& keypoints, CV_OUT Mat& descriptors ) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the descriptors for a keypoints collection detected in image collection.
|
* Compute the descriptors for a keypoints collection detected in image collection.
|
||||||
@ -222,22 +222,22 @@ public:
|
|||||||
* Keypoints for which a descriptor cannot be computed are removed.
|
* Keypoints for which a descriptor cannot be computed are removed.
|
||||||
* descriptors Descriptor collection. descriptors[i] are descriptors computed for set keypoints[i].
|
* descriptors Descriptor collection. descriptors[i] are descriptors computed for set keypoints[i].
|
||||||
*/
|
*/
|
||||||
void compute( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, vector<Mat>& descriptors ) const;
|
void compute( const std::vector<Mat>& images, std::vector<std::vector<KeyPoint> >& keypoints, std::vector<Mat>& descriptors ) const;
|
||||||
|
|
||||||
CV_WRAP virtual int descriptorSize() const = 0;
|
CV_WRAP virtual int descriptorSize() const = 0;
|
||||||
CV_WRAP virtual int descriptorType() const = 0;
|
CV_WRAP virtual int descriptorType() const = 0;
|
||||||
|
|
||||||
CV_WRAP virtual bool empty() const;
|
CV_WRAP virtual bool empty() const;
|
||||||
|
|
||||||
CV_WRAP static Ptr<DescriptorExtractor> create( const string& descriptorExtractorType );
|
CV_WRAP static Ptr<DescriptorExtractor> create( const std::string& descriptorExtractorType );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const = 0;
|
virtual void computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove keypoints within borderPixels of an image edge.
|
* Remove keypoints within borderPixels of an image edge.
|
||||||
*/
|
*/
|
||||||
static void removeBorderKeypoints( vector<KeyPoint>& keypoints,
|
static void removeBorderKeypoints( std::vector<KeyPoint>& keypoints,
|
||||||
Size imageSize, int borderSize );
|
Size imageSize, int borderSize );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -259,12 +259,12 @@ public:
|
|||||||
* descriptors for the provided keypoints
|
* descriptors for the provided keypoints
|
||||||
*/
|
*/
|
||||||
CV_WRAP_AS(detectAndCompute) virtual void operator()( InputArray image, InputArray mask,
|
CV_WRAP_AS(detectAndCompute) virtual void operator()( InputArray image, InputArray mask,
|
||||||
CV_OUT vector<KeyPoint>& keypoints,
|
CV_OUT std::vector<KeyPoint>& keypoints,
|
||||||
OutputArray descriptors,
|
OutputArray descriptors,
|
||||||
bool useProvidedKeypoints=false ) const = 0;
|
bool useProvidedKeypoints=false ) const = 0;
|
||||||
|
|
||||||
// Create feature detector and descriptor extractor by name.
|
// Create feature detector and descriptor extractor by name.
|
||||||
CV_WRAP static Ptr<Feature2D> create( const string& name );
|
CV_WRAP static Ptr<Feature2D> create( const std::string& name );
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -283,10 +283,10 @@ public:
|
|||||||
int descriptorType() const;
|
int descriptorType() const;
|
||||||
|
|
||||||
// Compute the BRISK features on an image
|
// Compute the BRISK features on an image
|
||||||
void operator()(InputArray image, InputArray mask, vector<KeyPoint>& keypoints) const;
|
void operator()(InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints) const;
|
||||||
|
|
||||||
// Compute the BRISK features and descriptors on an image
|
// Compute the BRISK features and descriptors on an image
|
||||||
void operator()( InputArray image, InputArray mask, vector<KeyPoint>& keypoints,
|
void operator()( InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints,
|
||||||
OutputArray descriptors, bool useProvidedKeypoints=false ) const;
|
OutputArray descriptors, bool useProvidedKeypoints=false ) const;
|
||||||
|
|
||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
@ -304,11 +304,11 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
void computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
||||||
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
void computeKeypointsNoOrientation(InputArray image, InputArray mask, vector<KeyPoint>& keypoints) const;
|
void computeKeypointsNoOrientation(InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints) const;
|
||||||
void computeDescriptorsAndOrOrientation(InputArray image, InputArray mask, vector<KeyPoint>& keypoints,
|
void computeDescriptorsAndOrOrientation(InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints,
|
||||||
OutputArray descriptors, bool doDescriptors, bool doOrientation,
|
OutputArray descriptors, bool doDescriptors, bool doOrientation,
|
||||||
bool useProvidedKeypoints) const;
|
bool useProvidedKeypoints) const;
|
||||||
|
|
||||||
@ -377,18 +377,18 @@ public:
|
|||||||
int descriptorType() const;
|
int descriptorType() const;
|
||||||
|
|
||||||
// Compute the ORB features and descriptors on an image
|
// Compute the ORB features and descriptors on an image
|
||||||
void operator()(InputArray image, InputArray mask, vector<KeyPoint>& keypoints) const;
|
void operator()(InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints) const;
|
||||||
|
|
||||||
// Compute the ORB features and descriptors on an image
|
// Compute the ORB features and descriptors on an image
|
||||||
void operator()( InputArray image, InputArray mask, vector<KeyPoint>& keypoints,
|
void operator()( InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints,
|
||||||
OutputArray descriptors, bool useProvidedKeypoints=false ) const;
|
OutputArray descriptors, bool useProvidedKeypoints=false ) const;
|
||||||
|
|
||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
void computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
||||||
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
CV_PROP_RW int nfeatures;
|
CV_PROP_RW int nfeatures;
|
||||||
CV_PROP_RW double scaleFactor;
|
CV_PROP_RW double scaleFactor;
|
||||||
@ -420,7 +420,7 @@ public:
|
|||||||
bool scaleNormalized = true,
|
bool scaleNormalized = true,
|
||||||
float patternScale = 22.0f,
|
float patternScale = 22.0f,
|
||||||
int nOctaves = 4,
|
int nOctaves = 4,
|
||||||
const vector<int>& selectedPairs = vector<int>());
|
const std::vector<int>& selectedPairs = std::vector<int>());
|
||||||
FREAK( const FREAK& rhs );
|
FREAK( const FREAK& rhs );
|
||||||
FREAK& operator=( const FREAK& );
|
FREAK& operator=( const FREAK& );
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ public:
|
|||||||
* @param verbose print construction information
|
* @param verbose print construction information
|
||||||
* @return list of best pair indexes
|
* @return list of best pair indexes
|
||||||
*/
|
*/
|
||||||
vector<int> selectPairs( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints,
|
std::vector<int> selectPairs( const std::vector<Mat>& images, std::vector<std::vector<KeyPoint> >& keypoints,
|
||||||
const double corrThresh = 0.7, bool verbose = true );
|
const double corrThresh = 0.7, bool verbose = true );
|
||||||
|
|
||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
@ -450,7 +450,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
virtual void computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
||||||
void buildPattern();
|
void buildPattern();
|
||||||
uchar meanIntensity( const Mat& image, const Mat& integral, const float kp_x, const float kp_y,
|
uchar meanIntensity( const Mat& image, const Mat& integral, const float kp_x, const float kp_y,
|
||||||
const unsigned int scale, const unsigned int rot, const unsigned int point ) const;
|
const unsigned int scale, const unsigned int rot, const unsigned int point ) const;
|
||||||
@ -463,7 +463,7 @@ protected:
|
|||||||
|
|
||||||
double patternScale0;
|
double patternScale0;
|
||||||
int nOctaves0;
|
int nOctaves0;
|
||||||
vector<int> selectedPairs0;
|
std::vector<int> selectedPairs0;
|
||||||
|
|
||||||
struct PatternPoint
|
struct PatternPoint
|
||||||
{
|
{
|
||||||
@ -486,7 +486,7 @@ protected:
|
|||||||
int weight_dy; // dy/(norm_sq))*4096
|
int weight_dy; // dy/(norm_sq))*4096
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<PatternPoint> patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation)
|
std::vector<PatternPoint> patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation)
|
||||||
int patternSizes[NB_SCALES]; // size of the pattern at a specific scale (used to check if a point is within image boundaries)
|
int patternSizes[NB_SCALES]; // size of the pattern at a specific scale (used to check if a point is within image boundaries)
|
||||||
DescriptionPair descriptionPairs[NB_PAIRS];
|
DescriptionPair descriptionPairs[NB_PAIRS];
|
||||||
OrientationPair orientationPairs[NB_ORIENPAIRS];
|
OrientationPair orientationPairs[NB_ORIENPAIRS];
|
||||||
@ -512,12 +512,12 @@ public:
|
|||||||
double _min_margin=0.003, int _edge_blur_size=5 );
|
double _min_margin=0.003, int _edge_blur_size=5 );
|
||||||
|
|
||||||
//! the operator that extracts the MSERs from the image or the specific part of it
|
//! the operator that extracts the MSERs from the image or the specific part of it
|
||||||
CV_WRAP_AS(detect) void operator()( const Mat& image, CV_OUT vector<vector<Point> >& msers,
|
CV_WRAP_AS(detect) void operator()( const Mat& image, CV_OUT std::vector<std::vector<Point> >& msers,
|
||||||
const Mat& mask=Mat() ) const;
|
const Mat& mask=Mat() ) const;
|
||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
int delta;
|
int delta;
|
||||||
int minArea;
|
int minArea;
|
||||||
@ -548,12 +548,12 @@ public:
|
|||||||
|
|
||||||
//! finds the keypoints in the image
|
//! finds the keypoints in the image
|
||||||
CV_WRAP_AS(detect) void operator()(const Mat& image,
|
CV_WRAP_AS(detect) void operator()(const Mat& image,
|
||||||
CV_OUT vector<KeyPoint>& keypoints) const;
|
CV_OUT std::vector<KeyPoint>& keypoints) const;
|
||||||
|
|
||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
int maxSize;
|
int maxSize;
|
||||||
int responseThreshold;
|
int responseThreshold;
|
||||||
@ -563,10 +563,10 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! detects corners using FAST algorithm by E. Rosten
|
//! detects corners using FAST algorithm by E. Rosten
|
||||||
CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
|
CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
|
||||||
int threshold, bool nonmaxSupression=true );
|
int threshold, bool nonmaxSupression=true );
|
||||||
|
|
||||||
CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
|
CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
|
||||||
int threshold, bool nonmaxSupression, int type );
|
int threshold, bool nonmaxSupression, int type );
|
||||||
|
|
||||||
class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector
|
class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector
|
||||||
@ -582,7 +582,7 @@ public:
|
|||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
int threshold;
|
int threshold;
|
||||||
bool nonmaxSuppression;
|
bool nonmaxSuppression;
|
||||||
@ -598,7 +598,7 @@ public:
|
|||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
int nfeatures;
|
int nfeatures;
|
||||||
double qualityLevel;
|
double qualityLevel;
|
||||||
@ -655,8 +655,8 @@ protected:
|
|||||||
double confidence;
|
double confidence;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
virtual void findBlobs(const Mat &image, const Mat &binaryImage, vector<Center> ¢ers) const;
|
virtual void findBlobs(const Mat &image, const Mat &binaryImage, std::vector<Center> ¢ers) const;
|
||||||
|
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
@ -673,7 +673,7 @@ public:
|
|||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
double initFeatureScale;
|
double initFeatureScale;
|
||||||
int featureScaleLevels;
|
int featureScaleLevels;
|
||||||
@ -710,7 +710,7 @@ public:
|
|||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
Ptr<FeatureDetector> detector;
|
Ptr<FeatureDetector> detector;
|
||||||
int maxTotalKeypoints;
|
int maxTotalKeypoints;
|
||||||
@ -732,7 +732,7 @@ public:
|
|||||||
virtual bool empty() const;
|
virtual bool empty() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
Ptr<FeatureDetector> detector;
|
Ptr<FeatureDetector> detector;
|
||||||
int maxLevel;
|
int maxLevel;
|
||||||
@ -764,7 +764,7 @@ public:
|
|||||||
|
|
||||||
virtual Ptr<AdjusterAdapter> clone() const = 0;
|
virtual Ptr<AdjusterAdapter> clone() const = 0;
|
||||||
|
|
||||||
static Ptr<AdjusterAdapter> create( const string& detectorType );
|
static Ptr<AdjusterAdapter> create( const std::string& detectorType );
|
||||||
};
|
};
|
||||||
/** \brief an adaptively adjusting detector that iteratively detects until the desired number
|
/** \brief an adaptively adjusting detector that iteratively detects until the desired number
|
||||||
* of features are detected.
|
* of features are detected.
|
||||||
@ -793,7 +793,7 @@ public:
|
|||||||
virtual bool empty() const;
|
virtual bool empty() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynamicAdaptedFeatureDetector& operator=(const DynamicAdaptedFeatureDetector&);
|
DynamicAdaptedFeatureDetector& operator=(const DynamicAdaptedFeatureDetector&);
|
||||||
@ -822,7 +822,7 @@ public:
|
|||||||
virtual Ptr<AdjusterAdapter> clone() const;
|
virtual Ptr<AdjusterAdapter> clone() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
int thresh_;
|
int thresh_;
|
||||||
bool nonmax_;
|
bool nonmax_;
|
||||||
@ -845,7 +845,7 @@ public:
|
|||||||
virtual Ptr<AdjusterAdapter> clone() const;
|
virtual Ptr<AdjusterAdapter> clone() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
double thresh_, init_thresh_, min_thresh_, max_thresh_;
|
double thresh_, init_thresh_, min_thresh_, max_thresh_;
|
||||||
};
|
};
|
||||||
@ -862,12 +862,12 @@ public:
|
|||||||
virtual Ptr<AdjusterAdapter> clone() const;
|
virtual Ptr<AdjusterAdapter> clone() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
double thresh_, init_thresh_, min_thresh_, max_thresh_;
|
double thresh_, init_thresh_, min_thresh_, max_thresh_;
|
||||||
};
|
};
|
||||||
|
|
||||||
CV_EXPORTS Mat windowedMatchingMask( const vector<KeyPoint>& keypoints1, const vector<KeyPoint>& keypoints2,
|
CV_EXPORTS Mat windowedMatchingMask( const std::vector<KeyPoint>& keypoints1, const std::vector<KeyPoint>& keypoints2,
|
||||||
float maxDeltaX, float maxDeltaY );
|
float maxDeltaX, float maxDeltaY );
|
||||||
|
|
||||||
|
|
||||||
@ -895,7 +895,7 @@ public:
|
|||||||
virtual bool empty() const;
|
virtual bool empty() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
virtual void computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
||||||
|
|
||||||
Ptr<DescriptorExtractor> descriptorExtractor;
|
Ptr<DescriptorExtractor> descriptorExtractor;
|
||||||
};
|
};
|
||||||
@ -923,9 +923,9 @@ public:
|
|||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void computeImpl(const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors) const;
|
virtual void computeImpl(const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors) const;
|
||||||
|
|
||||||
typedef void(*PixelTestFn)(const Mat&, const vector<KeyPoint>&, Mat&);
|
typedef void(*PixelTestFn)(const Mat&, const std::vector<KeyPoint>&, Mat&);
|
||||||
|
|
||||||
int bytes_;
|
int bytes_;
|
||||||
PixelTestFn test_fn_;
|
PixelTestFn test_fn_;
|
||||||
@ -975,7 +975,7 @@ struct CV_EXPORTS L2
|
|||||||
|
|
||||||
ResultType operator()( const T* a, const T* b, int size ) const
|
ResultType operator()( const T* a, const T* b, int size ) const
|
||||||
{
|
{
|
||||||
return (ResultType)sqrt((double)normL2Sqr<ValueType, ResultType>(a, b, size));
|
return (ResultType)std::sqrt((double)normL2Sqr<ValueType, ResultType>(a, b, size));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1069,11 +1069,11 @@ public:
|
|||||||
* Add descriptors to train descriptor collection.
|
* Add descriptors to train descriptor collection.
|
||||||
* descriptors Descriptors to add. Each descriptors[i] is a descriptors set from one image.
|
* descriptors Descriptors to add. Each descriptors[i] is a descriptors set from one image.
|
||||||
*/
|
*/
|
||||||
CV_WRAP virtual void add( const vector<Mat>& descriptors );
|
CV_WRAP virtual void add( const std::vector<Mat>& descriptors );
|
||||||
/*
|
/*
|
||||||
* Get train descriptors collection.
|
* Get train descriptors collection.
|
||||||
*/
|
*/
|
||||||
CV_WRAP const vector<Mat>& getTrainDescriptors() const;
|
CV_WRAP const std::vector<Mat>& getTrainDescriptors() const;
|
||||||
/*
|
/*
|
||||||
* Clear train descriptors collection.
|
* Clear train descriptors collection.
|
||||||
*/
|
*/
|
||||||
@ -1106,29 +1106,29 @@ public:
|
|||||||
*/
|
*/
|
||||||
// Find one best match for each query descriptor (if mask is empty).
|
// Find one best match for each query descriptor (if mask is empty).
|
||||||
CV_WRAP void match( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
CV_WRAP void match( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
||||||
CV_OUT vector<DMatch>& matches, const Mat& mask=Mat() ) const;
|
CV_OUT std::vector<DMatch>& matches, const Mat& mask=Mat() ) const;
|
||||||
// Find k best matches for each query descriptor (in increasing order of distances).
|
// Find k best matches for each query descriptor (in increasing order of distances).
|
||||||
// compactResult is used when mask is not empty. If compactResult is false matches
|
// compactResult is used when mask is not empty. If compactResult is false matches
|
||||||
// vector will have the same size as queryDescriptors rows. If compactResult is true
|
// vector will have the same size as queryDescriptors rows. If compactResult is true
|
||||||
// matches vector will not contain matches for fully masked out query descriptors.
|
// matches vector will not contain matches for fully masked out query descriptors.
|
||||||
CV_WRAP void knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
CV_WRAP void knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
||||||
CV_OUT vector<vector<DMatch> >& matches, int k,
|
CV_OUT std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const Mat& mask=Mat(), bool compactResult=false ) const;
|
const Mat& mask=Mat(), bool compactResult=false ) const;
|
||||||
// Find best matches for each query descriptor which have distance less than
|
// Find best matches for each query descriptor which have distance less than
|
||||||
// maxDistance (in increasing order of distances).
|
// maxDistance (in increasing order of distances).
|
||||||
void radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
void radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const Mat& mask=Mat(), bool compactResult=false ) const;
|
const Mat& mask=Mat(), bool compactResult=false ) const;
|
||||||
/*
|
/*
|
||||||
* Group of methods to match descriptors from one image to image set.
|
* Group of methods to match descriptors from one image to image set.
|
||||||
* See description of similar methods for matching image pair above.
|
* See description of similar methods for matching image pair above.
|
||||||
*/
|
*/
|
||||||
CV_WRAP void match( const Mat& queryDescriptors, CV_OUT vector<DMatch>& matches,
|
CV_WRAP void match( const Mat& queryDescriptors, CV_OUT std::vector<DMatch>& matches,
|
||||||
const vector<Mat>& masks=vector<Mat>() );
|
const std::vector<Mat>& masks=std::vector<Mat>() );
|
||||||
CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT vector<vector<DMatch> >& matches, int k,
|
CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
void radiusMatch( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
|
void radiusMatch( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
|
|
||||||
// Reads matcher object from a file node
|
// Reads matcher object from a file node
|
||||||
virtual void read( const FileNode& );
|
virtual void read( const FileNode& );
|
||||||
@ -1140,7 +1140,7 @@ public:
|
|||||||
// but with empty train data.
|
// but with empty train data.
|
||||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
||||||
|
|
||||||
CV_WRAP static Ptr<DescriptorMatcher> create( const string& descriptorMatcherType );
|
CV_WRAP static Ptr<DescriptorMatcher> create( const std::string& descriptorMatcherType );
|
||||||
protected:
|
protected:
|
||||||
/*
|
/*
|
||||||
* Class to work with descriptors from several images as with one merged matrix.
|
* Class to work with descriptors from several images as with one merged matrix.
|
||||||
@ -1154,7 +1154,7 @@ protected:
|
|||||||
virtual ~DescriptorCollection();
|
virtual ~DescriptorCollection();
|
||||||
|
|
||||||
// Vector of matrices "descriptors" will be merged to one matrix "mergedDescriptors" here.
|
// Vector of matrices "descriptors" will be merged to one matrix "mergedDescriptors" here.
|
||||||
void set( const vector<Mat>& descriptors );
|
void set( const std::vector<Mat>& descriptors );
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
const Mat& getDescriptors() const;
|
const Mat& getDescriptors() const;
|
||||||
@ -1166,25 +1166,25 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Mat mergedDescriptors;
|
Mat mergedDescriptors;
|
||||||
vector<int> startIdxs;
|
std::vector<int> startIdxs;
|
||||||
};
|
};
|
||||||
|
|
||||||
// In fact the matching is implemented only by the following two methods. These methods suppose
|
// In fact the matching is implemented only by the following two methods. These methods suppose
|
||||||
// that the class object has been trained already. Public match methods call these methods
|
// that the class object has been trained already. Public match methods call these methods
|
||||||
// after calling train().
|
// after calling train().
|
||||||
virtual void knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k,
|
virtual void knnMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false ) = 0;
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false ) = 0;
|
||||||
virtual void radiusMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
|
virtual void radiusMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false ) = 0;
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false ) = 0;
|
||||||
|
|
||||||
static bool isPossibleMatch( const Mat& mask, int queryIdx, int trainIdx );
|
static bool isPossibleMatch( const Mat& mask, int queryIdx, int trainIdx );
|
||||||
static bool isMaskedOut( const vector<Mat>& masks, int queryIdx );
|
static bool isMaskedOut( const std::vector<Mat>& masks, int queryIdx );
|
||||||
|
|
||||||
static Mat clone_op( Mat m ) { return m.clone(); }
|
static Mat clone_op( Mat m ) { return m.clone(); }
|
||||||
void checkMasks( const vector<Mat>& masks, int queryDescriptorsCount ) const;
|
void checkMasks( const std::vector<Mat>& masks, int queryDescriptorsCount ) const;
|
||||||
|
|
||||||
// Collection of descriptors from train images.
|
// Collection of descriptors from train images.
|
||||||
vector<Mat> trainDescCollection;
|
std::vector<Mat> trainDescCollection;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1208,10 +1208,10 @@ public:
|
|||||||
|
|
||||||
AlgorithmInfo* info() const;
|
AlgorithmInfo* info() const;
|
||||||
protected:
|
protected:
|
||||||
virtual void knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k,
|
virtual void knnMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
virtual void radiusMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
|
virtual void radiusMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
|
|
||||||
int normType;
|
int normType;
|
||||||
bool crossCheck;
|
bool crossCheck;
|
||||||
@ -1227,7 +1227,7 @@ public:
|
|||||||
CV_WRAP FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=new flann::KDTreeIndexParams(),
|
CV_WRAP FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=new flann::KDTreeIndexParams(),
|
||||||
const Ptr<flann::SearchParams>& searchParams=new flann::SearchParams() );
|
const Ptr<flann::SearchParams>& searchParams=new flann::SearchParams() );
|
||||||
|
|
||||||
virtual void add( const vector<Mat>& descriptors );
|
virtual void add( const std::vector<Mat>& descriptors );
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
// Reads matcher object from a file node
|
// Reads matcher object from a file node
|
||||||
@ -1244,12 +1244,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
static void convertToDMatches( const DescriptorCollection& descriptors,
|
static void convertToDMatches( const DescriptorCollection& descriptors,
|
||||||
const Mat& indices, const Mat& distances,
|
const Mat& indices, const Mat& distances,
|
||||||
vector<vector<DMatch> >& matches );
|
std::vector<std::vector<DMatch> >& matches );
|
||||||
|
|
||||||
virtual void knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k,
|
virtual void knnMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
virtual void radiusMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
|
virtual void radiusMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
|
|
||||||
Ptr<flann::IndexParams> indexParams;
|
Ptr<flann::IndexParams> indexParams;
|
||||||
Ptr<flann::SearchParams> searchParams;
|
Ptr<flann::SearchParams> searchParams;
|
||||||
@ -1284,11 +1284,11 @@ public:
|
|||||||
* If inheritor class need perform such prefiltering the method add() must be overloaded.
|
* If inheritor class need perform such prefiltering the method add() must be overloaded.
|
||||||
* In the other class methods programmer has access to the train keypoints by a constant link.
|
* In the other class methods programmer has access to the train keypoints by a constant link.
|
||||||
*/
|
*/
|
||||||
virtual void add( const vector<Mat>& images,
|
virtual void add( const std::vector<Mat>& images,
|
||||||
vector<vector<KeyPoint> >& keypoints );
|
std::vector<std::vector<KeyPoint> >& keypoints );
|
||||||
|
|
||||||
const vector<Mat>& getTrainImages() const;
|
const std::vector<Mat>& getTrainImages() const;
|
||||||
const vector<vector<KeyPoint> >& getTrainKeypoints() const;
|
const std::vector<std::vector<KeyPoint> >& getTrainKeypoints() const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear images and keypoints storing in train collection.
|
* Clear images and keypoints storing in train collection.
|
||||||
@ -1313,10 +1313,10 @@ public:
|
|||||||
* trainKeypoints Keypoints from the train image
|
* trainKeypoints Keypoints from the train image
|
||||||
*/
|
*/
|
||||||
// Classify keypoints from query image under one train image.
|
// Classify keypoints from query image under one train image.
|
||||||
void classify( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void classify( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints ) const;
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints ) const;
|
||||||
// Classify keypoints from query image under train image collection.
|
// Classify keypoints from query image under train image collection.
|
||||||
void classify( const Mat& queryImage, vector<KeyPoint>& queryKeypoints );
|
void classify( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Group of methods to match keypoints from image pair.
|
* Group of methods to match keypoints from image pair.
|
||||||
@ -1324,34 +1324,34 @@ public:
|
|||||||
* train() method is called here.
|
* train() method is called here.
|
||||||
*/
|
*/
|
||||||
// Find one best match for each query descriptor (if mask is empty).
|
// Find one best match for each query descriptor (if mask is empty).
|
||||||
void match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void match( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints,
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
|
||||||
vector<DMatch>& matches, const Mat& mask=Mat() ) const;
|
std::vector<DMatch>& matches, const Mat& mask=Mat() ) const;
|
||||||
// Find k best matches for each query keypoint (in increasing order of distances).
|
// Find k best matches for each query keypoint (in increasing order of distances).
|
||||||
// compactResult is used when mask is not empty. If compactResult is false matches
|
// compactResult is used when mask is not empty. If compactResult is false matches
|
||||||
// vector will have the same size as queryDescriptors rows.
|
// vector will have the same size as queryDescriptors rows.
|
||||||
// If compactResult is true matches vector will not contain matches for fully masked out query descriptors.
|
// If compactResult is true matches vector will not contain matches for fully masked out query descriptors.
|
||||||
void knnMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void knnMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints,
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
|
||||||
vector<vector<DMatch> >& matches, int k,
|
std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const Mat& mask=Mat(), bool compactResult=false ) const;
|
const Mat& mask=Mat(), bool compactResult=false ) const;
|
||||||
// Find best matches for each query descriptor which have distance less than maxDistance (in increasing order of distances).
|
// Find best matches for each query descriptor which have distance less than maxDistance (in increasing order of distances).
|
||||||
void radiusMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void radiusMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints,
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const Mat& mask=Mat(), bool compactResult=false ) const;
|
const Mat& mask=Mat(), bool compactResult=false ) const;
|
||||||
/*
|
/*
|
||||||
* Group of methods to match keypoints from one image to image set.
|
* Group of methods to match keypoints from one image to image set.
|
||||||
* See description of similar methods for matching image pair above.
|
* See description of similar methods for matching image pair above.
|
||||||
*/
|
*/
|
||||||
void match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void match( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<DMatch>& matches, const vector<Mat>& masks=vector<Mat>() );
|
std::vector<DMatch>& matches, const std::vector<Mat>& masks=std::vector<Mat>() );
|
||||||
void knnMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void knnMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, int k,
|
std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
void radiusMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void radiusMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false );
|
||||||
|
|
||||||
// Reads matcher object from a file node
|
// Reads matcher object from a file node
|
||||||
virtual void read( const FileNode& fn );
|
virtual void read( const FileNode& fn );
|
||||||
@ -1366,19 +1366,19 @@ public:
|
|||||||
// but with empty train data.
|
// but with empty train data.
|
||||||
virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
||||||
|
|
||||||
static Ptr<GenericDescriptorMatcher> create( const string& genericDescritptorMatcherType,
|
static Ptr<GenericDescriptorMatcher> create( const std::string& genericDescritptorMatcherType,
|
||||||
const string ¶msFilename=string() );
|
const std::string ¶msFilename=std::string() );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// In fact the matching is implemented only by the following two methods. These methods suppose
|
// In fact the matching is implemented only by the following two methods. These methods suppose
|
||||||
// that the class object has been trained already. Public match methods call these methods
|
// that the class object has been trained already. Public match methods call these methods
|
||||||
// after calling train().
|
// after calling train().
|
||||||
virtual void knnMatchImpl( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
virtual void knnMatchImpl( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, int k,
|
std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const vector<Mat>& masks, bool compactResult ) = 0;
|
const std::vector<Mat>& masks, bool compactResult ) = 0;
|
||||||
virtual void radiusMatchImpl( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
virtual void radiusMatchImpl( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks, bool compactResult ) = 0;
|
const std::vector<Mat>& masks, bool compactResult ) = 0;
|
||||||
/*
|
/*
|
||||||
* A storage for sets of keypoints together with corresponding images and class IDs
|
* A storage for sets of keypoints together with corresponding images and class IDs
|
||||||
*/
|
*/
|
||||||
@ -1387,29 +1387,29 @@ protected:
|
|||||||
public:
|
public:
|
||||||
KeyPointCollection();
|
KeyPointCollection();
|
||||||
KeyPointCollection( const KeyPointCollection& collection );
|
KeyPointCollection( const KeyPointCollection& collection );
|
||||||
void add( const vector<Mat>& images, const vector<vector<KeyPoint> >& keypoints );
|
void add( const std::vector<Mat>& images, const std::vector<std::vector<KeyPoint> >& keypoints );
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// Returns the total number of keypoints in the collection
|
// Returns the total number of keypoints in the collection
|
||||||
size_t keypointCount() const;
|
size_t keypointCount() const;
|
||||||
size_t imageCount() const;
|
size_t imageCount() const;
|
||||||
|
|
||||||
const vector<vector<KeyPoint> >& getKeypoints() const;
|
const std::vector<std::vector<KeyPoint> >& getKeypoints() const;
|
||||||
const vector<KeyPoint>& getKeypoints( int imgIdx ) const;
|
const std::vector<KeyPoint>& getKeypoints( int imgIdx ) const;
|
||||||
const KeyPoint& getKeyPoint( int imgIdx, int localPointIdx ) const;
|
const KeyPoint& getKeyPoint( int imgIdx, int localPointIdx ) const;
|
||||||
const KeyPoint& getKeyPoint( int globalPointIdx ) const;
|
const KeyPoint& getKeyPoint( int globalPointIdx ) const;
|
||||||
void getLocalIdx( int globalPointIdx, int& imgIdx, int& localPointIdx ) const;
|
void getLocalIdx( int globalPointIdx, int& imgIdx, int& localPointIdx ) const;
|
||||||
|
|
||||||
const vector<Mat>& getImages() const;
|
const std::vector<Mat>& getImages() const;
|
||||||
const Mat& getImage( int imgIdx ) const;
|
const Mat& getImage( int imgIdx ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int pointCount;
|
int pointCount;
|
||||||
|
|
||||||
vector<Mat> images;
|
std::vector<Mat> images;
|
||||||
vector<vector<KeyPoint> > keypoints;
|
std::vector<std::vector<KeyPoint> > keypoints;
|
||||||
// global indices of the first points in each image, startIndices.size() = keypoints.size()
|
// global indices of the first points in each image, startIndices.size() = keypoints.size()
|
||||||
vector<int> startIndices;
|
std::vector<int> startIndices;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Mat clone_op( Mat m ) { return m.clone(); }
|
static Mat clone_op( Mat m ) { return m.clone(); }
|
||||||
@ -1435,8 +1435,8 @@ public:
|
|||||||
VectorDescriptorMatcher( const Ptr<DescriptorExtractor>& extractor, const Ptr<DescriptorMatcher>& matcher );
|
VectorDescriptorMatcher( const Ptr<DescriptorExtractor>& extractor, const Ptr<DescriptorMatcher>& matcher );
|
||||||
virtual ~VectorDescriptorMatcher();
|
virtual ~VectorDescriptorMatcher();
|
||||||
|
|
||||||
virtual void add( const vector<Mat>& imgCollection,
|
virtual void add( const std::vector<Mat>& imgCollection,
|
||||||
vector<vector<KeyPoint> >& pointCollection );
|
std::vector<std::vector<KeyPoint> >& pointCollection );
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
@ -1451,12 +1451,12 @@ public:
|
|||||||
virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void knnMatchImpl( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
virtual void knnMatchImpl( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, int k,
|
std::vector<std::vector<DMatch> >& matches, int k,
|
||||||
const vector<Mat>& masks, bool compactResult );
|
const std::vector<Mat>& masks, bool compactResult );
|
||||||
virtual void radiusMatchImpl( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
virtual void radiusMatchImpl( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks, bool compactResult );
|
const std::vector<Mat>& masks, bool compactResult );
|
||||||
|
|
||||||
Ptr<DescriptorExtractor> extractor;
|
Ptr<DescriptorExtractor> extractor;
|
||||||
Ptr<DescriptorMatcher> matcher;
|
Ptr<DescriptorMatcher> matcher;
|
||||||
@ -1481,42 +1481,42 @@ struct CV_EXPORTS DrawMatchesFlags
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Draw keypoints.
|
// Draw keypoints.
|
||||||
CV_EXPORTS_W void drawKeypoints( const Mat& image, const vector<KeyPoint>& keypoints, CV_OUT Mat& outImage,
|
CV_EXPORTS_W void drawKeypoints( const Mat& image, const std::vector<KeyPoint>& keypoints, CV_OUT Mat& outImage,
|
||||||
const Scalar& color=Scalar::all(-1), int flags=DrawMatchesFlags::DEFAULT );
|
const Scalar& color=Scalar::all(-1), int flags=DrawMatchesFlags::DEFAULT );
|
||||||
|
|
||||||
// Draws matches of keypints from two images on output image.
|
// Draws matches of keypints from two images on output image.
|
||||||
CV_EXPORTS void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1,
|
CV_EXPORTS void drawMatches( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
|
||||||
const Mat& img2, const vector<KeyPoint>& keypoints2,
|
const Mat& img2, const std::vector<KeyPoint>& keypoints2,
|
||||||
const vector<DMatch>& matches1to2, Mat& outImg,
|
const std::vector<DMatch>& matches1to2, Mat& outImg,
|
||||||
const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1),
|
const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1),
|
||||||
const vector<char>& matchesMask=vector<char>(), int flags=DrawMatchesFlags::DEFAULT );
|
const std::vector<char>& matchesMask=std::vector<char>(), int flags=DrawMatchesFlags::DEFAULT );
|
||||||
|
|
||||||
CV_EXPORTS void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1,
|
CV_EXPORTS void drawMatches( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
|
||||||
const Mat& img2, const vector<KeyPoint>& keypoints2,
|
const Mat& img2, const std::vector<KeyPoint>& keypoints2,
|
||||||
const vector<vector<DMatch> >& matches1to2, Mat& outImg,
|
const std::vector<std::vector<DMatch> >& matches1to2, Mat& outImg,
|
||||||
const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1),
|
const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1),
|
||||||
const vector<vector<char> >& matchesMask=vector<vector<char> >(), int flags=DrawMatchesFlags::DEFAULT );
|
const std::vector<std::vector<char> >& matchesMask=std::vector<std::vector<char> >(), int flags=DrawMatchesFlags::DEFAULT );
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
* Functions to evaluate the feature detectors and [generic] descriptor extractors *
|
* Functions to evaluate the feature detectors and [generic] descriptor extractors *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
|
|
||||||
CV_EXPORTS void evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
CV_EXPORTS void evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
||||||
vector<KeyPoint>* keypoints1, vector<KeyPoint>* keypoints2,
|
std::vector<KeyPoint>* keypoints1, std::vector<KeyPoint>* keypoints2,
|
||||||
float& repeatability, int& correspCount,
|
float& repeatability, int& correspCount,
|
||||||
const Ptr<FeatureDetector>& fdetector=Ptr<FeatureDetector>() );
|
const Ptr<FeatureDetector>& fdetector=Ptr<FeatureDetector>() );
|
||||||
|
|
||||||
CV_EXPORTS void computeRecallPrecisionCurve( const vector<vector<DMatch> >& matches1to2,
|
CV_EXPORTS void computeRecallPrecisionCurve( const std::vector<std::vector<DMatch> >& matches1to2,
|
||||||
const vector<vector<uchar> >& correctMatches1to2Mask,
|
const std::vector<std::vector<uchar> >& correctMatches1to2Mask,
|
||||||
vector<Point2f>& recallPrecisionCurve );
|
std::vector<Point2f>& recallPrecisionCurve );
|
||||||
|
|
||||||
CV_EXPORTS float getRecall( const vector<Point2f>& recallPrecisionCurve, float l_precision );
|
CV_EXPORTS float getRecall( const std::vector<Point2f>& recallPrecisionCurve, float l_precision );
|
||||||
CV_EXPORTS int getNearestPoint( const vector<Point2f>& recallPrecisionCurve, float l_precision );
|
CV_EXPORTS int getNearestPoint( const std::vector<Point2f>& recallPrecisionCurve, float l_precision );
|
||||||
|
|
||||||
CV_EXPORTS void evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
CV_EXPORTS void evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
||||||
vector<KeyPoint>& keypoints1, vector<KeyPoint>& keypoints2,
|
std::vector<KeyPoint>& keypoints1, std::vector<KeyPoint>& keypoints2,
|
||||||
vector<vector<DMatch> >* matches1to2, vector<vector<uchar> >* correctMatches1to2Mask,
|
std::vector<std::vector<DMatch> >* matches1to2, std::vector<std::vector<uchar> >* correctMatches1to2Mask,
|
||||||
vector<Point2f>& recallPrecisionCurve,
|
std::vector<Point2f>& recallPrecisionCurve,
|
||||||
const Ptr<GenericDescriptorMatcher>& dmatch=Ptr<GenericDescriptorMatcher>() );
|
const Ptr<GenericDescriptorMatcher>& dmatch=Ptr<GenericDescriptorMatcher>() );
|
||||||
|
|
||||||
|
|
||||||
@ -1533,7 +1533,7 @@ public:
|
|||||||
virtual ~BOWTrainer();
|
virtual ~BOWTrainer();
|
||||||
|
|
||||||
void add( const Mat& descriptors );
|
void add( const Mat& descriptors );
|
||||||
const vector<Mat>& getDescriptors() const;
|
const std::vector<Mat>& getDescriptors() const;
|
||||||
int descripotorsCount() const;
|
int descripotorsCount() const;
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
@ -1549,7 +1549,7 @@ public:
|
|||||||
virtual Mat cluster( const Mat& descriptors ) const = 0;
|
virtual Mat cluster( const Mat& descriptors ) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
vector<Mat> descriptors;
|
std::vector<Mat> descriptors;
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1587,8 +1587,8 @@ public:
|
|||||||
|
|
||||||
void setVocabulary( const Mat& vocabulary );
|
void setVocabulary( const Mat& vocabulary );
|
||||||
const Mat& getVocabulary() const;
|
const Mat& getVocabulary() const;
|
||||||
void compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor,
|
void compute( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& imgDescriptor,
|
||||||
vector<vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 );
|
std::vector<std::vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 );
|
||||||
// compute() is not constant because DescriptorMatcher::match is not constant
|
// compute() is not constant because DescriptorMatcher::match is not constant
|
||||||
|
|
||||||
int descriptorSize() const;
|
int descriptorSize() const;
|
||||||
|
@ -9,7 +9,7 @@ using std::tr1::get;
|
|||||||
enum { TYPE_5_8 =FastFeatureDetector::TYPE_5_8, TYPE_7_12 = FastFeatureDetector::TYPE_7_12, TYPE_9_16 = FastFeatureDetector::TYPE_9_16 };
|
enum { TYPE_5_8 =FastFeatureDetector::TYPE_5_8, TYPE_7_12 = FastFeatureDetector::TYPE_7_12, TYPE_9_16 = FastFeatureDetector::TYPE_9_16 };
|
||||||
CV_ENUM(FastType, TYPE_5_8, TYPE_7_12, TYPE_9_16)
|
CV_ENUM(FastType, TYPE_5_8, TYPE_7_12, TYPE_9_16)
|
||||||
|
|
||||||
typedef std::tr1::tuple<String, FastType> File_Type_t;
|
typedef std::tr1::tuple<string, FastType> File_Type_t;
|
||||||
typedef perf::TestBaseWithParam<File_Type_t> fast;
|
typedef perf::TestBaseWithParam<File_Type_t> fast;
|
||||||
|
|
||||||
#define FAST_IMAGES \
|
#define FAST_IMAGES \
|
||||||
@ -21,7 +21,7 @@ PERF_TEST_P(fast, detect, testing::Combine(
|
|||||||
testing::ValuesIn(FastType::all())
|
testing::ValuesIn(FastType::all())
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
String filename = getDataPath(get<0>(GetParam()));
|
string filename = getDataPath(get<0>(GetParam()));
|
||||||
int type = get<1>(GetParam());
|
int type = get<1>(GetParam());
|
||||||
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ typedef perf::TestBaseWithParam<std::string> orb;
|
|||||||
|
|
||||||
PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
|
PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
|
||||||
{
|
{
|
||||||
String filename = getDataPath(GetParam());
|
string filename = getDataPath(GetParam());
|
||||||
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
||||||
|
|
||||||
if (frame.empty())
|
if (frame.empty())
|
||||||
@ -33,7 +33,7 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
|
|||||||
|
|
||||||
PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
|
PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
|
||||||
{
|
{
|
||||||
String filename = getDataPath(GetParam());
|
string filename = getDataPath(GetParam());
|
||||||
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
||||||
|
|
||||||
if (frame.empty())
|
if (frame.empty())
|
||||||
@ -56,7 +56,7 @@ PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
|
|||||||
|
|
||||||
PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
|
PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
|
||||||
{
|
{
|
||||||
String filename = getDataPath(GetParam());
|
string filename = getDataPath(GetParam());
|
||||||
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
Mat frame = imread(filename, IMREAD_GRAYSCALE);
|
||||||
|
|
||||||
if (frame.empty())
|
if (frame.empty())
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -69,7 +67,7 @@ void BOWTrainer::add( const Mat& _descriptors )
|
|||||||
descriptors.push_back(_descriptors);
|
descriptors.push_back(_descriptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<Mat>& BOWTrainer::getDescriptors() const
|
const std::vector<Mat>& BOWTrainer::getDescriptors() const
|
||||||
{
|
{
|
||||||
return descriptors;
|
return descriptors;
|
||||||
}
|
}
|
||||||
@ -130,7 +128,7 @@ void BOWImgDescriptorExtractor::setVocabulary( const Mat& _vocabulary )
|
|||||||
{
|
{
|
||||||
dmatcher->clear();
|
dmatcher->clear();
|
||||||
vocabulary = _vocabulary;
|
vocabulary = _vocabulary;
|
||||||
dmatcher->add( vector<Mat>(1, vocabulary) );
|
dmatcher->add( std::vector<Mat>(1, vocabulary) );
|
||||||
}
|
}
|
||||||
|
|
||||||
const Mat& BOWImgDescriptorExtractor::getVocabulary() const
|
const Mat& BOWImgDescriptorExtractor::getVocabulary() const
|
||||||
@ -138,8 +136,8 @@ const Mat& BOWImgDescriptorExtractor::getVocabulary() const
|
|||||||
return vocabulary;
|
return vocabulary;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOWImgDescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor,
|
void BOWImgDescriptorExtractor::compute( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& imgDescriptor,
|
||||||
vector<vector<int> >* pointIdxsOfClusters, Mat* _descriptors )
|
std::vector<std::vector<int> >* pointIdxsOfClusters, Mat* _descriptors )
|
||||||
{
|
{
|
||||||
imgDescriptor.release();
|
imgDescriptor.release();
|
||||||
|
|
||||||
@ -153,7 +151,7 @@ void BOWImgDescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& key
|
|||||||
dextractor->compute( image, keypoints, descriptors );
|
dextractor->compute( image, keypoints, descriptors );
|
||||||
|
|
||||||
// Match keypoint descriptors to cluster center (to vocabulary)
|
// Match keypoint descriptors to cluster center (to vocabulary)
|
||||||
vector<DMatch> matches;
|
std::vector<DMatch> matches;
|
||||||
dmatcher->match( descriptors, matches );
|
dmatcher->match( descriptors, matches );
|
||||||
|
|
||||||
// Compute image descriptor
|
// Compute image descriptor
|
||||||
|
@ -162,12 +162,12 @@ void SimpleBlobDetector::write( cv::FileStorage& fs ) const
|
|||||||
params.write(fs);
|
params.write(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, vector<Center> ¢ers) const
|
void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, std::vector<Center> ¢ers) const
|
||||||
{
|
{
|
||||||
(void)image;
|
(void)image;
|
||||||
centers.clear();
|
centers.clear();
|
||||||
|
|
||||||
vector < vector<Point> > contours;
|
std::vector < std::vector<Point> > contours;
|
||||||
Mat tmpBinaryImage = binaryImage.clone();
|
Mat tmpBinaryImage = binaryImage.clone();
|
||||||
findContours(tmpBinaryImage, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
|
findContours(tmpBinaryImage, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
|
|||||||
|
|
||||||
if (params.filterByInertia)
|
if (params.filterByInertia)
|
||||||
{
|
{
|
||||||
double denominator = sqrt(pow(2 * moms.mu11, 2) + pow(moms.mu20 - moms.mu02, 2));
|
double denominator = std::sqrt(std::pow(2 * moms.mu11, 2) + std::pow(moms.mu20 - moms.mu02, 2));
|
||||||
const double eps = 1e-2;
|
const double eps = 1e-2;
|
||||||
double ratio;
|
double ratio;
|
||||||
if (denominator > eps)
|
if (denominator > eps)
|
||||||
@ -231,7 +231,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
|
|||||||
|
|
||||||
if (params.filterByConvexity)
|
if (params.filterByConvexity)
|
||||||
{
|
{
|
||||||
vector < Point > hull;
|
std::vector < Point > hull;
|
||||||
convexHull(Mat(contours[contourIdx]), hull);
|
convexHull(Mat(contours[contourIdx]), hull);
|
||||||
double area = contourArea(Mat(contours[contourIdx]));
|
double area = contourArea(Mat(contours[contourIdx]));
|
||||||
double hullArea = contourArea(Mat(hull));
|
double hullArea = contourArea(Mat(hull));
|
||||||
@ -250,7 +250,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
|
|||||||
|
|
||||||
//compute blob radius
|
//compute blob radius
|
||||||
{
|
{
|
||||||
vector<double> dists;
|
std::vector<double> dists;
|
||||||
for (size_t pointIdx = 0; pointIdx < contours[contourIdx].size(); pointIdx++)
|
for (size_t pointIdx = 0; pointIdx < contours[contourIdx].size(); pointIdx++)
|
||||||
{
|
{
|
||||||
Point2d pt = contours[contourIdx][pointIdx];
|
Point2d pt = contours[contourIdx][pointIdx];
|
||||||
@ -282,7 +282,7 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
|
|||||||
else
|
else
|
||||||
grayscaleImage = image;
|
grayscaleImage = image;
|
||||||
|
|
||||||
vector < vector<Center> > centers;
|
std::vector < std::vector<Center> > centers;
|
||||||
for (double thresh = params.minThreshold; thresh < params.maxThreshold; thresh += params.thresholdStep)
|
for (double thresh = params.minThreshold; thresh < params.maxThreshold; thresh += params.thresholdStep)
|
||||||
{
|
{
|
||||||
Mat binarizedImage;
|
Mat binarizedImage;
|
||||||
@ -293,9 +293,9 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
|
|||||||
// cvtColor( binarizedImage, keypointsImage, CV_GRAY2RGB );
|
// cvtColor( binarizedImage, keypointsImage, CV_GRAY2RGB );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vector < Center > curCenters;
|
std::vector < Center > curCenters;
|
||||||
findBlobs(grayscaleImage, binarizedImage, curCenters);
|
findBlobs(grayscaleImage, binarizedImage, curCenters);
|
||||||
vector < vector<Center> > newCenters;
|
std::vector < std::vector<Center> > newCenters;
|
||||||
for (size_t i = 0; i < curCenters.size(); i++)
|
for (size_t i = 0; i < curCenters.size(); i++)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BLOB_DETECTOR
|
#ifdef DEBUG_BLOB_DETECTOR
|
||||||
@ -324,8 +324,8 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
|
|||||||
}
|
}
|
||||||
if (isNew)
|
if (isNew)
|
||||||
{
|
{
|
||||||
newCenters.push_back(vector<Center> (1, curCenters[i]));
|
newCenters.push_back(std::vector<Center> (1, curCenters[i]));
|
||||||
//centers.push_back(vector<Center> (1, curCenters[i]));
|
//centers.push_back(std::vector<Center> (1, curCenters[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::copy(newCenters.begin(), newCenters.end(), std::back_inserter(centers));
|
std::copy(newCenters.begin(), newCenters.end(), std::back_inserter(centers));
|
||||||
|
@ -247,7 +247,7 @@ BRISK::generateKernel(std::vector<float> &radiusList, std::vector<int> &numberLi
|
|||||||
BriskPatternPoint* patternIterator = patternPoints_;
|
BriskPatternPoint* patternIterator = patternPoints_;
|
||||||
|
|
||||||
// define the scale discretization:
|
// define the scale discretization:
|
||||||
static const float lb_scale = (float)(log(scalerange_) / log(2.0));
|
static const float lb_scale = (float)(std::log(scalerange_) / std::log(2.0));
|
||||||
static const float lb_scale_step = lb_scale / (scales_);
|
static const float lb_scale_step = lb_scale / (scales_);
|
||||||
|
|
||||||
scaleList_ = new float[scales_];
|
scaleList_ = new float[scales_];
|
||||||
@ -257,7 +257,7 @@ BRISK::generateKernel(std::vector<float> &radiusList, std::vector<int> &numberLi
|
|||||||
|
|
||||||
for (unsigned int scale = 0; scale < scales_; ++scale)
|
for (unsigned int scale = 0; scale < scales_; ++scale)
|
||||||
{
|
{
|
||||||
scaleList_[scale] = (float)pow((double) 2.0, (double) (scale * lb_scale_step));
|
scaleList_[scale] = (float)std::pow((double) 2.0, (double) (scale * lb_scale_step));
|
||||||
sizeList_[scale] = 0;
|
sizeList_[scale] = 0;
|
||||||
|
|
||||||
// generate the pattern points look-up
|
// generate the pattern points look-up
|
||||||
@ -519,7 +519,7 @@ RoiPredicate(const float minX, const float minY, const float maxX, const float m
|
|||||||
|
|
||||||
// computes the descriptor
|
// computes the descriptor
|
||||||
void
|
void
|
||||||
BRISK::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& keypoints,
|
BRISK::operator()( InputArray _image, InputArray _mask, std::vector<KeyPoint>& keypoints,
|
||||||
OutputArray _descriptors, bool useProvidedKeypoints) const
|
OutputArray _descriptors, bool useProvidedKeypoints) const
|
||||||
{
|
{
|
||||||
bool doOrientation=true;
|
bool doOrientation=true;
|
||||||
@ -530,7 +530,7 @@ BRISK::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& keypoi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, vector<KeyPoint>& keypoints,
|
BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, std::vector<KeyPoint>& keypoints,
|
||||||
OutputArray _descriptors, bool doDescriptors, bool doOrientation,
|
OutputArray _descriptors, bool doDescriptors, bool doOrientation,
|
||||||
bool useProvidedKeypoints) const
|
bool useProvidedKeypoints) const
|
||||||
{
|
{
|
||||||
@ -549,14 +549,14 @@ BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, v
|
|||||||
std::vector<int> kscales; // remember the scale per keypoint
|
std::vector<int> kscales; // remember the scale per keypoint
|
||||||
kscales.resize(ksize);
|
kscales.resize(ksize);
|
||||||
static const float log2 = 0.693147180559945f;
|
static const float log2 = 0.693147180559945f;
|
||||||
static const float lb_scalerange = (float)(log(scalerange_) / (log2));
|
static const float lb_scalerange = (float)(std::log(scalerange_) / (log2));
|
||||||
std::vector<cv::KeyPoint>::iterator beginning = keypoints.begin();
|
std::vector<cv::KeyPoint>::iterator beginning = keypoints.begin();
|
||||||
std::vector<int>::iterator beginningkscales = kscales.begin();
|
std::vector<int>::iterator beginningkscales = kscales.begin();
|
||||||
static const float basicSize06 = basicSize_ * 0.6f;
|
static const float basicSize06 = basicSize_ * 0.6f;
|
||||||
for (size_t k = 0; k < ksize; k++)
|
for (size_t k = 0; k < ksize; k++)
|
||||||
{
|
{
|
||||||
unsigned int scale;
|
unsigned int scale;
|
||||||
scale = std::max((int) (scales_ / lb_scalerange * (log(keypoints[k].size / (basicSize06)) / log2) + 0.5), 0);
|
scale = std::max((int) (scales_ / lb_scalerange * (std::log(keypoints[k].size / (basicSize06)) / log2) + 0.5), 0);
|
||||||
// saturate
|
// saturate
|
||||||
if (scale >= scales_)
|
if (scale >= scales_)
|
||||||
scale = scales_ - 1;
|
scale = scales_ - 1;
|
||||||
@ -718,14 +718,14 @@ BRISK::~BRISK()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BRISK::operator()(InputArray image, InputArray mask, vector<KeyPoint>& keypoints) const
|
BRISK::operator()(InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints) const
|
||||||
{
|
{
|
||||||
computeKeypointsNoOrientation(image, mask, keypoints);
|
computeKeypointsNoOrientation(image, mask, keypoints);
|
||||||
computeDescriptorsAndOrOrientation(image, mask, keypoints, cv::noArray(), false, true, true);
|
computeDescriptorsAndOrOrientation(image, mask, keypoints, cv::noArray(), false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BRISK::computeKeypointsNoOrientation(InputArray _image, InputArray _mask, vector<KeyPoint>& keypoints) const
|
BRISK::computeKeypointsNoOrientation(InputArray _image, InputArray _mask, std::vector<KeyPoint>& keypoints) const
|
||||||
{
|
{
|
||||||
Mat image = _image.getMat(), mask = _mask.getMat();
|
Mat image = _image.getMat(), mask = _mask.getMat();
|
||||||
if( image.type() != CV_8UC1 )
|
if( image.type() != CV_8UC1 )
|
||||||
@ -741,13 +741,13 @@ BRISK::computeKeypointsNoOrientation(InputArray _image, InputArray _mask, vector
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BRISK::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const
|
BRISK::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
|
||||||
{
|
{
|
||||||
(*this)(image, mask, keypoints);
|
(*this)(image, mask, keypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BRISK::computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors) const
|
BRISK::computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors) const
|
||||||
{
|
{
|
||||||
(*this)(image, Mat(), keypoints, descriptors, true);
|
(*this)(image, Mat(), keypoints, descriptors, true);
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -55,7 +53,7 @@ namespace cv
|
|||||||
DescriptorExtractor::~DescriptorExtractor()
|
DescriptorExtractor::~DescriptorExtractor()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void DescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const
|
void DescriptorExtractor::compute( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const
|
||||||
{
|
{
|
||||||
if( image.empty() || keypoints.empty() )
|
if( image.empty() || keypoints.empty() )
|
||||||
{
|
{
|
||||||
@ -69,7 +67,7 @@ void DescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints
|
|||||||
computeImpl( image, keypoints, descriptors );
|
computeImpl( image, keypoints, descriptors );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorExtractor::compute( const vector<Mat>& imageCollection, vector<vector<KeyPoint> >& pointCollection, vector<Mat>& descCollection ) const
|
void DescriptorExtractor::compute( const std::vector<Mat>& imageCollection, std::vector<std::vector<KeyPoint> >& pointCollection, std::vector<Mat>& descCollection ) const
|
||||||
{
|
{
|
||||||
CV_Assert( imageCollection.size() == pointCollection.size() );
|
CV_Assert( imageCollection.size() == pointCollection.size() );
|
||||||
descCollection.resize( imageCollection.size() );
|
descCollection.resize( imageCollection.size() );
|
||||||
@ -88,18 +86,18 @@ bool DescriptorExtractor::empty() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorExtractor::removeBorderKeypoints( vector<KeyPoint>& keypoints,
|
void DescriptorExtractor::removeBorderKeypoints( std::vector<KeyPoint>& keypoints,
|
||||||
Size imageSize, int borderSize )
|
Size imageSize, int borderSize )
|
||||||
{
|
{
|
||||||
KeyPointsFilter::runByImageBorder( keypoints, imageSize, borderSize );
|
KeyPointsFilter::runByImageBorder( keypoints, imageSize, borderSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<DescriptorExtractor> DescriptorExtractor::create(const string& descriptorExtractorType)
|
Ptr<DescriptorExtractor> DescriptorExtractor::create(const std::string& descriptorExtractorType)
|
||||||
{
|
{
|
||||||
if( descriptorExtractorType.find("Opponent") == 0 )
|
if( descriptorExtractorType.find("Opponent") == 0 )
|
||||||
{
|
{
|
||||||
size_t pos = string("Opponent").size();
|
size_t pos = std::string("Opponent").size();
|
||||||
string type = descriptorExtractorType.substr(pos);
|
std::string type = descriptorExtractorType.substr(pos);
|
||||||
return new OpponentColorDescriptorExtractor(DescriptorExtractor::create(type));
|
return new OpponentColorDescriptorExtractor(DescriptorExtractor::create(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +115,7 @@ OpponentColorDescriptorExtractor::OpponentColorDescriptorExtractor( const Ptr<De
|
|||||||
CV_Assert( !descriptorExtractor.empty() );
|
CV_Assert( !descriptorExtractor.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, vector<Mat>& opponentChannels )
|
static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, std::vector<Mat>& opponentChannels )
|
||||||
{
|
{
|
||||||
if( bgrImage.type() != CV_8UC3 )
|
if( bgrImage.type() != CV_8UC3 )
|
||||||
CV_Error( CV_StsBadArg, "input image must be an BGR image of type CV_8UC3" );
|
CV_Error( CV_StsBadArg, "input image must be an BGR image of type CV_8UC3" );
|
||||||
@ -144,23 +142,23 @@ static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, vector<Mat
|
|||||||
|
|
||||||
struct KP_LessThan
|
struct KP_LessThan
|
||||||
{
|
{
|
||||||
KP_LessThan(const vector<KeyPoint>& _kp) : kp(&_kp) {}
|
KP_LessThan(const std::vector<KeyPoint>& _kp) : kp(&_kp) {}
|
||||||
bool operator()(int i, int j) const
|
bool operator()(int i, int j) const
|
||||||
{
|
{
|
||||||
return (*kp)[i].class_id < (*kp)[j].class_id;
|
return (*kp)[i].class_id < (*kp)[j].class_id;
|
||||||
}
|
}
|
||||||
const vector<KeyPoint>* kp;
|
const std::vector<KeyPoint>* kp;
|
||||||
};
|
};
|
||||||
|
|
||||||
void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector<KeyPoint>& keypoints, Mat& descriptors ) const
|
void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const
|
||||||
{
|
{
|
||||||
vector<Mat> opponentChannels;
|
std::vector<Mat> opponentChannels;
|
||||||
convertBGRImageToOpponentColorSpace( bgrImage, opponentChannels );
|
convertBGRImageToOpponentColorSpace( bgrImage, opponentChannels );
|
||||||
|
|
||||||
const int N = 3; // channels count
|
const int N = 3; // channels count
|
||||||
vector<KeyPoint> channelKeypoints[N];
|
std::vector<KeyPoint> channelKeypoints[N];
|
||||||
Mat channelDescriptors[N];
|
Mat channelDescriptors[N];
|
||||||
vector<int> idxs[N];
|
std::vector<int> idxs[N];
|
||||||
|
|
||||||
// Compute descriptors three times, once for each Opponent channel to concatenate into a single color descriptor
|
// Compute descriptors three times, once for each Opponent channel to concatenate into a single color descriptor
|
||||||
int maxKeypointsCount = 0;
|
int maxKeypointsCount = 0;
|
||||||
@ -181,7 +179,7 @@ void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector<
|
|||||||
maxKeypointsCount = std::max( maxKeypointsCount, (int)channelKeypoints[ci].size());
|
maxKeypointsCount = std::max( maxKeypointsCount, (int)channelKeypoints[ci].size());
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<KeyPoint> outKeypoints;
|
std::vector<KeyPoint> outKeypoints;
|
||||||
outKeypoints.reserve( keypoints.size() );
|
outKeypoints.reserve( keypoints.size() );
|
||||||
|
|
||||||
int dSize = descriptorExtractor->descriptorSize();
|
int dSize = descriptorExtractor->descriptorSize();
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -53,7 +51,7 @@ namespace cv
|
|||||||
FeatureDetector::~FeatureDetector()
|
FeatureDetector::~FeatureDetector()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void FeatureDetector::detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void FeatureDetector::detect( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
keypoints.clear();
|
keypoints.clear();
|
||||||
|
|
||||||
@ -65,7 +63,7 @@ void FeatureDetector::detect( const Mat& image, vector<KeyPoint>& keypoints, con
|
|||||||
detectImpl( image, keypoints, mask );
|
detectImpl( image, keypoints, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeatureDetector::detect(const vector<Mat>& imageCollection, vector<vector<KeyPoint> >& pointCollection, const vector<Mat>& masks ) const
|
void FeatureDetector::detect(const std::vector<Mat>& imageCollection, std::vector<std::vector<KeyPoint> >& pointCollection, const std::vector<Mat>& masks ) const
|
||||||
{
|
{
|
||||||
pointCollection.resize( imageCollection.size() );
|
pointCollection.resize( imageCollection.size() );
|
||||||
for( size_t i = 0; i < imageCollection.size(); i++ )
|
for( size_t i = 0; i < imageCollection.size(); i++ )
|
||||||
@ -83,12 +81,12 @@ bool FeatureDetector::empty() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeatureDetector::removeInvalidPoints( const Mat& mask, vector<KeyPoint>& keypoints )
|
void FeatureDetector::removeInvalidPoints( const Mat& mask, std::vector<KeyPoint>& keypoints )
|
||||||
{
|
{
|
||||||
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<FeatureDetector> FeatureDetector::create( const string& detectorType )
|
Ptr<FeatureDetector> FeatureDetector::create( const std::string& detectorType )
|
||||||
{
|
{
|
||||||
if( detectorType.find("Grid") == 0 )
|
if( detectorType.find("Grid") == 0 )
|
||||||
{
|
{
|
||||||
@ -127,17 +125,17 @@ GFTTDetector::GFTTDetector( int _nfeatures, double _qualityLevel,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GFTTDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const
|
void GFTTDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
|
||||||
{
|
{
|
||||||
Mat grayImage = image;
|
Mat grayImage = image;
|
||||||
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
||||||
|
|
||||||
vector<Point2f> corners;
|
std::vector<Point2f> corners;
|
||||||
goodFeaturesToTrack( grayImage, corners, nfeatures, qualityLevel, minDistance, mask,
|
goodFeaturesToTrack( grayImage, corners, nfeatures, qualityLevel, minDistance, mask,
|
||||||
blockSize, useHarrisDetector, k );
|
blockSize, useHarrisDetector, k );
|
||||||
keypoints.resize(corners.size());
|
keypoints.resize(corners.size());
|
||||||
vector<Point2f>::const_iterator corner_it = corners.begin();
|
std::vector<Point2f>::const_iterator corner_it = corners.begin();
|
||||||
vector<KeyPoint>::iterator keypoint_it = keypoints.begin();
|
std::vector<KeyPoint>::iterator keypoint_it = keypoints.begin();
|
||||||
for( ; corner_it != corners.end(); ++corner_it, ++keypoint_it )
|
for( ; corner_it != corners.end(); ++corner_it, ++keypoint_it )
|
||||||
{
|
{
|
||||||
*keypoint_it = KeyPoint( *corner_it, (float)blockSize );
|
*keypoint_it = KeyPoint( *corner_it, (float)blockSize );
|
||||||
@ -159,7 +157,7 @@ DenseFeatureDetector::DenseFeatureDetector( float _initFeatureScale, int _featur
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void DenseFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void DenseFeatureDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
float curScale = static_cast<float>(initFeatureScale);
|
float curScale = static_cast<float>(initFeatureScale);
|
||||||
int curStep = initXyStep;
|
int curStep = initXyStep;
|
||||||
@ -203,11 +201,11 @@ struct ResponseComparator
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void keepStrongest( int N, vector<KeyPoint>& keypoints )
|
static void keepStrongest( int N, std::vector<KeyPoint>& keypoints )
|
||||||
{
|
{
|
||||||
if( (int)keypoints.size() > N )
|
if( (int)keypoints.size() > N )
|
||||||
{
|
{
|
||||||
vector<KeyPoint>::iterator nth = keypoints.begin() + N;
|
std::vector<KeyPoint>::iterator nth = keypoints.begin() + N;
|
||||||
std::nth_element( keypoints.begin(), nth, keypoints.end(), ResponseComparator() );
|
std::nth_element( keypoints.begin(), nth, keypoints.end(), ResponseComparator() );
|
||||||
keypoints.erase( nth, keypoints.end() );
|
keypoints.erase( nth, keypoints.end() );
|
||||||
}
|
}
|
||||||
@ -219,7 +217,7 @@ class GridAdaptedFeatureDetectorInvoker
|
|||||||
private:
|
private:
|
||||||
int gridRows_, gridCols_;
|
int gridRows_, gridCols_;
|
||||||
int maxPerCell_;
|
int maxPerCell_;
|
||||||
vector<KeyPoint>& keypoints_;
|
std::vector<KeyPoint>& keypoints_;
|
||||||
const Mat& image_;
|
const Mat& image_;
|
||||||
const Mat& mask_;
|
const Mat& mask_;
|
||||||
const Ptr<FeatureDetector>& detector_;
|
const Ptr<FeatureDetector>& detector_;
|
||||||
@ -231,7 +229,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GridAdaptedFeatureDetectorInvoker(const Ptr<FeatureDetector>& detector, const Mat& image, const Mat& mask, vector<KeyPoint>& keypoints, int maxPerCell, int gridRows, int gridCols
|
GridAdaptedFeatureDetectorInvoker(const Ptr<FeatureDetector>& detector, const Mat& image, const Mat& mask, std::vector<KeyPoint>& keypoints, int maxPerCell, int gridRows, int gridCols
|
||||||
#ifdef HAVE_TBB
|
#ifdef HAVE_TBB
|
||||||
, tbb::mutex* kptLock
|
, tbb::mutex* kptLock
|
||||||
#endif
|
#endif
|
||||||
@ -257,7 +255,7 @@ public:
|
|||||||
Mat sub_mask;
|
Mat sub_mask;
|
||||||
if (!mask_.empty()) sub_mask = mask_(row_range, col_range);
|
if (!mask_.empty()) sub_mask = mask_(row_range, col_range);
|
||||||
|
|
||||||
vector<KeyPoint> sub_keypoints;
|
std::vector<KeyPoint> sub_keypoints;
|
||||||
sub_keypoints.reserve(maxPerCell_);
|
sub_keypoints.reserve(maxPerCell_);
|
||||||
|
|
||||||
detector_->detect( sub_image, sub_keypoints, sub_mask );
|
detector_->detect( sub_image, sub_keypoints, sub_mask );
|
||||||
@ -279,7 +277,7 @@ public:
|
|||||||
};
|
};
|
||||||
} // namepace
|
} // namepace
|
||||||
|
|
||||||
void GridAdaptedFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void GridAdaptedFeatureDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
if (image.empty() || maxTotalKeypoints < gridRows * gridCols)
|
if (image.empty() || maxTotalKeypoints < gridRows * gridCols)
|
||||||
{
|
{
|
||||||
@ -310,7 +308,7 @@ bool PyramidAdaptedFeatureDetector::empty() const
|
|||||||
return detector.empty() || (FeatureDetector*)detector->empty();
|
return detector.empty() || (FeatureDetector*)detector->empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
Mat src = image;
|
Mat src = image;
|
||||||
Mat src_mask = mask;
|
Mat src_mask = mask;
|
||||||
@ -327,9 +325,9 @@ void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector<KeyPoin
|
|||||||
for( int l = 0, multiplier = 1; l <= maxLevel; ++l, multiplier *= 2 )
|
for( int l = 0, multiplier = 1; l <= maxLevel; ++l, multiplier *= 2 )
|
||||||
{
|
{
|
||||||
// Detect on current level of the pyramid
|
// Detect on current level of the pyramid
|
||||||
vector<KeyPoint> new_pts;
|
std::vector<KeyPoint> new_pts;
|
||||||
detector->detect( src, new_pts, src_mask );
|
detector->detect( src, new_pts, src_mask );
|
||||||
vector<KeyPoint>::iterator it = new_pts.begin(),
|
std::vector<KeyPoint>::iterator it = new_pts.begin(),
|
||||||
end = new_pts.end();
|
end = new_pts.end();
|
||||||
for( ; it != end; ++it)
|
for( ; it != end; ++it)
|
||||||
{
|
{
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
const int draw_shift_bits = 4;
|
const int draw_shift_bits = 4;
|
||||||
const int draw_multiplier = 1 << draw_shift_bits;
|
const int draw_multiplier = 1 << draw_shift_bits;
|
||||||
|
|
||||||
@ -90,7 +88,7 @@ static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& col
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawKeypoints( const Mat& image, const vector<KeyPoint>& keypoints, Mat& outImage,
|
void drawKeypoints( const Mat& image, const std::vector<KeyPoint>& keypoints, Mat& outImage,
|
||||||
const Scalar& _color, int flags )
|
const Scalar& _color, int flags )
|
||||||
{
|
{
|
||||||
if( !(flags & DrawMatchesFlags::DRAW_OVER_OUTIMG) )
|
if( !(flags & DrawMatchesFlags::DRAW_OVER_OUTIMG) )
|
||||||
@ -113,7 +111,7 @@ void drawKeypoints( const Mat& image, const vector<KeyPoint>& keypoints, Mat& ou
|
|||||||
bool isRandColor = _color == Scalar::all(-1);
|
bool isRandColor = _color == Scalar::all(-1);
|
||||||
|
|
||||||
CV_Assert( !outImage.empty() );
|
CV_Assert( !outImage.empty() );
|
||||||
vector<KeyPoint>::const_iterator it = keypoints.begin(),
|
std::vector<KeyPoint>::const_iterator it = keypoints.begin(),
|
||||||
end = keypoints.end();
|
end = keypoints.end();
|
||||||
for( ; it != end; ++it )
|
for( ; it != end; ++it )
|
||||||
{
|
{
|
||||||
@ -122,8 +120,8 @@ void drawKeypoints( const Mat& image, const vector<KeyPoint>& keypoints, Mat& ou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _prepareImgAndDrawKeypoints( const Mat& img1, const vector<KeyPoint>& keypoints1,
|
static void _prepareImgAndDrawKeypoints( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
|
||||||
const Mat& img2, const vector<KeyPoint>& keypoints2,
|
const Mat& img2, const std::vector<KeyPoint>& keypoints2,
|
||||||
Mat& outImg, Mat& outImg1, Mat& outImg2,
|
Mat& outImg, Mat& outImg1, Mat& outImg2,
|
||||||
const Scalar& singlePointColor, int flags )
|
const Scalar& singlePointColor, int flags )
|
||||||
{
|
{
|
||||||
@ -184,11 +182,11 @@ static inline void _drawMatch( Mat& outImg, Mat& outImg1, Mat& outImg2 ,
|
|||||||
color, 1, CV_AA, draw_shift_bits );
|
color, 1, CV_AA, draw_shift_bits );
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1,
|
void drawMatches( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
|
||||||
const Mat& img2, const vector<KeyPoint>& keypoints2,
|
const Mat& img2, const std::vector<KeyPoint>& keypoints2,
|
||||||
const vector<DMatch>& matches1to2, Mat& outImg,
|
const std::vector<DMatch>& matches1to2, Mat& outImg,
|
||||||
const Scalar& matchColor, const Scalar& singlePointColor,
|
const Scalar& matchColor, const Scalar& singlePointColor,
|
||||||
const vector<char>& matchesMask, int flags )
|
const std::vector<char>& matchesMask, int flags )
|
||||||
{
|
{
|
||||||
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
|
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
|
||||||
CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" );
|
CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" );
|
||||||
@ -213,11 +211,11 @@ void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1,
|
void drawMatches( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
|
||||||
const Mat& img2, const vector<KeyPoint>& keypoints2,
|
const Mat& img2, const std::vector<KeyPoint>& keypoints2,
|
||||||
const vector<vector<DMatch> >& matches1to2, Mat& outImg,
|
const std::vector<std::vector<DMatch> >& matches1to2, Mat& outImg,
|
||||||
const Scalar& matchColor, const Scalar& singlePointColor,
|
const Scalar& matchColor, const Scalar& singlePointColor,
|
||||||
const vector<vector<char> >& matchesMask, int flags )
|
const std::vector<std::vector<char> >& matchesMask, int flags )
|
||||||
{
|
{
|
||||||
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
|
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
|
||||||
CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" );
|
CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" );
|
||||||
|
@ -54,7 +54,7 @@ bool DynamicAdaptedFeatureDetector::empty() const
|
|||||||
return adjuster_.empty() || adjuster_->empty();
|
return adjuster_.empty() || adjuster_->empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicAdaptedFeatureDetector::detectImpl(const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const
|
void DynamicAdaptedFeatureDetector::detectImpl(const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
|
||||||
{
|
{
|
||||||
//for oscillation testing
|
//for oscillation testing
|
||||||
bool down = false;
|
bool down = false;
|
||||||
@ -98,7 +98,7 @@ FastAdjuster::FastAdjuster( int init_thresh, bool nonmax, int min_thresh, int ma
|
|||||||
min_thresh_(min_thresh), max_thresh_(max_thresh)
|
min_thresh_(min_thresh), max_thresh_(max_thresh)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void FastAdjuster::detectImpl(const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const
|
void FastAdjuster::detectImpl(const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
|
||||||
{
|
{
|
||||||
FastFeatureDetector(thresh_, nonmax_).detect(image, keypoints, mask);
|
FastFeatureDetector(thresh_, nonmax_).detect(image, keypoints, mask);
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ StarAdjuster::StarAdjuster(double initial_thresh, double min_thresh, double max_
|
|||||||
min_thresh_(min_thresh), max_thresh_(max_thresh)
|
min_thresh_(min_thresh), max_thresh_(max_thresh)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void StarAdjuster::detectImpl(const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const
|
void StarAdjuster::detectImpl(const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
|
||||||
{
|
{
|
||||||
StarFeatureDetector detector_tmp(16, cvRound(thresh_), 10, 8, 3);
|
StarFeatureDetector detector_tmp(16, cvRound(thresh_), 10, 8, 3);
|
||||||
detector_tmp.detect(image, keypoints, mask);
|
detector_tmp.detect(image, keypoints, mask);
|
||||||
@ -167,7 +167,7 @@ SurfAdjuster::SurfAdjuster( double initial_thresh, double min_thresh, double max
|
|||||||
min_thresh_(min_thresh), max_thresh_(max_thresh)
|
min_thresh_(min_thresh), max_thresh_(max_thresh)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SurfAdjuster::detectImpl(const Mat& image, vector<KeyPoint>& keypoints, const cv::Mat& mask) const
|
void SurfAdjuster::detectImpl(const Mat& image, std::vector<KeyPoint>& keypoints, const cv::Mat& mask) const
|
||||||
{
|
{
|
||||||
Ptr<FeatureDetector> surf = FeatureDetector::create("SURF");
|
Ptr<FeatureDetector> surf = FeatureDetector::create("SURF");
|
||||||
surf->set("hessianThreshold", thresh_);
|
surf->set("hessianThreshold", thresh_);
|
||||||
@ -199,7 +199,7 @@ Ptr<AdjusterAdapter> SurfAdjuster::clone() const
|
|||||||
return cloned_obj;
|
return cloned_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<AdjusterAdapter> AdjusterAdapter::create( const string& detectorType )
|
Ptr<AdjusterAdapter> AdjusterAdapter::create( const std::string& detectorType )
|
||||||
{
|
{
|
||||||
Ptr<AdjusterAdapter> adapter;
|
Ptr<AdjusterAdapter> adapter;
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
template<typename _Tp> static int solveQuadratic(_Tp a, _Tp b, _Tp c, _Tp& x1, _Tp& x2)
|
template<typename _Tp> static int solveQuadratic(_Tp a, _Tp b, _Tp c, _Tp& x1, _Tp& x2)
|
||||||
{
|
{
|
||||||
@ -89,7 +88,7 @@ static inline Point2f applyHomography( const Mat_<double>& H, const Point2f& pt
|
|||||||
double w = 1./z;
|
double w = 1./z;
|
||||||
return Point2f( (float)((H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w), (float)((H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w) );
|
return Point2f( (float)((H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w), (float)((H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w) );
|
||||||
}
|
}
|
||||||
return Point2f( numeric_limits<float>::max(), numeric_limits<float>::max() );
|
return Point2f( std::numeric_limits<float>::max(), std::numeric_limits<float>::max() );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void linearizeHomographyAt( const Mat_<double>& H, const Point2f& pt, Mat_<double>& A )
|
static inline void linearizeHomographyAt( const Mat_<double>& H, const Point2f& pt, Mat_<double>& A )
|
||||||
@ -108,7 +107,7 @@ static inline void linearizeHomographyAt( const Mat_<double>& H, const Point2f&
|
|||||||
A(1,1) = H(1,1)/p3 - p2*H(2,1)/p3_2; // fydx
|
A(1,1) = H(1,1)/p3 - p2*H(2,1)/p3_2; // fydx
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
A.setTo(Scalar::all(numeric_limits<double>::max()));
|
A.setTo(Scalar::all(std::numeric_limits<double>::max()));
|
||||||
}
|
}
|
||||||
|
|
||||||
class EllipticKeyPoint
|
class EllipticKeyPoint
|
||||||
@ -117,14 +116,14 @@ public:
|
|||||||
EllipticKeyPoint();
|
EllipticKeyPoint();
|
||||||
EllipticKeyPoint( const Point2f& _center, const Scalar& _ellipse );
|
EllipticKeyPoint( const Point2f& _center, const Scalar& _ellipse );
|
||||||
|
|
||||||
static void convert( const vector<KeyPoint>& src, vector<EllipticKeyPoint>& dst );
|
static void convert( const std::vector<KeyPoint>& src, std::vector<EllipticKeyPoint>& dst );
|
||||||
static void convert( const vector<EllipticKeyPoint>& src, vector<KeyPoint>& dst );
|
static void convert( const std::vector<EllipticKeyPoint>& src, std::vector<KeyPoint>& dst );
|
||||||
|
|
||||||
static Mat_<double> getSecondMomentsMatrix( const Scalar& _ellipse );
|
static Mat_<double> getSecondMomentsMatrix( const Scalar& _ellipse );
|
||||||
Mat_<double> getSecondMomentsMatrix() const;
|
Mat_<double> getSecondMomentsMatrix() const;
|
||||||
|
|
||||||
void calcProjection( const Mat_<double>& H, EllipticKeyPoint& projection ) const;
|
void calcProjection( const Mat_<double>& H, EllipticKeyPoint& projection ) const;
|
||||||
static void calcProjection( const vector<EllipticKeyPoint>& src, const Mat_<double>& H, vector<EllipticKeyPoint>& dst );
|
static void calcProjection( const std::vector<EllipticKeyPoint>& src, const Mat_<double>& H, std::vector<EllipticKeyPoint>& dst );
|
||||||
|
|
||||||
Point2f center;
|
Point2f center;
|
||||||
Scalar ellipse; // 3 elements a, b, c: ax^2+2bxy+cy^2=1
|
Scalar ellipse; // 3 elements a, b, c: ax^2+2bxy+cy^2=1
|
||||||
@ -178,7 +177,7 @@ void EllipticKeyPoint::calcProjection( const Mat_<double>& H, EllipticKeyPoint&
|
|||||||
projection = EllipticKeyPoint( dstCenter, Scalar(dstM(0,0), dstM(0,1), dstM(1,1)) );
|
projection = EllipticKeyPoint( dstCenter, Scalar(dstM(0,0), dstM(0,1), dstM(1,1)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipticKeyPoint::convert( const vector<KeyPoint>& src, vector<EllipticKeyPoint>& dst )
|
void EllipticKeyPoint::convert( const std::vector<KeyPoint>& src, std::vector<EllipticKeyPoint>& dst )
|
||||||
{
|
{
|
||||||
if( !src.empty() )
|
if( !src.empty() )
|
||||||
{
|
{
|
||||||
@ -193,7 +192,7 @@ void EllipticKeyPoint::convert( const vector<KeyPoint>& src, vector<EllipticKeyP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipticKeyPoint::convert( const vector<EllipticKeyPoint>& src, vector<KeyPoint>& dst )
|
void EllipticKeyPoint::convert( const std::vector<EllipticKeyPoint>& src, std::vector<KeyPoint>& dst )
|
||||||
{
|
{
|
||||||
if( !src.empty() )
|
if( !src.empty() )
|
||||||
{
|
{
|
||||||
@ -207,26 +206,26 @@ void EllipticKeyPoint::convert( const vector<EllipticKeyPoint>& src, vector<KeyP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipticKeyPoint::calcProjection( const vector<EllipticKeyPoint>& src, const Mat_<double>& H, vector<EllipticKeyPoint>& dst )
|
void EllipticKeyPoint::calcProjection( const std::vector<EllipticKeyPoint>& src, const Mat_<double>& H, std::vector<EllipticKeyPoint>& dst )
|
||||||
{
|
{
|
||||||
if( !src.empty() )
|
if( !src.empty() )
|
||||||
{
|
{
|
||||||
assert( !H.empty() && H.cols == 3 && H.rows == 3);
|
assert( !H.empty() && H.cols == 3 && H.rows == 3);
|
||||||
dst.resize(src.size());
|
dst.resize(src.size());
|
||||||
vector<EllipticKeyPoint>::const_iterator srcIt = src.begin();
|
std::vector<EllipticKeyPoint>::const_iterator srcIt = src.begin();
|
||||||
vector<EllipticKeyPoint>::iterator dstIt = dst.begin();
|
std::vector<EllipticKeyPoint>::iterator dstIt = dst.begin();
|
||||||
for( ; srcIt != src.end(); ++srcIt, ++dstIt )
|
for( ; srcIt != src.end(); ++srcIt, ++dstIt )
|
||||||
srcIt->calcProjection(H, *dstIt);
|
srcIt->calcProjection(H, *dstIt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void filterEllipticKeyPointsByImageSize( vector<EllipticKeyPoint>& keypoints, const Size& imgSize )
|
static void filterEllipticKeyPointsByImageSize( std::vector<EllipticKeyPoint>& keypoints, const Size& imgSize )
|
||||||
{
|
{
|
||||||
if( !keypoints.empty() )
|
if( !keypoints.empty() )
|
||||||
{
|
{
|
||||||
vector<EllipticKeyPoint> filtered;
|
std::vector<EllipticKeyPoint> filtered;
|
||||||
filtered.reserve(keypoints.size());
|
filtered.reserve(keypoints.size());
|
||||||
vector<EllipticKeyPoint>::const_iterator it = keypoints.begin();
|
std::vector<EllipticKeyPoint>::const_iterator it = keypoints.begin();
|
||||||
for( int i = 0; it != keypoints.end(); ++it, i++ )
|
for( int i = 0; it != keypoints.end(); ++it, i++ )
|
||||||
{
|
{
|
||||||
if( it->center.x + it->boundingBox.width < imgSize.width &&
|
if( it->center.x + it->boundingBox.width < imgSize.width &&
|
||||||
@ -315,8 +314,8 @@ struct SIdx
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static void computeOneToOneMatchedOverlaps( const vector<EllipticKeyPoint>& keypoints1, const vector<EllipticKeyPoint>& keypoints2t,
|
static void computeOneToOneMatchedOverlaps( const std::vector<EllipticKeyPoint>& keypoints1, const std::vector<EllipticKeyPoint>& keypoints2t,
|
||||||
bool commonPart, vector<SIdx>& overlaps, float minOverlap )
|
bool commonPart, std::vector<SIdx>& overlaps, float minOverlap )
|
||||||
{
|
{
|
||||||
CV_Assert( minOverlap >= 0.f );
|
CV_Assert( minOverlap >= 0.f );
|
||||||
overlaps.clear();
|
overlaps.clear();
|
||||||
@ -374,9 +373,9 @@ static void computeOneToOneMatchedOverlaps( const vector<EllipticKeyPoint>& keyp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort( overlaps.begin(), overlaps.end() );
|
std::sort( overlaps.begin(), overlaps.end() );
|
||||||
|
|
||||||
typedef vector<SIdx>::iterator It;
|
typedef std::vector<SIdx>::iterator It;
|
||||||
|
|
||||||
It pos = overlaps.begin();
|
It pos = overlaps.begin();
|
||||||
It end = overlaps.end();
|
It end = overlaps.end();
|
||||||
@ -390,11 +389,11 @@ static void computeOneToOneMatchedOverlaps( const vector<EllipticKeyPoint>& keyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void calculateRepeatability( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
static void calculateRepeatability( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
||||||
const vector<KeyPoint>& _keypoints1, const vector<KeyPoint>& _keypoints2,
|
const std::vector<KeyPoint>& _keypoints1, const std::vector<KeyPoint>& _keypoints2,
|
||||||
float& repeatability, int& correspondencesCount,
|
float& repeatability, int& correspondencesCount,
|
||||||
Mat* thresholdedOverlapMask=0 )
|
Mat* thresholdedOverlapMask=0 )
|
||||||
{
|
{
|
||||||
vector<EllipticKeyPoint> keypoints1, keypoints2, keypoints1t, keypoints2t;
|
std::vector<EllipticKeyPoint> keypoints1, keypoints2, keypoints1t, keypoints2t;
|
||||||
EllipticKeyPoint::convert( _keypoints1, keypoints1 );
|
EllipticKeyPoint::convert( _keypoints1, keypoints1 );
|
||||||
EllipticKeyPoint::convert( _keypoints2, keypoints2 );
|
EllipticKeyPoint::convert( _keypoints2, keypoints2 );
|
||||||
|
|
||||||
@ -427,7 +426,7 @@ static void calculateRepeatability( const Mat& img1, const Mat& img2, const Mat&
|
|||||||
size_t minCount = MIN( size1, size2 );
|
size_t minCount = MIN( size1, size2 );
|
||||||
|
|
||||||
// calculate overlap errors
|
// calculate overlap errors
|
||||||
vector<SIdx> overlaps;
|
std::vector<SIdx> overlaps;
|
||||||
computeOneToOneMatchedOverlaps( keypoints1, keypoints2t, ifEvaluateDetectors, overlaps, overlapThreshold/*min overlap*/ );
|
computeOneToOneMatchedOverlaps( keypoints1, keypoints2t, ifEvaluateDetectors, overlaps, overlapThreshold/*min overlap*/ );
|
||||||
|
|
||||||
correspondencesCount = -1;
|
correspondencesCount = -1;
|
||||||
@ -453,12 +452,12 @@ static void calculateRepeatability( const Mat& img1, const Mat& img2, const Mat&
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
||||||
vector<KeyPoint>* _keypoints1, vector<KeyPoint>* _keypoints2,
|
std::vector<KeyPoint>* _keypoints1, std::vector<KeyPoint>* _keypoints2,
|
||||||
float& repeatability, int& correspCount,
|
float& repeatability, int& correspCount,
|
||||||
const Ptr<FeatureDetector>& _fdetector )
|
const Ptr<FeatureDetector>& _fdetector )
|
||||||
{
|
{
|
||||||
Ptr<FeatureDetector> fdetector(_fdetector);
|
Ptr<FeatureDetector> fdetector(_fdetector);
|
||||||
vector<KeyPoint> *keypoints1, *keypoints2, buf1, buf2;
|
std::vector<KeyPoint> *keypoints1, *keypoints2, buf1, buf2;
|
||||||
keypoints1 = _keypoints1 != 0 ? _keypoints1 : &buf1;
|
keypoints1 = _keypoints1 != 0 ? _keypoints1 : &buf1;
|
||||||
keypoints2 = _keypoints2 != 0 ? _keypoints2 : &buf2;
|
keypoints2 = _keypoints2 != 0 ? _keypoints2 : &buf2;
|
||||||
|
|
||||||
@ -489,13 +488,13 @@ static inline float precision( int correctMatchCount, int falseMatchCount )
|
|||||||
return correctMatchCount + falseMatchCount ? (float)correctMatchCount / (float)(correctMatchCount + falseMatchCount) : -1;
|
return correctMatchCount + falseMatchCount ? (float)correctMatchCount / (float)(correctMatchCount + falseMatchCount) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::computeRecallPrecisionCurve( const vector<vector<DMatch> >& matches1to2,
|
void cv::computeRecallPrecisionCurve( const std::vector<std::vector<DMatch> >& matches1to2,
|
||||||
const vector<vector<uchar> >& correctMatches1to2Mask,
|
const std::vector<std::vector<uchar> >& correctMatches1to2Mask,
|
||||||
vector<Point2f>& recallPrecisionCurve )
|
std::vector<Point2f>& recallPrecisionCurve )
|
||||||
{
|
{
|
||||||
CV_Assert( matches1to2.size() == correctMatches1to2Mask.size() );
|
CV_Assert( matches1to2.size() == correctMatches1to2Mask.size() );
|
||||||
|
|
||||||
vector<DMatchForEvaluation> allMatches;
|
std::vector<DMatchForEvaluation> allMatches;
|
||||||
int correspondenceCount = 0;
|
int correspondenceCount = 0;
|
||||||
for( size_t i = 0; i < matches1to2.size(); i++ )
|
for( size_t i = 0; i < matches1to2.size(); i++ )
|
||||||
{
|
{
|
||||||
@ -525,7 +524,7 @@ void cv::computeRecallPrecisionCurve( const vector<vector<DMatch> >& matches1to2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float cv::getRecall( const vector<Point2f>& recallPrecisionCurve, float l_precision )
|
float cv::getRecall( const std::vector<Point2f>& recallPrecisionCurve, float l_precision )
|
||||||
{
|
{
|
||||||
int nearestPointIndex = getNearestPoint( recallPrecisionCurve, l_precision );
|
int nearestPointIndex = getNearestPoint( recallPrecisionCurve, l_precision );
|
||||||
|
|
||||||
@ -537,7 +536,7 @@ float cv::getRecall( const vector<Point2f>& recallPrecisionCurve, float l_precis
|
|||||||
return recall;
|
return recall;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::getNearestPoint( const vector<Point2f>& recallPrecisionCurve, float l_precision )
|
int cv::getNearestPoint( const std::vector<Point2f>& recallPrecisionCurve, float l_precision )
|
||||||
{
|
{
|
||||||
int nearestPointIndex = -1;
|
int nearestPointIndex = -1;
|
||||||
|
|
||||||
@ -559,18 +558,18 @@ int cv::getNearestPoint( const vector<Point2f>& recallPrecisionCurve, float l_pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cv::evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
void cv::evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, const Mat& H1to2,
|
||||||
vector<KeyPoint>& keypoints1, vector<KeyPoint>& keypoints2,
|
std::vector<KeyPoint>& keypoints1, std::vector<KeyPoint>& keypoints2,
|
||||||
vector<vector<DMatch> >* _matches1to2, vector<vector<uchar> >* _correctMatches1to2Mask,
|
std::vector<std::vector<DMatch> >* _matches1to2, std::vector<std::vector<uchar> >* _correctMatches1to2Mask,
|
||||||
vector<Point2f>& recallPrecisionCurve,
|
std::vector<Point2f>& recallPrecisionCurve,
|
||||||
const Ptr<GenericDescriptorMatcher>& _dmatcher )
|
const Ptr<GenericDescriptorMatcher>& _dmatcher )
|
||||||
{
|
{
|
||||||
Ptr<GenericDescriptorMatcher> dmatcher = _dmatcher;
|
Ptr<GenericDescriptorMatcher> dmatcher = _dmatcher;
|
||||||
dmatcher->clear();
|
dmatcher->clear();
|
||||||
|
|
||||||
vector<vector<DMatch> > *matches1to2, buf1;
|
std::vector<std::vector<DMatch> > *matches1to2, buf1;
|
||||||
matches1to2 = _matches1to2 != 0 ? _matches1to2 : &buf1;
|
matches1to2 = _matches1to2 != 0 ? _matches1to2 : &buf1;
|
||||||
|
|
||||||
vector<vector<uchar> > *correctMatches1to2Mask, buf2;
|
std::vector<std::vector<uchar> > *correctMatches1to2Mask, buf2;
|
||||||
correctMatches1to2Mask = _correctMatches1to2Mask != 0 ? _correctMatches1to2Mask : &buf2;
|
correctMatches1to2Mask = _correctMatches1to2Mask != 0 ? _correctMatches1to2Mask : &buf2;
|
||||||
|
|
||||||
if( keypoints1.empty() )
|
if( keypoints1.empty() )
|
||||||
|
@ -283,7 +283,7 @@ FastFeatureDetector::FastFeatureDetector( int _threshold, bool _nonmaxSuppressio
|
|||||||
: threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type)
|
: threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void FastFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void FastFeatureDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
Mat grayImage = image;
|
Mat grayImage = image;
|
||||||
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
Ptr<Feature2D> Feature2D::create( const string& feature2DType )
|
Ptr<Feature2D> Feature2D::create( const std::string& feature2DType )
|
||||||
{
|
{
|
||||||
return Algorithm::create<Feature2D>("Feature2D." + feature2DType);
|
return Algorithm::create<Feature2D>("Feature2D." + feature2DType);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ void FREAK::buildPattern()
|
|||||||
patternScale0 = patternScale;
|
patternScale0 = patternScale;
|
||||||
|
|
||||||
patternLookup.resize(FREAK_NB_SCALES*FREAK_NB_ORIENTATION*FREAK_NB_POINTS);
|
patternLookup.resize(FREAK_NB_SCALES*FREAK_NB_ORIENTATION*FREAK_NB_POINTS);
|
||||||
double scaleStep = pow(2.0, (double)(nOctaves)/FREAK_NB_SCALES ); // 2 ^ ( (nOctaves-1) /nbScales)
|
double scaleStep = std::pow(2.0, (double)(nOctaves)/FREAK_NB_SCALES ); // 2 ^ ( (nOctaves-1) /nbScales)
|
||||||
double scalingFactor, alpha, beta, theta = 0;
|
double scalingFactor, alpha, beta, theta = 0;
|
||||||
|
|
||||||
// pattern definition, radius normalized to 1.0 (outer point position+sigma=1.0)
|
// pattern definition, radius normalized to 1.0 (outer point position+sigma=1.0)
|
||||||
@ -132,7 +132,7 @@ void FREAK::buildPattern()
|
|||||||
// fill the lookup table
|
// fill the lookup table
|
||||||
for( int scaleIdx=0; scaleIdx < FREAK_NB_SCALES; ++scaleIdx ) {
|
for( int scaleIdx=0; scaleIdx < FREAK_NB_SCALES; ++scaleIdx ) {
|
||||||
patternSizes[scaleIdx] = 0; // proper initialization
|
patternSizes[scaleIdx] = 0; // proper initialization
|
||||||
scalingFactor = pow(scaleStep,scaleIdx); //scale of the pattern, scaleStep ^ scaleIdx
|
scalingFactor = std::pow(scaleStep,scaleIdx); //scale of the pattern, scaleStep ^ scaleIdx
|
||||||
|
|
||||||
for( int orientationIdx = 0; orientationIdx < FREAK_NB_ORIENTATION; ++orientationIdx ) {
|
for( int orientationIdx = 0; orientationIdx < FREAK_NB_ORIENTATION; ++orientationIdx ) {
|
||||||
theta = double(orientationIdx)* 2*CV_PI/double(FREAK_NB_ORIENTATION); // orientation of the pattern
|
theta = double(orientationIdx)* 2*CV_PI/double(FREAK_NB_ORIENTATION); // orientation of the pattern
|
||||||
@ -239,7 +239,7 @@ void FREAK::computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat
|
|||||||
if( scaleNormalized ) {
|
if( scaleNormalized ) {
|
||||||
for( size_t k = keypoints.size(); k--; ) {
|
for( size_t k = keypoints.size(); k--; ) {
|
||||||
//Is k non-zero? If so, decrement it and continue"
|
//Is k non-zero? If so, decrement it and continue"
|
||||||
kpScaleIdx[k] = max( (int)(log(keypoints[k].size/FREAK_SMALLEST_KP_SIZE)*sizeCst+0.5) ,0);
|
kpScaleIdx[k] = std::max( (int)(std::log(keypoints[k].size/FREAK_SMALLEST_KP_SIZE)*sizeCst+0.5) ,0);
|
||||||
if( kpScaleIdx[k] >= FREAK_NB_SCALES )
|
if( kpScaleIdx[k] >= FREAK_NB_SCALES )
|
||||||
kpScaleIdx[k] = FREAK_NB_SCALES-1;
|
kpScaleIdx[k] = FREAK_NB_SCALES-1;
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ void FREAK::computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const int scIdx = max( (int)(1.0986122886681*sizeCst+0.5) ,0);
|
const int scIdx = std::max( (int)(1.0986122886681*sizeCst+0.5) ,0);
|
||||||
for( size_t k = keypoints.size(); k--; ) {
|
for( size_t k = keypoints.size(); k--; ) {
|
||||||
kpScaleIdx[k] = scIdx; // equivalent to the formule when the scale is normalized with a constant size of keypoints[k].size=3*SMALLEST_KP_SIZE
|
kpScaleIdx[k] = scIdx; // equivalent to the formule when the scale is normalized with a constant size of keypoints[k].size=3*SMALLEST_KP_SIZE
|
||||||
if( kpScaleIdx[k] >= FREAK_NB_SCALES ) {
|
if( kpScaleIdx[k] >= FREAK_NB_SCALES ) {
|
||||||
@ -495,7 +495,7 @@ uchar FREAK::meanIntensity( const cv::Mat& image, const cv::Mat& integral,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pair selection algorithm from a set of training images and corresponding keypoints
|
// pair selection algorithm from a set of training images and corresponding keypoints
|
||||||
vector<int> FREAK::selectPairs(const std::vector<Mat>& images
|
std::vector<int> FREAK::selectPairs(const std::vector<Mat>& images
|
||||||
, std::vector<std::vector<KeyPoint> >& keypoints
|
, std::vector<std::vector<KeyPoint> >& keypoints
|
||||||
, const double corrTresh
|
, const double corrTresh
|
||||||
, bool verbose )
|
, bool verbose )
|
||||||
|
@ -58,7 +58,7 @@ size_t KeyPoint::hash() const
|
|||||||
return _Val;
|
return _Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(FileStorage& fs, const string& objname, const vector<KeyPoint>& keypoints)
|
void write(FileStorage& fs, const std::string& objname, const std::vector<KeyPoint>& keypoints)
|
||||||
{
|
{
|
||||||
WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW);
|
WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ void write(FileStorage& fs, const string& objname, const vector<KeyPoint>& keypo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void read(const FileNode& node, vector<KeyPoint>& keypoints)
|
void read(const FileNode& node, std::vector<KeyPoint>& keypoints)
|
||||||
{
|
{
|
||||||
keypoints.resize(0);
|
keypoints.resize(0);
|
||||||
FileNodeIterator it = node.begin(), it_end = node.end();
|
FileNodeIterator it = node.begin(), it_end = node.end();
|
||||||
@ -91,7 +91,7 @@ void read(const FileNode& node, vector<KeyPoint>& keypoints)
|
|||||||
|
|
||||||
|
|
||||||
void KeyPoint::convert(const std::vector<KeyPoint>& keypoints, std::vector<Point2f>& points2f,
|
void KeyPoint::convert(const std::vector<KeyPoint>& keypoints, std::vector<Point2f>& points2f,
|
||||||
const vector<int>& keypointIndexes)
|
const std::vector<int>& keypointIndexes)
|
||||||
{
|
{
|
||||||
if( keypointIndexes.empty() )
|
if( keypointIndexes.empty() )
|
||||||
{
|
{
|
||||||
@ -138,8 +138,8 @@ float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 )
|
|||||||
float ovrl = 0.f;
|
float ovrl = 0.f;
|
||||||
|
|
||||||
// one circle is completely encovered by the other => no intersection points!
|
// one circle is completely encovered by the other => no intersection points!
|
||||||
if( min( a, b ) + c <= max( a, b ) )
|
if( std::min( a, b ) + c <= std::max( a, b ) )
|
||||||
return min( a_2, b_2 ) / max( a_2, b_2 );
|
return std::min( a_2, b_2 ) / std::max( a_2, b_2 );
|
||||||
|
|
||||||
if( c < a + b ) // circles intersect
|
if( c < a + b ) // circles intersect
|
||||||
{
|
{
|
||||||
@ -189,7 +189,7 @@ struct KeypointResponseGreater
|
|||||||
};
|
};
|
||||||
|
|
||||||
// takes keypoints and culls them by the response
|
// takes keypoints and culls them by the response
|
||||||
void KeyPointsFilter::retainBest(vector<KeyPoint>& keypoints, int n_points)
|
void KeyPointsFilter::retainBest(std::vector<KeyPoint>& keypoints, int n_points)
|
||||||
{
|
{
|
||||||
//this is only necessary if the keypoints size is greater than the number of desired points.
|
//this is only necessary if the keypoints size is greater than the number of desired points.
|
||||||
if( n_points > 0 && keypoints.size() > (size_t)n_points )
|
if( n_points > 0 && keypoints.size() > (size_t)n_points )
|
||||||
@ -204,7 +204,7 @@ void KeyPointsFilter::retainBest(vector<KeyPoint>& keypoints, int n_points)
|
|||||||
//this is the boundary response, and in the case of FAST may be ambigous
|
//this is the boundary response, and in the case of FAST may be ambigous
|
||||||
float ambiguous_response = keypoints[n_points - 1].response;
|
float ambiguous_response = keypoints[n_points - 1].response;
|
||||||
//use std::partition to grab all of the keypoints with the boundary response.
|
//use std::partition to grab all of the keypoints with the boundary response.
|
||||||
vector<KeyPoint>::const_iterator new_end =
|
std::vector<KeyPoint>::const_iterator new_end =
|
||||||
std::partition(keypoints.begin() + n_points, keypoints.end(),
|
std::partition(keypoints.begin() + n_points, keypoints.end(),
|
||||||
KeypointResponseGreaterThanThreshold(ambiguous_response));
|
KeypointResponseGreaterThanThreshold(ambiguous_response));
|
||||||
//resize the keypoints, given this new end point. nth_element and partition reordered the points inplace
|
//resize the keypoints, given this new end point. nth_element and partition reordered the points inplace
|
||||||
@ -225,7 +225,7 @@ struct RoiPredicate
|
|||||||
Rect r;
|
Rect r;
|
||||||
};
|
};
|
||||||
|
|
||||||
void KeyPointsFilter::runByImageBorder( vector<KeyPoint>& keypoints, Size imageSize, int borderSize )
|
void KeyPointsFilter::runByImageBorder( std::vector<KeyPoint>& keypoints, Size imageSize, int borderSize )
|
||||||
{
|
{
|
||||||
if( borderSize > 0)
|
if( borderSize > 0)
|
||||||
{
|
{
|
||||||
@ -253,7 +253,7 @@ struct SizePredicate
|
|||||||
float minSize, maxSize;
|
float minSize, maxSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
void KeyPointsFilter::runByKeypointSize( vector<KeyPoint>& keypoints, float minSize, float maxSize )
|
void KeyPointsFilter::runByKeypointSize( std::vector<KeyPoint>& keypoints, float minSize, float maxSize )
|
||||||
{
|
{
|
||||||
CV_Assert( minSize >= 0 );
|
CV_Assert( minSize >= 0 );
|
||||||
CV_Assert( maxSize >= 0);
|
CV_Assert( maxSize >= 0);
|
||||||
@ -277,7 +277,7 @@ private:
|
|||||||
MaskPredicate& operator=(const MaskPredicate&);
|
MaskPredicate& operator=(const MaskPredicate&);
|
||||||
};
|
};
|
||||||
|
|
||||||
void KeyPointsFilter::runByPixelsMask( vector<KeyPoint>& keypoints, const Mat& mask )
|
void KeyPointsFilter::runByPixelsMask( std::vector<KeyPoint>& keypoints, const Mat& mask )
|
||||||
{
|
{
|
||||||
if( mask.empty() )
|
if( mask.empty() )
|
||||||
return;
|
return;
|
||||||
@ -287,7 +287,7 @@ void KeyPointsFilter::runByPixelsMask( vector<KeyPoint>& keypoints, const Mat& m
|
|||||||
|
|
||||||
struct KeyPoint_LessThan
|
struct KeyPoint_LessThan
|
||||||
{
|
{
|
||||||
KeyPoint_LessThan(const vector<KeyPoint>& _kp) : kp(&_kp) {}
|
KeyPoint_LessThan(const std::vector<KeyPoint>& _kp) : kp(&_kp) {}
|
||||||
bool operator()(int i, int j) const
|
bool operator()(int i, int j) const
|
||||||
{
|
{
|
||||||
const KeyPoint& kp1 = (*kp)[i];
|
const KeyPoint& kp1 = (*kp)[i];
|
||||||
@ -309,14 +309,14 @@ struct KeyPoint_LessThan
|
|||||||
|
|
||||||
return i < j;
|
return i < j;
|
||||||
}
|
}
|
||||||
const vector<KeyPoint>* kp;
|
const std::vector<KeyPoint>* kp;
|
||||||
};
|
};
|
||||||
|
|
||||||
void KeyPointsFilter::removeDuplicated( vector<KeyPoint>& keypoints )
|
void KeyPointsFilter::removeDuplicated( std::vector<KeyPoint>& keypoints )
|
||||||
{
|
{
|
||||||
int i, j, n = (int)keypoints.size();
|
int i, j, n = (int)keypoints.size();
|
||||||
vector<int> kpidx(n);
|
std::vector<int> kpidx(n);
|
||||||
vector<uchar> mask(n, (uchar)1);
|
std::vector<uchar> mask(n, (uchar)1);
|
||||||
|
|
||||||
for( i = 0; i < n; i++ )
|
for( i = 0; i < n; i++ )
|
||||||
kpidx[i] = i;
|
kpidx[i] = i;
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
Mat windowedMatchingMask( const vector<KeyPoint>& keypoints1, const vector<KeyPoint>& keypoints2,
|
Mat windowedMatchingMask( const std::vector<KeyPoint>& keypoints1, const std::vector<KeyPoint>& keypoints2,
|
||||||
float maxDeltaX, float maxDeltaY )
|
float maxDeltaX, float maxDeltaY )
|
||||||
{
|
{
|
||||||
if( keypoints1.empty() || keypoints2.empty() )
|
if( keypoints1.empty() || keypoints2.empty() )
|
||||||
@ -83,7 +83,7 @@ DescriptorMatcher::DescriptorCollection::DescriptorCollection( const DescriptorC
|
|||||||
DescriptorMatcher::DescriptorCollection::~DescriptorCollection()
|
DescriptorMatcher::DescriptorCollection::~DescriptorCollection()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void DescriptorMatcher::DescriptorCollection::set( const vector<Mat>& descriptors )
|
void DescriptorMatcher::DescriptorCollection::set( const std::vector<Mat>& descriptors )
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ int DescriptorMatcher::DescriptorCollection::size() const
|
|||||||
/*
|
/*
|
||||||
* DescriptorMatcher
|
* DescriptorMatcher
|
||||||
*/
|
*/
|
||||||
static void convertMatches( const vector<vector<DMatch> >& knnMatches, vector<DMatch>& matches )
|
static void convertMatches( const std::vector<std::vector<DMatch> >& knnMatches, std::vector<DMatch>& matches )
|
||||||
{
|
{
|
||||||
matches.clear();
|
matches.clear();
|
||||||
matches.reserve( knnMatches.size() );
|
matches.reserve( knnMatches.size() );
|
||||||
@ -190,12 +190,12 @@ static void convertMatches( const vector<vector<DMatch> >& knnMatches, vector<DM
|
|||||||
DescriptorMatcher::~DescriptorMatcher()
|
DescriptorMatcher::~DescriptorMatcher()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void DescriptorMatcher::add( const vector<Mat>& descriptors )
|
void DescriptorMatcher::add( const std::vector<Mat>& descriptors )
|
||||||
{
|
{
|
||||||
trainDescCollection.insert( trainDescCollection.end(), descriptors.begin(), descriptors.end() );
|
trainDescCollection.insert( trainDescCollection.end(), descriptors.begin(), descriptors.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<Mat>& DescriptorMatcher::getTrainDescriptors() const
|
const std::vector<Mat>& DescriptorMatcher::getTrainDescriptors() const
|
||||||
{
|
{
|
||||||
return trainDescCollection;
|
return trainDescCollection;
|
||||||
}
|
}
|
||||||
@ -213,37 +213,37 @@ bool DescriptorMatcher::empty() const
|
|||||||
void DescriptorMatcher::train()
|
void DescriptorMatcher::train()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void DescriptorMatcher::match( const Mat& queryDescriptors, const Mat& trainDescriptors, vector<DMatch>& matches, const Mat& mask ) const
|
void DescriptorMatcher::match( const Mat& queryDescriptors, const Mat& trainDescriptors, std::vector<DMatch>& matches, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
Ptr<DescriptorMatcher> tempMatcher = clone(true);
|
Ptr<DescriptorMatcher> tempMatcher = clone(true);
|
||||||
tempMatcher->add( vector<Mat>(1, trainDescriptors) );
|
tempMatcher->add( std::vector<Mat>(1, trainDescriptors) );
|
||||||
tempMatcher->match( queryDescriptors, matches, vector<Mat>(1, mask) );
|
tempMatcher->match( queryDescriptors, matches, std::vector<Mat>(1, mask) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, vector<vector<DMatch> >& matches, int knn,
|
void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, std::vector<std::vector<DMatch> >& matches, int knn,
|
||||||
const Mat& mask, bool compactResult ) const
|
const Mat& mask, bool compactResult ) const
|
||||||
{
|
{
|
||||||
Ptr<DescriptorMatcher> tempMatcher = clone(true);
|
Ptr<DescriptorMatcher> tempMatcher = clone(true);
|
||||||
tempMatcher->add( vector<Mat>(1, trainDescriptors) );
|
tempMatcher->add( std::vector<Mat>(1, trainDescriptors) );
|
||||||
tempMatcher->knnMatch( queryDescriptors, matches, knn, vector<Mat>(1, mask), compactResult );
|
tempMatcher->knnMatch( queryDescriptors, matches, knn, std::vector<Mat>(1, mask), compactResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
|
void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const Mat& mask, bool compactResult ) const
|
const Mat& mask, bool compactResult ) const
|
||||||
{
|
{
|
||||||
Ptr<DescriptorMatcher> tempMatcher = clone(true);
|
Ptr<DescriptorMatcher> tempMatcher = clone(true);
|
||||||
tempMatcher->add( vector<Mat>(1, trainDescriptors) );
|
tempMatcher->add( std::vector<Mat>(1, trainDescriptors) );
|
||||||
tempMatcher->radiusMatch( queryDescriptors, matches, maxDistance, vector<Mat>(1, mask), compactResult );
|
tempMatcher->radiusMatch( queryDescriptors, matches, maxDistance, std::vector<Mat>(1, mask), compactResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorMatcher::match( const Mat& queryDescriptors, vector<DMatch>& matches, const vector<Mat>& masks )
|
void DescriptorMatcher::match( const Mat& queryDescriptors, std::vector<DMatch>& matches, const std::vector<Mat>& masks )
|
||||||
{
|
{
|
||||||
vector<vector<DMatch> > knnMatches;
|
std::vector<std::vector<DMatch> > knnMatches;
|
||||||
knnMatch( queryDescriptors, knnMatches, 1, masks, true /*compactResult*/ );
|
knnMatch( queryDescriptors, knnMatches, 1, masks, true /*compactResult*/ );
|
||||||
convertMatches( knnMatches, matches );
|
convertMatches( knnMatches, matches );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorMatcher::checkMasks( const vector<Mat>& masks, int queryDescriptorsCount ) const
|
void DescriptorMatcher::checkMasks( const std::vector<Mat>& masks, int queryDescriptorsCount ) const
|
||||||
{
|
{
|
||||||
if( isMaskSupported() && !masks.empty() )
|
if( isMaskSupported() && !masks.empty() )
|
||||||
{
|
{
|
||||||
@ -262,8 +262,8 @@ void DescriptorMatcher::checkMasks( const vector<Mat>& masks, int queryDescripto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int knn,
|
void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, int knn,
|
||||||
const vector<Mat>& masks, bool compactResult )
|
const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
matches.clear();
|
matches.clear();
|
||||||
if( empty() || queryDescriptors.empty() )
|
if( empty() || queryDescriptors.empty() )
|
||||||
@ -277,8 +277,8 @@ void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, vector<vector<DMa
|
|||||||
knnMatchImpl( queryDescriptors, matches, knn, masks, compactResult );
|
knnMatchImpl( queryDescriptors, matches, knn, masks, compactResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
|
void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks, bool compactResult )
|
const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
matches.clear();
|
matches.clear();
|
||||||
if( empty() || queryDescriptors.empty() )
|
if( empty() || queryDescriptors.empty() )
|
||||||
@ -303,7 +303,7 @@ bool DescriptorMatcher::isPossibleMatch( const Mat& mask, int queryIdx, int trai
|
|||||||
return mask.empty() || mask.at<uchar>(queryIdx, trainIdx);
|
return mask.empty() || mask.at<uchar>(queryIdx, trainIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DescriptorMatcher::isMaskedOut( const vector<Mat>& masks, int queryIdx )
|
bool DescriptorMatcher::isMaskedOut( const std::vector<Mat>& masks, int queryIdx )
|
||||||
{
|
{
|
||||||
size_t outCount = 0;
|
size_t outCount = 0;
|
||||||
for( size_t i = 0; i < masks.size(); i++ )
|
for( size_t i = 0; i < masks.size(); i++ )
|
||||||
@ -337,8 +337,8 @@ Ptr<DescriptorMatcher> BFMatcher::clone( bool emptyTrainData ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int knn,
|
void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, int knn,
|
||||||
const vector<Mat>& masks, bool compactResult )
|
const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
const int IMGIDX_SHIFT = 18;
|
const int IMGIDX_SHIFT = 18;
|
||||||
const int IMGIDX_ONE = (1 << IMGIDX_SHIFT);
|
const int IMGIDX_ONE = (1 << IMGIDX_SHIFT);
|
||||||
@ -380,8 +380,8 @@ void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch>
|
|||||||
const float* distptr = dist.ptr<float>(qIdx);
|
const float* distptr = dist.ptr<float>(qIdx);
|
||||||
const int* nidxptr = nidx.ptr<int>(qIdx);
|
const int* nidxptr = nidx.ptr<int>(qIdx);
|
||||||
|
|
||||||
matches.push_back( vector<DMatch>() );
|
matches.push_back( std::vector<DMatch>() );
|
||||||
vector<DMatch>& mq = matches.back();
|
std::vector<DMatch>& mq = matches.back();
|
||||||
mq.reserve(knn);
|
mq.reserve(knn);
|
||||||
|
|
||||||
for( int k = 0; k < nidx.cols; k++ )
|
for( int k = 0; k < nidx.cols; k++ )
|
||||||
@ -398,8 +398,8 @@ void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches,
|
void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches,
|
||||||
float maxDistance, const vector<Mat>& masks, bool compactResult )
|
float maxDistance, const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
if( queryDescriptors.empty() || trainDescCollection.empty() )
|
if( queryDescriptors.empty() || trainDescCollection.empty() )
|
||||||
{
|
{
|
||||||
@ -428,7 +428,7 @@ void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, vector<vector<DMat
|
|||||||
{
|
{
|
||||||
const float* distptr = distf.ptr<float>(qIdx);
|
const float* distptr = distf.ptr<float>(qIdx);
|
||||||
|
|
||||||
vector<DMatch>& mq = matches[qIdx];
|
std::vector<DMatch>& mq = matches[qIdx];
|
||||||
for( int k = 0; k < distf.cols; k++ )
|
for( int k = 0; k < distf.cols; k++ )
|
||||||
{
|
{
|
||||||
if( distptr[k] <= maxDistance )
|
if( distptr[k] <= maxDistance )
|
||||||
@ -456,7 +456,7 @@ void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, vector<vector<DMat
|
|||||||
/*
|
/*
|
||||||
* Factory function for DescriptorMatcher creating
|
* Factory function for DescriptorMatcher creating
|
||||||
*/
|
*/
|
||||||
Ptr<DescriptorMatcher> DescriptorMatcher::create( const string& descriptorMatcherType )
|
Ptr<DescriptorMatcher> DescriptorMatcher::create( const std::string& descriptorMatcherType )
|
||||||
{
|
{
|
||||||
DescriptorMatcher* dm = 0;
|
DescriptorMatcher* dm = 0;
|
||||||
if( !descriptorMatcherType.compare( "FlannBased" ) )
|
if( !descriptorMatcherType.compare( "FlannBased" ) )
|
||||||
@ -501,7 +501,7 @@ FlannBasedMatcher::FlannBasedMatcher( const Ptr<flann::IndexParams>& _indexParam
|
|||||||
CV_Assert( !_searchParams.empty() );
|
CV_Assert( !_searchParams.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlannBasedMatcher::add( const vector<Mat>& descriptors )
|
void FlannBasedMatcher::add( const std::vector<Mat>& descriptors )
|
||||||
{
|
{
|
||||||
DescriptorMatcher::add( descriptors );
|
DescriptorMatcher::add( descriptors );
|
||||||
for( size_t i = 0; i < descriptors.size(); i++ )
|
for( size_t i = 0; i < descriptors.size(); i++ )
|
||||||
@ -740,7 +740,7 @@ Ptr<DescriptorMatcher> FlannBasedMatcher::clone( bool emptyTrainData ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FlannBasedMatcher::convertToDMatches( const DescriptorCollection& collection, const Mat& indices, const Mat& dists,
|
void FlannBasedMatcher::convertToDMatches( const DescriptorCollection& collection, const Mat& indices, const Mat& dists,
|
||||||
vector<vector<DMatch> >& matches )
|
std::vector<std::vector<DMatch> >& matches )
|
||||||
{
|
{
|
||||||
matches.resize( indices.rows );
|
matches.resize( indices.rows );
|
||||||
for( int i = 0; i < indices.rows; i++ )
|
for( int i = 0; i < indices.rows; i++ )
|
||||||
@ -763,8 +763,8 @@ void FlannBasedMatcher::convertToDMatches( const DescriptorCollection& collectio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlannBasedMatcher::knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int knn,
|
void FlannBasedMatcher::knnMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, int knn,
|
||||||
const vector<Mat>& /*masks*/, bool /*compactResult*/ )
|
const std::vector<Mat>& /*masks*/, bool /*compactResult*/ )
|
||||||
{
|
{
|
||||||
Mat indices( queryDescriptors.rows, knn, CV_32SC1 );
|
Mat indices( queryDescriptors.rows, knn, CV_32SC1 );
|
||||||
Mat dists( queryDescriptors.rows, knn, CV_32FC1);
|
Mat dists( queryDescriptors.rows, knn, CV_32FC1);
|
||||||
@ -773,8 +773,8 @@ void FlannBasedMatcher::knnMatchImpl( const Mat& queryDescriptors, vector<vector
|
|||||||
convertToDMatches( mergedDescriptors, indices, dists, matches );
|
convertToDMatches( mergedDescriptors, indices, dists, matches );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlannBasedMatcher::radiusMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
|
void FlannBasedMatcher::radiusMatchImpl( const Mat& queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& /*masks*/, bool /*compactResult*/ )
|
const std::vector<Mat>& /*masks*/, bool /*compactResult*/ )
|
||||||
{
|
{
|
||||||
const int count = mergedDescriptors.size(); // TODO do count as param?
|
const int count = mergedDescriptors.size(); // TODO do count as param?
|
||||||
Mat indices( queryDescriptors.rows, count, CV_32SC1, Scalar::all(-1) );
|
Mat indices( queryDescriptors.rows, count, CV_32SC1, Scalar::all(-1) );
|
||||||
@ -812,8 +812,8 @@ GenericDescriptorMatcher::KeyPointCollection::KeyPointCollection( const KeyPoint
|
|||||||
std::copy( collection.startIndices.begin(), collection.startIndices.end(), startIndices.begin() );
|
std::copy( collection.startIndices.begin(), collection.startIndices.end(), startIndices.begin() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::KeyPointCollection::add( const vector<Mat>& _images,
|
void GenericDescriptorMatcher::KeyPointCollection::add( const std::vector<Mat>& _images,
|
||||||
const vector<vector<KeyPoint> >& _points )
|
const std::vector<std::vector<KeyPoint> >& _points )
|
||||||
{
|
{
|
||||||
CV_Assert( !_images.empty() );
|
CV_Assert( !_images.empty() );
|
||||||
CV_Assert( _images.size() == _points.size() );
|
CV_Assert( _images.size() == _points.size() );
|
||||||
@ -856,12 +856,12 @@ size_t GenericDescriptorMatcher::KeyPointCollection::imageCount() const
|
|||||||
return images.size();
|
return images.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<vector<KeyPoint> >& GenericDescriptorMatcher::KeyPointCollection::getKeypoints() const
|
const std::vector<std::vector<KeyPoint> >& GenericDescriptorMatcher::KeyPointCollection::getKeypoints() const
|
||||||
{
|
{
|
||||||
return keypoints;
|
return keypoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<KeyPoint>& GenericDescriptorMatcher::KeyPointCollection::getKeypoints( int imgIdx ) const
|
const std::vector<KeyPoint>& GenericDescriptorMatcher::KeyPointCollection::getKeypoints( int imgIdx ) const
|
||||||
{
|
{
|
||||||
CV_Assert( imgIdx < (int)imageCount() );
|
CV_Assert( imgIdx < (int)imageCount() );
|
||||||
return keypoints[imgIdx];
|
return keypoints[imgIdx];
|
||||||
@ -897,7 +897,7 @@ void GenericDescriptorMatcher::KeyPointCollection::getLocalIdx( int globalPointI
|
|||||||
localPointIdx = globalPointIdx - startIndices[imgIdx];
|
localPointIdx = globalPointIdx - startIndices[imgIdx];
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<Mat>& GenericDescriptorMatcher::KeyPointCollection::getImages() const
|
const std::vector<Mat>& GenericDescriptorMatcher::KeyPointCollection::getImages() const
|
||||||
{
|
{
|
||||||
return images;
|
return images;
|
||||||
}
|
}
|
||||||
@ -917,8 +917,8 @@ GenericDescriptorMatcher::GenericDescriptorMatcher()
|
|||||||
GenericDescriptorMatcher::~GenericDescriptorMatcher()
|
GenericDescriptorMatcher::~GenericDescriptorMatcher()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::add( const vector<Mat>& images,
|
void GenericDescriptorMatcher::add( const std::vector<Mat>& images,
|
||||||
vector<vector<KeyPoint> >& keypoints )
|
std::vector<std::vector<KeyPoint> >& keypoints )
|
||||||
{
|
{
|
||||||
CV_Assert( !images.empty() );
|
CV_Assert( !images.empty() );
|
||||||
CV_Assert( images.size() == keypoints.size() );
|
CV_Assert( images.size() == keypoints.size() );
|
||||||
@ -933,12 +933,12 @@ void GenericDescriptorMatcher::add( const vector<Mat>& images,
|
|||||||
trainPointCollection.add( images, keypoints );
|
trainPointCollection.add( images, keypoints );
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<Mat>& GenericDescriptorMatcher::getTrainImages() const
|
const std::vector<Mat>& GenericDescriptorMatcher::getTrainImages() const
|
||||||
{
|
{
|
||||||
return trainPointCollection.getImages();
|
return trainPointCollection.getImages();
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<vector<KeyPoint> >& GenericDescriptorMatcher::getTrainKeypoints() const
|
const std::vector<std::vector<KeyPoint> >& GenericDescriptorMatcher::getTrainKeypoints() const
|
||||||
{
|
{
|
||||||
return trainPointCollection.getKeypoints();
|
return trainPointCollection.getKeypoints();
|
||||||
}
|
}
|
||||||
@ -951,10 +951,10 @@ void GenericDescriptorMatcher::clear()
|
|||||||
void GenericDescriptorMatcher::train()
|
void GenericDescriptorMatcher::train()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::classify( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void GenericDescriptorMatcher::classify( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints ) const
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints ) const
|
||||||
{
|
{
|
||||||
vector<DMatch> matches;
|
std::vector<DMatch> matches;
|
||||||
match( queryImage, queryKeypoints, trainImage, trainKeypoints, matches );
|
match( queryImage, queryKeypoints, trainImage, trainKeypoints, matches );
|
||||||
|
|
||||||
// remap keypoint indices to descriptors
|
// remap keypoint indices to descriptors
|
||||||
@ -962,9 +962,9 @@ void GenericDescriptorMatcher::classify( const Mat& queryImage, vector<KeyPoint>
|
|||||||
queryKeypoints[matches[i].queryIdx].class_id = trainKeypoints[matches[i].trainIdx].class_id;
|
queryKeypoints[matches[i].queryIdx].class_id = trainKeypoints[matches[i].trainIdx].class_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::classify( const Mat& queryImage, vector<KeyPoint>& queryKeypoints )
|
void GenericDescriptorMatcher::classify( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints )
|
||||||
{
|
{
|
||||||
vector<DMatch> matches;
|
std::vector<DMatch> matches;
|
||||||
match( queryImage, queryKeypoints, matches );
|
match( queryImage, queryKeypoints, matches );
|
||||||
|
|
||||||
// remap keypoint indices to descriptors
|
// remap keypoint indices to descriptors
|
||||||
@ -972,51 +972,51 @@ void GenericDescriptorMatcher::classify( const Mat& queryImage, vector<KeyPoint>
|
|||||||
queryKeypoints[matches[i].queryIdx].class_id = trainPointCollection.getKeyPoint( matches[i].trainIdx, matches[i].trainIdx ).class_id;
|
queryKeypoints[matches[i].queryIdx].class_id = trainPointCollection.getKeyPoint( matches[i].trainIdx, matches[i].trainIdx ).class_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void GenericDescriptorMatcher::match( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints,
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
|
||||||
vector<DMatch>& matches, const Mat& mask ) const
|
std::vector<DMatch>& matches, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
|
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
|
||||||
vector<vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
|
std::vector<std::vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
|
||||||
tempMatcher->add( vector<Mat>(1, trainImage), vecTrainPoints );
|
tempMatcher->add( std::vector<Mat>(1, trainImage), vecTrainPoints );
|
||||||
tempMatcher->match( queryImage, queryKeypoints, matches, vector<Mat>(1, mask) );
|
tempMatcher->match( queryImage, queryKeypoints, matches, std::vector<Mat>(1, mask) );
|
||||||
vecTrainPoints[0].swap( trainKeypoints );
|
vecTrainPoints[0].swap( trainKeypoints );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints,
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
|
||||||
vector<vector<DMatch> >& matches, int knn, const Mat& mask, bool compactResult ) const
|
std::vector<std::vector<DMatch> >& matches, int knn, const Mat& mask, bool compactResult ) const
|
||||||
{
|
{
|
||||||
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
|
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
|
||||||
vector<vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
|
std::vector<std::vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
|
||||||
tempMatcher->add( vector<Mat>(1, trainImage), vecTrainPoints );
|
tempMatcher->add( std::vector<Mat>(1, trainImage), vecTrainPoints );
|
||||||
tempMatcher->knnMatch( queryImage, queryKeypoints, matches, knn, vector<Mat>(1, mask), compactResult );
|
tempMatcher->knnMatch( queryImage, queryKeypoints, matches, knn, std::vector<Mat>(1, mask), compactResult );
|
||||||
vecTrainPoints[0].swap( trainKeypoints );
|
vecTrainPoints[0].swap( trainKeypoints );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
const Mat& trainImage, vector<KeyPoint>& trainKeypoints,
|
const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const Mat& mask, bool compactResult ) const
|
const Mat& mask, bool compactResult ) const
|
||||||
{
|
{
|
||||||
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
|
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
|
||||||
vector<vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
|
std::vector<std::vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
|
||||||
tempMatcher->add( vector<Mat>(1, trainImage), vecTrainPoints );
|
tempMatcher->add( std::vector<Mat>(1, trainImage), vecTrainPoints );
|
||||||
tempMatcher->radiusMatch( queryImage, queryKeypoints, matches, maxDistance, vector<Mat>(1, mask), compactResult );
|
tempMatcher->radiusMatch( queryImage, queryKeypoints, matches, maxDistance, std::vector<Mat>(1, mask), compactResult );
|
||||||
vecTrainPoints[0].swap( trainKeypoints );
|
vecTrainPoints[0].swap( trainKeypoints );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void GenericDescriptorMatcher::match( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<DMatch>& matches, const vector<Mat>& masks )
|
std::vector<DMatch>& matches, const std::vector<Mat>& masks )
|
||||||
{
|
{
|
||||||
vector<vector<DMatch> > knnMatches;
|
std::vector<std::vector<DMatch> > knnMatches;
|
||||||
knnMatch( queryImage, queryKeypoints, knnMatches, 1, masks, false );
|
knnMatch( queryImage, queryKeypoints, knnMatches, 1, masks, false );
|
||||||
convertMatches( knnMatches, matches );
|
convertMatches( knnMatches, matches );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, int knn,
|
std::vector<std::vector<DMatch> >& matches, int knn,
|
||||||
const vector<Mat>& masks, bool compactResult )
|
const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
matches.clear();
|
matches.clear();
|
||||||
|
|
||||||
@ -1030,9 +1030,9 @@ void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector<KeyPoint>
|
|||||||
knnMatchImpl( queryImage, queryKeypoints, matches, knn, masks, compactResult );
|
knnMatchImpl( queryImage, queryKeypoints, matches, knn, masks, compactResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks, bool compactResult )
|
const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
matches.clear();
|
matches.clear();
|
||||||
|
|
||||||
@ -1060,8 +1060,8 @@ bool GenericDescriptorMatcher::empty() const
|
|||||||
/*
|
/*
|
||||||
* Factory function for GenericDescriptorMatch creating
|
* Factory function for GenericDescriptorMatch creating
|
||||||
*/
|
*/
|
||||||
Ptr<GenericDescriptorMatcher> GenericDescriptorMatcher::create( const string& genericDescritptorMatcherType,
|
Ptr<GenericDescriptorMatcher> GenericDescriptorMatcher::create( const std::string& genericDescritptorMatcherType,
|
||||||
const string ¶msFilename )
|
const std::string ¶msFilename )
|
||||||
{
|
{
|
||||||
Ptr<GenericDescriptorMatcher> descriptorMatcher =
|
Ptr<GenericDescriptorMatcher> descriptorMatcher =
|
||||||
Algorithm::create<GenericDescriptorMatcher>("DescriptorMatcher." + genericDescritptorMatcherType);
|
Algorithm::create<GenericDescriptorMatcher>("DescriptorMatcher." + genericDescritptorMatcherType);
|
||||||
@ -1092,10 +1092,10 @@ VectorDescriptorMatcher::VectorDescriptorMatcher( const Ptr<DescriptorExtractor>
|
|||||||
VectorDescriptorMatcher::~VectorDescriptorMatcher()
|
VectorDescriptorMatcher::~VectorDescriptorMatcher()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void VectorDescriptorMatcher::add( const vector<Mat>& imgCollection,
|
void VectorDescriptorMatcher::add( const std::vector<Mat>& imgCollection,
|
||||||
vector<vector<KeyPoint> >& pointCollection )
|
std::vector<std::vector<KeyPoint> >& pointCollection )
|
||||||
{
|
{
|
||||||
vector<Mat> descriptors;
|
std::vector<Mat> descriptors;
|
||||||
extractor->compute( imgCollection, pointCollection, descriptors );
|
extractor->compute( imgCollection, pointCollection, descriptors );
|
||||||
|
|
||||||
matcher->add( descriptors );
|
matcher->add( descriptors );
|
||||||
@ -1120,18 +1120,18 @@ bool VectorDescriptorMatcher::isMaskSupported()
|
|||||||
return matcher->isMaskSupported();
|
return matcher->isMaskSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VectorDescriptorMatcher::knnMatchImpl( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void VectorDescriptorMatcher::knnMatchImpl( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, int knn,
|
std::vector<std::vector<DMatch> >& matches, int knn,
|
||||||
const vector<Mat>& masks, bool compactResult )
|
const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
Mat queryDescriptors;
|
Mat queryDescriptors;
|
||||||
extractor->compute( queryImage, queryKeypoints, queryDescriptors );
|
extractor->compute( queryImage, queryKeypoints, queryDescriptors );
|
||||||
matcher->knnMatch( queryDescriptors, matches, knn, masks, compactResult );
|
matcher->knnMatch( queryDescriptors, matches, knn, masks, compactResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
void VectorDescriptorMatcher::radiusMatchImpl( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
|
void VectorDescriptorMatcher::radiusMatchImpl( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
|
||||||
vector<vector<DMatch> >& matches, float maxDistance,
|
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||||
const vector<Mat>& masks, bool compactResult )
|
const std::vector<Mat>& masks, bool compactResult )
|
||||||
{
|
{
|
||||||
Mat queryDescriptors;
|
Mat queryDescriptors;
|
||||||
extractor->compute( queryImage, queryKeypoints, queryDescriptors );
|
extractor->compute( queryImage, queryKeypoints, queryDescriptors );
|
||||||
|
@ -1263,7 +1263,7 @@ MSER::MSER( int _delta, int _min_area, int _max_area,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSER::operator()( const Mat& image, vector<vector<Point> >& dstcontours, const Mat& mask ) const
|
void MSER::operator()( const Mat& image, std::vector<std::vector<Point> >& dstcontours, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
CvMat _image = image, _mask, *pmask = 0;
|
CvMat _image = image, _mask, *pmask = 0;
|
||||||
if( mask.data )
|
if( mask.data )
|
||||||
@ -1281,19 +1281,19 @@ void MSER::operator()( const Mat& image, vector<vector<Point> >& dstcontours, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MserFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void MserFeatureDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
vector<vector<Point> > msers;
|
std::vector<std::vector<Point> > msers;
|
||||||
|
|
||||||
(*this)(image, msers, mask);
|
(*this)(image, msers, mask);
|
||||||
|
|
||||||
vector<vector<Point> >::const_iterator contour_it = msers.begin();
|
std::vector<std::vector<Point> >::const_iterator contour_it = msers.begin();
|
||||||
Rect r(0, 0, image.cols, image.rows);
|
Rect r(0, 0, image.cols, image.rows);
|
||||||
for( ; contour_it != msers.end(); ++contour_it )
|
for( ; contour_it != msers.end(); ++contour_it )
|
||||||
{
|
{
|
||||||
// TODO check transformation from MSER region to KeyPoint
|
// TODO check transformation from MSER region to KeyPoint
|
||||||
RotatedRect rect = fitEllipse(Mat(*contour_it));
|
RotatedRect rect = fitEllipse(Mat(*contour_it));
|
||||||
float diam = sqrt(rect.size.height*rect.size.width);
|
float diam = std::sqrt(rect.size.height*rect.size.width);
|
||||||
|
|
||||||
if( diam > std::numeric_limits<float>::epsilon() && r.contains(rect.center) )
|
if( diam > std::numeric_limits<float>::epsilon() && r.contains(rect.center) )
|
||||||
keypoints.push_back( KeyPoint(rect.center, diam) );
|
keypoints.push_back( KeyPoint(rect.center, diam) );
|
||||||
|
@ -50,7 +50,7 @@ const int DESCRIPTOR_SIZE = 32;
|
|||||||
* blockSize x blockSize patch at given points in an image
|
* blockSize x blockSize patch at given points in an image
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
HarrisResponses(const Mat& img, vector<KeyPoint>& pts, int blockSize, float harris_k)
|
HarrisResponses(const Mat& img, std::vector<KeyPoint>& pts, int blockSize, float harris_k)
|
||||||
{
|
{
|
||||||
CV_Assert( img.type() == CV_8UC1 && blockSize*blockSize <= 2048 );
|
CV_Assert( img.type() == CV_8UC1 && blockSize*blockSize <= 2048 );
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ HarrisResponses(const Mat& img, vector<KeyPoint>& pts, int blockSize, float harr
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static float IC_Angle(const Mat& image, const int half_k, Point2f pt,
|
static float IC_Angle(const Mat& image, const int half_k, Point2f pt,
|
||||||
const vector<int> & u_max)
|
const std::vector<int> & u_max)
|
||||||
{
|
{
|
||||||
int m_01 = 0, m_10 = 0;
|
int m_01 = 0, m_10 = 0;
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ static void computeOrbDescriptor(const KeyPoint& kpt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void initializeOrbPattern( const Point* pattern0, vector<Point>& pattern, int ntuples, int tupleSize, int poolSize )
|
static void initializeOrbPattern( const Point* pattern0, std::vector<Point>& pattern, int ntuples, int tupleSize, int poolSize )
|
||||||
{
|
{
|
||||||
RNG rng(0x12345678);
|
RNG rng(0x12345678);
|
||||||
int i, k, k1;
|
int i, k, k1;
|
||||||
@ -577,7 +577,7 @@ int ORB::descriptorType() const
|
|||||||
* @param mask the mask to apply
|
* @param mask the mask to apply
|
||||||
* @param keypoints the resulting keypoints
|
* @param keypoints the resulting keypoints
|
||||||
*/
|
*/
|
||||||
void ORB::operator()(InputArray image, InputArray mask, vector<KeyPoint>& keypoints) const
|
void ORB::operator()(InputArray image, InputArray mask, std::vector<KeyPoint>& keypoints) const
|
||||||
{
|
{
|
||||||
(*this)(image, mask, keypoints, noArray(), false);
|
(*this)(image, mask, keypoints, noArray(), false);
|
||||||
}
|
}
|
||||||
@ -589,11 +589,11 @@ void ORB::operator()(InputArray image, InputArray mask, vector<KeyPoint>& keypoi
|
|||||||
* @param scale the scale at which we compute the orientation
|
* @param scale the scale at which we compute the orientation
|
||||||
* @param keypoints the resulting keypoints
|
* @param keypoints the resulting keypoints
|
||||||
*/
|
*/
|
||||||
static void computeOrientation(const Mat& image, vector<KeyPoint>& keypoints,
|
static void computeOrientation(const Mat& image, std::vector<KeyPoint>& keypoints,
|
||||||
int halfPatchSize, const vector<int>& umax)
|
int halfPatchSize, const std::vector<int>& umax)
|
||||||
{
|
{
|
||||||
// Process each keypoint
|
// Process each keypoint
|
||||||
for (vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
for (std::vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
||||||
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
||||||
{
|
{
|
||||||
keypoint->angle = IC_Angle(image, halfPatchSize, keypoint->pt, umax);
|
keypoint->angle = IC_Angle(image, halfPatchSize, keypoint->pt, umax);
|
||||||
@ -606,18 +606,18 @@ static void computeOrientation(const Mat& image, vector<KeyPoint>& keypoints,
|
|||||||
* @param mask_pyramid the masks to apply at every level
|
* @param mask_pyramid the masks to apply at every level
|
||||||
* @param keypoints the resulting keypoints, clustered per level
|
* @param keypoints the resulting keypoints, clustered per level
|
||||||
*/
|
*/
|
||||||
static void computeKeyPoints(const vector<Mat>& imagePyramid,
|
static void computeKeyPoints(const std::vector<Mat>& imagePyramid,
|
||||||
const vector<Mat>& maskPyramid,
|
const std::vector<Mat>& maskPyramid,
|
||||||
vector<vector<KeyPoint> >& allKeypoints,
|
std::vector<std::vector<KeyPoint> >& allKeypoints,
|
||||||
int nfeatures, int firstLevel, double scaleFactor,
|
int nfeatures, int firstLevel, double scaleFactor,
|
||||||
int edgeThreshold, int patchSize, int scoreType )
|
int edgeThreshold, int patchSize, int scoreType )
|
||||||
{
|
{
|
||||||
int nlevels = (int)imagePyramid.size();
|
int nlevels = (int)imagePyramid.size();
|
||||||
vector<int> nfeaturesPerLevel(nlevels);
|
std::vector<int> nfeaturesPerLevel(nlevels);
|
||||||
|
|
||||||
// fill the extractors and descriptors for the corresponding scales
|
// fill the extractors and descriptors for the corresponding scales
|
||||||
float factor = (float)(1.0 / scaleFactor);
|
float factor = (float)(1.0 / scaleFactor);
|
||||||
float ndesiredFeaturesPerScale = nfeatures*(1 - factor)/(1 - (float)pow((double)factor, (double)nlevels));
|
float ndesiredFeaturesPerScale = nfeatures*(1 - factor)/(1 - (float)std::pow((double)factor, (double)nlevels));
|
||||||
|
|
||||||
int sumFeatures = 0;
|
int sumFeatures = 0;
|
||||||
for( int level = 0; level < nlevels-1; level++ )
|
for( int level = 0; level < nlevels-1; level++ )
|
||||||
@ -633,12 +633,12 @@ static void computeKeyPoints(const vector<Mat>& imagePyramid,
|
|||||||
|
|
||||||
// pre-compute the end of a row in a circular patch
|
// pre-compute the end of a row in a circular patch
|
||||||
int halfPatchSize = patchSize / 2;
|
int halfPatchSize = patchSize / 2;
|
||||||
vector<int> umax(halfPatchSize + 2);
|
std::vector<int> umax(halfPatchSize + 2);
|
||||||
|
|
||||||
int v, v0, vmax = cvFloor(halfPatchSize * sqrt(2.f) / 2 + 1);
|
int v, v0, vmax = cvFloor(halfPatchSize * std::sqrt(2.f) / 2 + 1);
|
||||||
int vmin = cvCeil(halfPatchSize * sqrt(2.f) / 2);
|
int vmin = cvCeil(halfPatchSize * std::sqrt(2.f) / 2);
|
||||||
for (v = 0; v <= vmax; ++v)
|
for (v = 0; v <= vmax; ++v)
|
||||||
umax[v] = cvRound(sqrt((double)halfPatchSize * halfPatchSize - v * v));
|
umax[v] = cvRound(std::sqrt((double)halfPatchSize * halfPatchSize - v * v));
|
||||||
|
|
||||||
// Make sure we are symmetric
|
// Make sure we are symmetric
|
||||||
for (v = halfPatchSize, v0 = 0; v >= vmin; --v)
|
for (v = halfPatchSize, v0 = 0; v >= vmin; --v)
|
||||||
@ -656,7 +656,7 @@ static void computeKeyPoints(const vector<Mat>& imagePyramid,
|
|||||||
int featuresNum = nfeaturesPerLevel[level];
|
int featuresNum = nfeaturesPerLevel[level];
|
||||||
allKeypoints[level].reserve(featuresNum*2);
|
allKeypoints[level].reserve(featuresNum*2);
|
||||||
|
|
||||||
vector<KeyPoint> & keypoints = allKeypoints[level];
|
std::vector<KeyPoint> & keypoints = allKeypoints[level];
|
||||||
|
|
||||||
// Detect FAST features, 20 is a good threshold
|
// Detect FAST features, 20 is a good threshold
|
||||||
FastFeatureDetector fd(20, true);
|
FastFeatureDetector fd(20, true);
|
||||||
@ -680,7 +680,7 @@ static void computeKeyPoints(const vector<Mat>& imagePyramid,
|
|||||||
float sf = getScale(level, firstLevel, scaleFactor);
|
float sf = getScale(level, firstLevel, scaleFactor);
|
||||||
|
|
||||||
// Set the level of the coordinates
|
// Set the level of the coordinates
|
||||||
for (vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
for (std::vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
||||||
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
||||||
{
|
{
|
||||||
keypoint->octave = level;
|
keypoint->octave = level;
|
||||||
@ -699,8 +699,8 @@ static void computeKeyPoints(const vector<Mat>& imagePyramid,
|
|||||||
* @param keypoints the keypoints to use
|
* @param keypoints the keypoints to use
|
||||||
* @param descriptors the resulting descriptors
|
* @param descriptors the resulting descriptors
|
||||||
*/
|
*/
|
||||||
static void computeDescriptors(const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors,
|
static void computeDescriptors(const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors,
|
||||||
const vector<Point>& pattern, int dsize, int WTA_K)
|
const std::vector<Point>& pattern, int dsize, int WTA_K)
|
||||||
{
|
{
|
||||||
//convert to grayscale if more than one color
|
//convert to grayscale if more than one color
|
||||||
CV_Assert(image.type() == CV_8UC1);
|
CV_Assert(image.type() == CV_8UC1);
|
||||||
@ -720,7 +720,7 @@ static void computeDescriptors(const Mat& image, vector<KeyPoint>& keypoints, Ma
|
|||||||
* @param do_keypoints if true, the keypoints are computed, otherwise used as an input
|
* @param do_keypoints if true, the keypoints are computed, otherwise used as an input
|
||||||
* @param do_descriptors if true, also computes the descriptors
|
* @param do_descriptors if true, also computes the descriptors
|
||||||
*/
|
*/
|
||||||
void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _keypoints,
|
void ORB::operator()( InputArray _image, InputArray _mask, std::vector<KeyPoint>& _keypoints,
|
||||||
OutputArray _descriptors, bool useProvidedKeypoints) const
|
OutputArray _descriptors, bool useProvidedKeypoints) const
|
||||||
{
|
{
|
||||||
CV_Assert(patchSize >= 2);
|
CV_Assert(patchSize >= 2);
|
||||||
@ -760,7 +760,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pre-compute the scale pyramids
|
// Pre-compute the scale pyramids
|
||||||
vector<Mat> imagePyramid(levelsNum), maskPyramid(levelsNum);
|
std::vector<Mat> imagePyramid(levelsNum), maskPyramid(levelsNum);
|
||||||
for (int level = 0; level < levelsNum; ++level)
|
for (int level = 0; level < levelsNum; ++level)
|
||||||
{
|
{
|
||||||
float scale = 1/getScale(level, firstLevel, scaleFactor);
|
float scale = 1/getScale(level, firstLevel, scaleFactor);
|
||||||
@ -811,7 +811,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pre-compute the keypoints (we keep the best over all scales, so this has to be done beforehand
|
// Pre-compute the keypoints (we keep the best over all scales, so this has to be done beforehand
|
||||||
vector < vector<KeyPoint> > allKeypoints;
|
std::vector < std::vector<KeyPoint> > allKeypoints;
|
||||||
if( do_keypoints )
|
if( do_keypoints )
|
||||||
{
|
{
|
||||||
// Get keypoints, those will be far enough from the border that no check will be required for the descriptor
|
// Get keypoints, those will be far enough from the border that no check will be required for the descriptor
|
||||||
@ -820,18 +820,18 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
edgeThreshold, patchSize, scoreType);
|
edgeThreshold, patchSize, scoreType);
|
||||||
|
|
||||||
// make sure we have the right number of keypoints keypoints
|
// make sure we have the right number of keypoints keypoints
|
||||||
/*vector<KeyPoint> temp;
|
/*std::vector<KeyPoint> temp;
|
||||||
|
|
||||||
for (int level = 0; level < n_levels; ++level)
|
for (int level = 0; level < n_levels; ++level)
|
||||||
{
|
{
|
||||||
vector<KeyPoint>& keypoints = all_keypoints[level];
|
std::vector<KeyPoint>& keypoints = all_keypoints[level];
|
||||||
temp.insert(temp.end(), keypoints.begin(), keypoints.end());
|
temp.insert(temp.end(), keypoints.begin(), keypoints.end());
|
||||||
keypoints.clear();
|
keypoints.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyPoint::retainBest(temp, n_features_);
|
KeyPoint::retainBest(temp, n_features_);
|
||||||
|
|
||||||
for (vector<KeyPoint>::iterator keypoint = temp.begin(),
|
for (std::vector<KeyPoint>::iterator keypoint = temp.begin(),
|
||||||
keypoint_end = temp.end(); keypoint != keypoint_end; ++keypoint)
|
keypoint_end = temp.end(); keypoint != keypoint_end; ++keypoint)
|
||||||
all_keypoints[keypoint->octave].push_back(*keypoint);*/
|
all_keypoints[keypoint->octave].push_back(*keypoint);*/
|
||||||
}
|
}
|
||||||
@ -842,7 +842,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
|
|
||||||
// Cluster the input keypoints depending on the level they were computed at
|
// Cluster the input keypoints depending on the level they were computed at
|
||||||
allKeypoints.resize(levelsNum);
|
allKeypoints.resize(levelsNum);
|
||||||
for (vector<KeyPoint>::iterator keypoint = _keypoints.begin(),
|
for (std::vector<KeyPoint>::iterator keypoint = _keypoints.begin(),
|
||||||
keypointEnd = _keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
keypointEnd = _keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
||||||
allKeypoints[keypoint->octave].push_back(*keypoint);
|
allKeypoints[keypoint->octave].push_back(*keypoint);
|
||||||
|
|
||||||
@ -852,16 +852,16 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
if (level == firstLevel)
|
if (level == firstLevel)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vector<KeyPoint> & keypoints = allKeypoints[level];
|
std::vector<KeyPoint> & keypoints = allKeypoints[level];
|
||||||
float scale = 1/getScale(level, firstLevel, scaleFactor);
|
float scale = 1/getScale(level, firstLevel, scaleFactor);
|
||||||
for (vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
for (std::vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
||||||
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
||||||
keypoint->pt *= scale;
|
keypoint->pt *= scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat descriptors;
|
Mat descriptors;
|
||||||
vector<Point> pattern;
|
std::vector<Point> pattern;
|
||||||
|
|
||||||
if( do_descriptors )
|
if( do_descriptors )
|
||||||
{
|
{
|
||||||
@ -902,7 +902,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
for (int level = 0; level < levelsNum; ++level)
|
for (int level = 0; level < levelsNum; ++level)
|
||||||
{
|
{
|
||||||
// Get the features and compute their orientation
|
// Get the features and compute their orientation
|
||||||
vector<KeyPoint>& keypoints = allKeypoints[level];
|
std::vector<KeyPoint>& keypoints = allKeypoints[level];
|
||||||
int nkeypoints = (int)keypoints.size();
|
int nkeypoints = (int)keypoints.size();
|
||||||
|
|
||||||
// Compute the descriptors
|
// Compute the descriptors
|
||||||
@ -926,7 +926,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
if (level != firstLevel)
|
if (level != firstLevel)
|
||||||
{
|
{
|
||||||
float scale = getScale(level, firstLevel, scaleFactor);
|
float scale = getScale(level, firstLevel, scaleFactor);
|
||||||
for (vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
for (std::vector<KeyPoint>::iterator keypoint = keypoints.begin(),
|
||||||
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
|
||||||
keypoint->pt *= scale;
|
keypoint->pt *= scale;
|
||||||
}
|
}
|
||||||
@ -935,12 +935,12 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ORB::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const
|
void ORB::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
|
||||||
{
|
{
|
||||||
(*this)(image, mask, keypoints, noArray(), false);
|
(*this)(image, mask, keypoints, noArray(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ORB::computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors) const
|
void ORB::computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors) const
|
||||||
{
|
{
|
||||||
(*this)(image, Mat(), keypoints, descriptors, true);
|
(*this)(image, Mat(), keypoints, descriptors, true);
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ static bool StarDetectorSuppressLines( const Mat& responses, const Mat& sizes, P
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
StarDetectorSuppressNonmax( const Mat& responses, const Mat& sizes,
|
StarDetectorSuppressNonmax( const Mat& responses, const Mat& sizes,
|
||||||
vector<KeyPoint>& keypoints, int border,
|
std::vector<KeyPoint>& keypoints, int border,
|
||||||
int responseThreshold,
|
int responseThreshold,
|
||||||
int lineThresholdProjected,
|
int lineThresholdProjected,
|
||||||
int lineThresholdBinarized,
|
int lineThresholdBinarized,
|
||||||
@ -426,7 +426,7 @@ StarDetector::StarDetector(int _maxSize, int _responseThreshold,
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void StarDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void StarDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
Mat grayImage = image;
|
Mat grayImage = image;
|
||||||
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
||||||
@ -435,7 +435,7 @@ void StarDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, co
|
|||||||
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
void StarDetector::operator()(const Mat& img, vector<KeyPoint>& keypoints) const
|
void StarDetector::operator()(const Mat& img, std::vector<KeyPoint>& keypoints) const
|
||||||
{
|
{
|
||||||
Mat responses, sizes;
|
Mat responses, sizes;
|
||||||
int border = StarDetectorComputeResponses( img, responses, sizes, maxSize );
|
int border = StarDetectorComputeResponses( img, responses, sizes, maxSize );
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "test_precomp.hpp"
|
#include "test_precomp.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
class CV_BRISKTest : public cvtest::BaseTest
|
class CV_BRISKTest : public cvtest::BaseTest
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "test_precomp.hpp"
|
#include "test_precomp.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
class CV_FastTest : public cvtest::BaseTest
|
class CV_FastTest : public cvtest::BaseTest
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace cv::flann;
|
using namespace cv::flann;
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user