// CCOUNTER_SET_ZERO(thread_consumed_count);
//
// #ifdef _OPENMP
-// #pragma omp parallel private(img, sum, tilted, sqsum, sumdata, tilteddata, \
+// #pragma omp parallel private(img, sum, tilted, sqsum, sumdata, tilteddata,
// normfactor, thread_consumed_count)
// #endif /* _OPENMP */
// {
Mat& _3dImage, const Mat& Q,
bool handleMissingValues=false );
-class CV_EXPORTS Keypoint
+class CV_EXPORTS KeyPoint
{
public:
- Keypoint() : pt(0,0), size(0), angle(-1), response(0), octave(0) {}
- Keypoint(Point2f _pt, float _size, float _angle=-1, float _response=0, int _octave=0)
+ KeyPoint() : pt(0,0), size(0), angle(-1), response(0), octave(0) {}
+ KeyPoint(Point2f _pt, float _size, float _angle=-1, float _response=0, int _octave=0)
: pt(_pt), size(_size), angle(_angle), response(_response), octave(_octave) {}
- Keypoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0)
+ KeyPoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0)
: pt(x, y), size(_size), angle(_angle), response(_response), octave(_octave) {}
Point2f pt;
int octave;
};
-CV_EXPORTS void write(FileStorage& fs, const String& name, const Vector<Keypoint>& keypoints);
-CV_EXPORTS void read(const FileNode& node, Vector<Keypoint>& keypoints);
+CV_EXPORTS void write(FileStorage& fs, const String& name, const Vector<KeyPoint>& keypoints);
+CV_EXPORTS void read(const FileNode& node, Vector<KeyPoint>& keypoints);
class CV_EXPORTS SURF : public CvSURFParams
{
int descriptorSize() const;
void operator()(const Mat& img, const Mat& mask,
- Vector<Keypoint>& keypoints) const;
+ Vector<KeyPoint>& keypoints) const;
void operator()(const Mat& img, const Mat& mask,
- Vector<Keypoint>& keypoints,
+ Vector<KeyPoint>& keypoints,
Vector<float>& descriptors,
bool useProvidedKeypoints=false) const;
};
int _lineThresholdBinarized,
int _suppressNonmaxSize);
- void operator()(const Mat& image, Vector<Keypoint>& keypoints) const;
+ void operator()(const Mat& image, Vector<KeyPoint>& keypoints) const;
};
}
LDetector();\r
LDetector(int _radius, int _threshold, int _nOctaves,\r
int _nViews, double _baseFeatureSize, double _clusteringDistance);\r
- void operator()(const Mat& image, Vector<Keypoint>& keypoints, int maxCount=0, bool scaleCoords=true) const;\r
- void operator()(const Vector<Mat>& pyr, Vector<Keypoint>& keypoints, int maxCount=0, bool scaleCoords=true) const;\r
- void getMostStable2D(const Mat& image, Vector<Keypoint>& keypoints,\r
+ void operator()(const Mat& image, Vector<KeyPoint>& keypoints, int maxCount=0, bool scaleCoords=true) const;\r
+ void operator()(const Vector<Mat>& pyr, Vector<KeyPoint>& keypoints, int maxCount=0, bool scaleCoords=true) const;\r
+ void getMostStable2D(const Mat& image, Vector<KeyPoint>& keypoints,\r
int maxCount, const PatchGenerator& patchGenerator) const;\r
void setVerbose(bool verbose);\r
\r
virtual void read(const FileNode& n);\r
virtual void write(FileStorage& fs, const String& name=String()) const;\r
virtual void trainFromSingleView(const Mat& image,\r
- const Vector<Keypoint>& keypoints,\r
+ const Vector<KeyPoint>& keypoints,\r
int _patchSize=PATCH_SIZE,\r
int _signatureSize=DEFAULT_SIGNATURE_SIZE,\r
int _nstructs=DEFAULT_STRUCTS,\r
int _nviews=FernClassifier::DEFAULT_VIEWS,\r
const LDetector& detector=LDetector(),\r
const PatchGenerator& patchGenerator=PatchGenerator());\r
- virtual void train(const Vector<Mat>& pyr, const Vector<Keypoint>& keypoints,\r
+ virtual void train(const Vector<Mat>& pyr, const Vector<KeyPoint>& keypoints,\r
int _patchSize=FernClassifier::PATCH_SIZE,\r
int _nstructs=FernClassifier::DEFAULT_STRUCTS,\r
int _structSize=FernClassifier::DEFAULT_STRUCT_SIZE,\r
const LDetector& detector=LDetector(),\r
const PatchGenerator& patchGenerator=PatchGenerator());\r
Rect getModelROI() const;\r
- Vector<Keypoint> getModelPoints() const;\r
+ Vector<KeyPoint> getModelPoints() const;\r
const LDetector& getDetector() const;\r
const FernClassifier& getClassifier() const;\r
void setVerbose(bool verbose);\r
void read(const FileNode& node);\r
void write(FileStorage& fs, const String& name=String()) const;\r
bool operator()(const Mat& image, Mat& H, Vector<Point2f>& corners) const;\r
- bool operator()(const Vector<Mat>& pyr, const Vector<Keypoint>& keypoints,\r
+ bool operator()(const Vector<Mat>& pyr, const Vector<KeyPoint>& keypoints,\r
Mat& H, Vector<Point2f>& corners, Vector<int>* pairs=0) const;\r
\r
protected:\r
bool verbose;\r
Rect modelROI;\r
- Vector<Keypoint> modelPoints;\r
+ Vector<KeyPoint> modelPoints;\r
LDetector ldetector;\r
FernClassifier fernClassifier;\r
};\r
}
}
-void write(FileStorage& fs, const String& objname, const Vector<Keypoint>& keypoints)
+void write(FileStorage& fs, const String& objname, const Vector<KeyPoint>& keypoints)
{
WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW);
int i, npoints = (int)keypoints.size();
for( i = 0; i < npoints; i++ )
{
- const Keypoint& kpt = keypoints[i];
+ const KeyPoint& kpt = keypoints[i];
write(fs, kpt.pt.x);
write(fs, kpt.pt.y);
write(fs, kpt.size);
}
-void read(const FileNode& node, Vector<Keypoint>& keypoints)
+void read(const FileNode& node, Vector<KeyPoint>& keypoints)
{
keypoints.resize(0);
FileNodeIterator it = node.begin(), it_end = node.end();
for( ; it != it_end; )
{
- Keypoint kpt;
+ KeyPoint kpt;
it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave;
keypoints.push_back(kpt);
}
_lineThresholdProjected, _lineThresholdBinarized, _suppressNonmaxSize);
}
-void StarDetector::operator()(const Mat& image, Vector<Keypoint>& keypoints) const
+void StarDetector::operator()(const Mat& image, Vector<KeyPoint>& keypoints) const
{
CvMat _image = image;
MemStorage storage(cvCreateMemStorage(0));
for( i = 0; i < n; i++, ++it )
{
const CvStarKeypoint& kpt = *it;
- keypoints[i] = Keypoint(kpt.pt, (float)kpt.size, -1.f, kpt.response, 0);
+ keypoints[i] = KeyPoint(kpt.pt, (float)kpt.size, -1.f, kpt.response, 0);
}
}
*/
/*
-Keypoint position and scale interpolation has been implemented as described in
+KeyPoint position and scale interpolation has been implemented as described in
the Brown and Lowe paper cited by the SURF paper.
The sampling step along the x and y axes of the image for the determinant of the
The extraction of the patch of pixels surrounding a keypoint used to build a
descriptor has been simplified.
-Keypoint descriptor normalisation has been changed from normalising each 4x4
+KeyPoint descriptor normalisation has been changed from normalising each 4x4
cell (resulting in a descriptor of magnitude 16) to normalising the entire
descriptor to magnitude 1.
point.pt.x >= 0 && point.pt.x <= (sum->cols-1) &&
point.pt.y >= 0 && point.pt.y <= (sum->rows-1) )
{
- /*printf( "Keypoint %f %f %d\n", point.pt.x, point.pt.y, point.size );*/
+ /*printf( "KeyPoint %f %f %d\n", point.pt.x, point.pt.y, point.size );*/
cvSeqPush( points, &point );
}
}
void SURF::operator()(const Mat& img, const Mat& mask,
- Vector<Keypoint>& keypoints) const
+ Vector<KeyPoint>& keypoints) const
{
CvMat _img = img, _mask, *pmask = 0;
if( mask.data )
for( i = 0; i < n; i++, ++it )
{
const CvSURFPoint& kpt = *it;
- keypoints[i] = Keypoint(kpt.pt, (float)kpt.size, kpt.dir,
+ keypoints[i] = KeyPoint(kpt.pt, (float)kpt.size, kpt.dir,
kpt.hessian, getPointOctave(kpt, *this));
}
}
void SURF::operator()(const Mat& img, const Mat& mask,
- Vector<Keypoint>& keypoints,
+ Vector<KeyPoint>& keypoints,
Vector<float>& descriptors,
bool useProvidedKeypoints) const
{
n = keypoints.size();
for( i = 0; i < n; i++ )
{
- const Keypoint& kpt = keypoints[i];
+ const KeyPoint& kpt = keypoints[i];
kp.push_back(cvSURFPoint(kpt.pt, 1, cvRound(kpt.size), kpt.angle, kpt.response));
}
}
for( i = 0; i < n; i++, ++it )
{
const CvSURFPoint& kpt = *it;
- keypoints[i] = Keypoint(kpt.pt, (float)kpt.size, kpt.dir,
+ keypoints[i] = KeyPoint(kpt.pt, (float)kpt.size, kpt.dir,
kpt.hessian, getPointOctave(kpt, *this));
}
}
References:
1. Mustafa Özuysal, Michael Calonder, Vincent Lepetit, Pascal Fua,
- "Fast Keypoint Recognition Using Random Ferns,"
+ "Fast KeyPoint Recognition Using Random Ferns,"
IEEE Transactions on Pattern Analysis and Machine Intelligence, 15 Jan. 2009.
2. Vincent Lepetit, Pascal Fua,
struct CmpKeypointScores
{
- bool operator ()(const Keypoint& a, const Keypoint& b) const { return std::abs(a.response) > std::abs(b.response); }
+ bool operator ()(const KeyPoint& a, const KeyPoint& b) const { return std::abs(a.response) > std::abs(b.response); }
};
-void LDetector::getMostStable2D(const Mat& image, Vector<Keypoint>& keypoints,
+void LDetector::getMostStable2D(const Mat& image, Vector<KeyPoint>& keypoints,
int maxPoints, const PatchGenerator& _patchGenerator) const
{
PatchGenerator patchGenerator = _patchGenerator;
double *M = (double*)_M.data, *iM = (double*)_iM.data;
RNG& rng = theRNG();
int i, k;
- Vector<Keypoint> tempKeypoints;
+ Vector<KeyPoint> tempKeypoints;
double d2 = clusteringDistance*clusteringDistance;
keypoints.clear();
int j, sz0 = (int)tempKeypoints.size(), sz1;
for( j = 0; j < sz0; j++ )
{
- Keypoint kpt1 = tempKeypoints[j];
- Keypoint kpt0((float)(iM[0]*kpt1.pt.x + iM[1]*kpt1.pt.y + iM[2]),
+ KeyPoint kpt1 = tempKeypoints[j];
+ KeyPoint kpt0((float)(iM[0]*kpt1.pt.x + iM[1]*kpt1.pt.y + iM[2]),
(float)(iM[3]*kpt1.pt.x + iM[4]*kpt1.pt.y + iM[5]),
kpt1.size, -1.f, 1.f, kpt1.octave);
float r = kpt1.size*0.5f;
sz1 = (int)keypoints.size();
for( k = 0; k < sz1; k++ )
{
- Keypoint kpt = keypoints[k];
+ KeyPoint kpt = keypoints[k];
if( kpt.octave != kpt0.octave )
continue;
double dx = kpt.pt.x - kpt0.pt.x, dy = kpt.pt.y - kpt0.pt.y;
if( dx*dx + dy*dy <= d2*(1 << kpt.octave*2) )
{
- keypoints[k] = Keypoint((kpt.pt.x*kpt.response + kpt0.pt.x)/(kpt.response+1),
+ keypoints[k] = KeyPoint((kpt.pt.x*kpt.response + kpt0.pt.x)/(kpt.response+1),
(kpt.pt.y*kpt.response + kpt0.pt.y)/(kpt.response+1),
kpt.size, -1.f, kpt.response + 1, kpt.octave);
break;
return Point2f((float)dx, (float)dy);
}
-void LDetector::operator()(const Mat& image, Vector<Keypoint>& keypoints, int maxCount, bool scaleCoords) const
+void LDetector::operator()(const Mat& image, Vector<KeyPoint>& keypoints, int maxCount, bool scaleCoords) const
{
Vector<Mat> pyr;
buildPyramid(image, pyr, std::max(nOctaves-1, 0));
(*this)(pyr, keypoints, maxCount, scaleCoords);
}
-void LDetector::operator()(const Vector<Mat>& pyr, Vector<Keypoint>& keypoints, int maxCount, bool scaleCoords) const
+void LDetector::operator()(const Vector<Mat>& pyr, Vector<KeyPoint>& keypoints, int maxCount, bool scaleCoords) const
{
const int lthreshold = 3;
int L, x, y, i, j, k, tau = lthreshold;
Point2f pt = adjustCorner(fval, fvaln);
pt.x += x;
pt.y += y;
- keypoints.push_back(Keypoint((float)(pt.x*cscale), (float)(pt.y*cscale),
+ keypoints.push_back(KeyPoint((float)(pt.x*cscale), (float)(pt.y*cscale),
(float)(baseFeatureSize*cscale), -1, fvaln, L));
}
}
void FernClassifier::trainFromSingleView(const Mat& image,
- const Vector<Keypoint>& keypoints,
+ const Vector<KeyPoint>& keypoints,
int _patchSize, int _signatureSize,
int _nstructs, int _structSize,
int _nviews, int _compressionMethod,
for( j = 0; j < nsamples; j++ )
{
- Keypoint kpt = keypoints[j];
+ KeyPoint kpt = keypoints[j];
float scale = 1.f/(1 << kpt.octave);
Point2f pt((float)((M[0]*kpt.pt.x + M[1]*kpt.pt.y + M[2])*scale),
(float)((M[3]*kpt.pt.x + M[4]*kpt.pt.y + M[5])*scale));
{
}
-Vector<Keypoint> PlanarObjectDetector::getModelPoints() const
+Vector<KeyPoint> PlanarObjectDetector::getModelPoints() const
{
return modelPoints;
}
FernClassifier::COMPRESSION_NONE, patchGenerator);
}
-void PlanarObjectDetector::train(const Vector<Mat>& pyr, const Vector<Keypoint>& keypoints,
+void PlanarObjectDetector::train(const Vector<Mat>& pyr, const Vector<KeyPoint>& keypoints,
int patchSize, int nstructs, int structSize,
int nviews, const LDetector& detector,
const PatchGenerator& patchGenerator)
{
Vector<Mat> pyr;
buildPyramid(image, pyr, ldetector.nOctaves - 1);
- Vector<Keypoint> keypoints;
+ Vector<KeyPoint> keypoints;
ldetector(pyr, keypoints);
return (*this)(pyr, keypoints, H, corners);
}
-bool PlanarObjectDetector::operator()(const Vector<Mat>& pyr, const Vector<Keypoint>& keypoints,
+bool PlanarObjectDetector::operator()(const Vector<Mat>& pyr, const Vector<KeyPoint>& keypoints,
Mat& _H, Vector<Point2f>& corners, Vector<int>* pairs) const
{
int i, j, m = (int)modelPoints.size(), n = (int)keypoints.size();
for( i = 0; i < n; i++ )
{
- Keypoint kpt = keypoints[i];
+ KeyPoint kpt = keypoints[i];
CV_Assert(0 <= kpt.octave && kpt.octave < (int)pyr.size());
kpt.pt.x /= (float)(1 << kpt.octave);
kpt.pt.y /= (float)(1 << kpt.octave);