fixed wrapper of sift descriptor
This commit is contained in:
parent
da2fd5357d
commit
0043fe6fcd
@ -171,18 +171,18 @@ CVAPI(CvSeq*) cvGetStarKeypoints( const CvArr* img, CvMemStorage* storage,
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
||||||
// CvAffinePose: defines a parameterized affine transformation of an image patch.
|
// CvAffinePose: defines a parameterized affine transformation of an image patch.
|
||||||
// An image patch is rotated on angle phi (in degrees), then scaled lambda1 times
|
// An image patch is rotated on angle phi (in degrees), then scaled lambda1 times
|
||||||
// along horizontal and lambda2 times along vertical direction, and then rotated again
|
// along horizontal and lambda2 times along vertical direction, and then rotated again
|
||||||
// on angle (theta - phi).
|
// on angle (theta - phi).
|
||||||
class CV_EXPORTS CvAffinePose
|
class CV_EXPORTS CvAffinePose
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
float phi;
|
float phi;
|
||||||
float theta;
|
float theta;
|
||||||
float lambda1;
|
float lambda1;
|
||||||
float lambda2;
|
float lambda2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
@ -249,7 +249,7 @@ public:
|
|||||||
{
|
{
|
||||||
static double GET_DEFAULT_MAGNIFICATION() { return 3.0; }
|
static double GET_DEFAULT_MAGNIFICATION() { return 3.0; }
|
||||||
static const bool DEFAULT_IS_NORMALIZE = true;
|
static const bool DEFAULT_IS_NORMALIZE = true;
|
||||||
static const int DESCRIPTOR_SIZE = -1;
|
static const int DESCRIPTOR_SIZE = 128;
|
||||||
DescriptorParams() : magnification(GET_DEFAULT_MAGNIFICATION()), isNormalize(DEFAULT_IS_NORMALIZE) {}
|
DescriptorParams() : magnification(GET_DEFAULT_MAGNIFICATION()), isNormalize(DEFAULT_IS_NORMALIZE) {}
|
||||||
DescriptorParams( double _magnification, bool _isNormalize ) :
|
DescriptorParams( double _magnification, bool _isNormalize ) :
|
||||||
magnification(_magnification), isNormalize(_isNormalize) {}
|
magnification(_magnification), isNormalize(_isNormalize) {}
|
||||||
@ -1534,6 +1534,7 @@ void BruteForceMatcher<Distance>::matchImpl( const Mat& descriptors_1, const Mat
|
|||||||
|
|
||||||
assert( mask.empty() || (mask.rows == descriptors_1.rows && mask.cols == descriptors_2.rows) );
|
assert( mask.empty() || (mask.rows == descriptors_1.rows && mask.cols == descriptors_2.rows) );
|
||||||
|
|
||||||
|
assert( !descriptors_1.empty() && !descriptors_2.empty() );
|
||||||
assert( descriptors_1.cols == descriptors_2.cols );
|
assert( descriptors_1.cols == descriptors_2.cols );
|
||||||
assert( DataType<ValueType>::type == descriptors_1.type() );
|
assert( DataType<ValueType>::type == descriptors_1.type() );
|
||||||
assert( DataType<ValueType>::type == descriptors_2.type() );
|
assert( DataType<ValueType>::type == descriptors_2.type() );
|
||||||
@ -1862,27 +1863,6 @@ protected:
|
|||||||
vector<int> classIds;
|
vector<int> classIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
// A factory function for creating an arbitrary descriptor matcher at runtime
|
|
||||||
/*inline GenericDescriptorMatch* createDescriptorMatcher(std::string extractor = "SURF", std::string matcher = "BruteForce")
|
|
||||||
{
|
|
||||||
GenericDescriptorMatch* descriptors = NULL;
|
|
||||||
|
|
||||||
if(matcher.compare("BruteForce") != 0)
|
|
||||||
{
|
|
||||||
// only one matcher exists now
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(extractor.compare("SURF"))
|
|
||||||
{
|
|
||||||
descriptors = new DescriptorMatchVector<features_2d::SurfDescriptorExtractor, features_2d::BruteForceMatcher<features_2d::L2<float> > >();
|
|
||||||
}
|
|
||||||
else if(extractor.compare("OneWay"))
|
|
||||||
{
|
|
||||||
descriptors = new DescriptorMatchOneWay();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#include<iostream>
|
#include<iostream>
|
||||||
#include<limits>
|
#include<limits>
|
||||||
|
|
||||||
#define log2(a) log((a)) /CV_LOG2
|
#define log2(a) (log((a))/CV_LOG2)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* from sift.hpp of original code
|
* from sift.hpp of original code
|
||||||
@ -2006,16 +2006,16 @@ SIFT::SIFT( const CommonParams& _commParams,
|
|||||||
|
|
||||||
inline KeyPoint vlKeypointToOcv( const VL::Sift::Keypoint& vlKeypoint, float angle )
|
inline KeyPoint vlKeypointToOcv( const VL::Sift::Keypoint& vlKeypoint, float angle )
|
||||||
{
|
{
|
||||||
return KeyPoint(vlKeypoint.x, vlKeypoint.y, vlKeypoint.sigma/*??????? or s */, angle, 0, vlKeypoint.o, 0 );
|
return KeyPoint(vlKeypoint.x, vlKeypoint.y, vlKeypoint.sigma, angle, 0, vlKeypoint.o, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ocvKeypointToVl( const KeyPoint& ocvKeypoint, const VL::Sift& vlSift,
|
inline void ocvKeypointToVl( const KeyPoint& ocvKeypoint, const VL::Sift& vlSift,
|
||||||
VL::Sift::Keypoint& vlKeypoint, float& angle )
|
VL::Sift::Keypoint& vlKeypoint )
|
||||||
{
|
{
|
||||||
vlKeypoint = vlSift.getKeypoint(ocvKeypoint.pt.x, ocvKeypoint.pt.y, ocvKeypoint.size);
|
vlKeypoint = vlSift.getKeypoint(ocvKeypoint.pt.x, ocvKeypoint.pt.y, ocvKeypoint.size);
|
||||||
angle = ocvKeypoint.angle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// detectors
|
||||||
void SIFT::operator()(const Mat& img, const Mat& mask,
|
void SIFT::operator()(const Mat& img, const Mat& mask,
|
||||||
vector<KeyPoint>& keypoints) const
|
vector<KeyPoint>& keypoints) const
|
||||||
{
|
{
|
||||||
@ -2063,6 +2063,7 @@ void SIFT::operator()(const Mat& img, const Mat& mask,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// descriptors
|
||||||
void SIFT::operator()(const Mat& img, const Mat& mask,
|
void SIFT::operator()(const Mat& img, const Mat& mask,
|
||||||
vector<KeyPoint>& keypoints,
|
vector<KeyPoint>& keypoints,
|
||||||
Mat& descriptors,
|
Mat& descriptors,
|
||||||
@ -2091,8 +2092,7 @@ void SIFT::operator()(const Mat& img, const Mat& mask,
|
|||||||
for( int pi = 0 ; iter != keypoints.end(); ++iter, pi++ )
|
for( int pi = 0 ; iter != keypoints.end(); ++iter, pi++ )
|
||||||
{
|
{
|
||||||
VL::Sift::Keypoint vlkpt;
|
VL::Sift::Keypoint vlkpt;
|
||||||
float angle;
|
ocvKeypointToVl( *iter, vlsift, vlkpt );
|
||||||
ocvKeypointToVl( *iter, vlsift, vlkpt, angle);
|
vlsift.computeKeypointDescriptor((VL::float_t*)descriptors.ptr(pi), vlkpt, iter->angle);
|
||||||
vlsift.computeKeypointDescriptor((VL::float_t*)descriptors.ptr(pi), vlkpt, angle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user