From 49f6dad13f12f9fb1197eec293b1767b488d02f3 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 26 Mar 2013 14:58:09 +0400 Subject: [PATCH 1/2] Move cv::KeyPoint and cv::DMatch to core --- modules/contrib/CMakeLists.txt | 2 +- modules/core/include/opencv2/core.hpp | 90 ++++++++++++ .../core/include/opencv2/core/operations.hpp | 3 + modules/core/src/persistence.cpp | 31 ++++ modules/core/src/types.cpp | 139 ++++++++++++++++++ .../features2d/include/opencv2/features2d.hpp | 89 +---------- modules/features2d/src/keypoint.cpp | 123 ---------------- modules/flann/include/opencv2/flann.hpp | 2 +- .../src/org/opencv/test/OpenCVTestCase.java | 4 +- .../test/{features2d => core}/DMatchTest.java | 4 +- .../{features2d => core}/KeyPointTest.java | 4 +- .../BRIEFDescriptorExtractorTest.java | 2 +- .../BruteForceDescriptorMatcherTest.java | 4 +- ...ruteForceHammingDescriptorMatcherTest.java | 2 +- ...eForceHammingLUTDescriptorMatcherTest.java | 2 +- .../BruteForceL1DescriptorMatcherTest.java | 4 +- .../BruteForceSL2DescriptorMatcherTest.java | 4 +- .../features2d/FASTFeatureDetectorTest.java | 2 +- .../test/features2d/Features2dTest.java | 4 +- .../FlannBasedDescriptorMatcherTest.java | 4 +- .../ORBDescriptorExtractorTest.java | 2 +- .../SIFTDescriptorExtractorTest.java | 2 +- .../features2d/STARFeatureDetectorTest.java | 2 +- .../SURFDescriptorExtractorTest.java | 2 +- .../features2d/SURFFeatureDetectorTest.java | 2 +- .../org/opencv/test/utils/ConvertersTest.java | 4 +- modules/java/generator/gen_java.py | 2 +- ...eatures2d+DMatch.java => core+DMatch.java} | 2 +- ...res2d+KeyPoint.java => core+KeyPoint.java} | 2 +- .../generator/src/java/core+MatOfDMatch.java | 2 +- .../src/java/core+MatOfKeyPoint.java | 2 +- .../generator/src/java/utils+Converters.java | 4 +- .../src/org/opencv/test/OpenCVTestCase.java | 4 +- modules/ocl/CMakeLists.txt | 2 +- modules/ocl/include/opencv2/ocl.hpp | 2 +- modules/ts/CMakeLists.txt | 2 +- modules/ts/include/opencv2/ts/ts_perf.hpp | 1 - 37 files changed, 308 insertions(+), 250 deletions(-) create mode 100644 modules/core/src/types.cpp rename modules/java/android_test/src/org/opencv/test/{features2d => core}/DMatchTest.java (93%) rename modules/java/android_test/src/org/opencv/test/{features2d => core}/KeyPointTest.java (96%) rename modules/java/generator/src/java/{features2d+DMatch.java => core+DMatch.java} (97%) rename modules/java/generator/src/java/{features2d+KeyPoint.java => core+KeyPoint.java} (98%) diff --git a/modules/contrib/CMakeLists.txt b/modules/contrib/CMakeLists.txt index 81c9ea4aa5..1d3432b598 100644 --- a/modules/contrib/CMakeLists.txt +++ b/modules/contrib/CMakeLists.txt @@ -1 +1 @@ -ocv_define_module(contrib opencv_imgproc opencv_calib3d opencv_features2d opencv_ml opencv_video opencv_objdetect OPTIONAL opencv_highgui) +ocv_define_module(contrib opencv_imgproc opencv_calib3d opencv_ml opencv_video opencv_objdetect OPTIONAL opencv_highgui) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index ec4f5610d7..4034421620 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -826,6 +826,96 @@ public: int start, end; }; + + +/////////////////////////////// KeyPoint //////////////////////////////// + +/*! + The Keypoint Class + + The class instance stores a keypoint, i.e. a point feature found by one of many available keypoint detectors, such as + Harris corner detector, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT, cv::LDetector etc. + + The keypoint is characterized by the 2D position, scale + (proportional to the diameter of the neighborhood that needs to be taken into account), + orientation and some other parameters. The keypoint neighborhood is then analyzed by another algorithm that builds a descriptor + (usually represented as a feature vector). The keypoints representing the same object in different images can then be matched using + cv::KDTree or another method. +*/ +class CV_EXPORTS_W_SIMPLE KeyPoint +{ +public: + //! the default constructor + CV_WRAP KeyPoint(); + //! the full constructor + KeyPoint(Point2f _pt, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1); + //! another form of the full constructor + CV_WRAP KeyPoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1); + + size_t hash() const; + + //! converts vector of keypoints to vector of points + static void convert(const std::vector& keypoints, + CV_OUT std::vector& points2f, + const std::vector& keypointIndexes=std::vector()); + //! 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 std::vector& points2f, + CV_OUT std::vector& keypoints, + float size=1, float response=1, int octave=0, int class_id=-1); + + //! computes overlap for pair of keypoints; + //! overlap is a ratio between area of keypoint regions intersection and + //! area of keypoint regions union (now keypoint region is circle) + static float overlap(const KeyPoint& kp1, const KeyPoint& kp2); + + CV_PROP_RW Point2f pt; //!< coordinates of the keypoints + CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood + CV_PROP_RW float angle; //!< computed orientation of the keypoint (-1 if not applicable); + //!< it's in [0,360) degrees and measured relative to + //!< image coordinate system, ie in clockwise. + CV_PROP_RW float response; //!< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling + CV_PROP_RW int octave; //!< octave (pyramid layer) from which the keypoint has been extracted + CV_PROP_RW int class_id; //!< object class (if the keypoints need to be clustered by an object they belong to) +}; + +inline KeyPoint::KeyPoint() : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {} +inline KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle, float _response, int _octave, int _class_id) + : pt(_pt), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {} +inline KeyPoint::KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) + : pt(x, y), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {} + + + +//////////////////////////////// DMatch ///////////////////////////////// + +/* + * Struct for matching: query descriptor index, train descriptor index, train image index and distance between descriptors. + */ +struct CV_EXPORTS_W_SIMPLE DMatch +{ + CV_WRAP DMatch(); + CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance); + CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance); + + CV_PROP_RW int queryIdx; // query descriptor index + CV_PROP_RW int trainIdx; // train descriptor index + CV_PROP_RW int imgIdx; // train image index + + CV_PROP_RW float distance; + + // less is better + bool operator<(const DMatch &m) const; +}; + +inline DMatch::DMatch() : queryIdx(-1), trainIdx(-1), imgIdx(-1), distance(FLT_MAX) {} +inline DMatch::DMatch(int _queryIdx, int _trainIdx, float _distance) + : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), distance(_distance) {} +inline DMatch::DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) + : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), distance(_distance) {} +inline bool DMatch::operator<(const DMatch &m) const { return distance < m.distance; } + + + /////////////////////////////// DataType //////////////////////////////// /*! diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 26f91461a5..ef3458151f 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -2947,6 +2947,9 @@ static inline void read(const FileNode& node, String& value, const String& defau CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() ); CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat=SparseMat() ); +CV_EXPORTS void read(const FileNode& node, std::vector& keypoints); +CV_EXPORTS void write(FileStorage& fs, const String& objname, const std::vector& keypoints); + inline FileNode::operator int() const { int value; diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index bd3aab9701..52be883970 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -5522,6 +5522,37 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat ) SparseMat(m).copyTo(mat); } +void write(FileStorage& fs, const String& objname, const std::vector& 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]; + cv::write(fs, kpt.pt.x); + cv::write(fs, kpt.pt.y); + cv::write(fs, kpt.size); + cv::write(fs, kpt.angle); + cv::write(fs, kpt.response); + cv::write(fs, kpt.octave); + cv::write(fs, kpt.class_id); + } +} + + +void read(const FileNode& node, std::vector& keypoints) +{ + keypoints.resize(0); + FileNodeIterator it = node.begin(), it_end = node.end(); + for( ; it != it_end; ) + { + KeyPoint kpt; + it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave >> kpt.class_id; + keypoints.push_back(kpt); + } +} + } /* End of file. */ diff --git a/modules/core/src/types.cpp b/modules/core/src/types.cpp new file mode 100644 index 0000000000..4dbb06f31d --- /dev/null +++ b/modules/core/src/types.cpp @@ -0,0 +1,139 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#include "precomp.hpp" + +namespace cv +{ + +size_t KeyPoint::hash() const +{ + size_t _Val = 2166136261U, scale = 16777619U; + Cv32suf u; + u.f = pt.x; _Val = (scale * _Val) ^ u.u; + u.f = pt.y; _Val = (scale * _Val) ^ u.u; + u.f = size; _Val = (scale * _Val) ^ u.u; + u.f = angle; _Val = (scale * _Val) ^ u.u; + u.f = response; _Val = (scale * _Val) ^ u.u; + _Val = (scale * _Val) ^ ((size_t) octave); + _Val = (scale * _Val) ^ ((size_t) class_id); + return _Val; +} + +void KeyPoint::convert(const std::vector& keypoints, std::vector& points2f, + const std::vector& keypointIndexes) +{ + if( keypointIndexes.empty() ) + { + points2f.resize( keypoints.size() ); + for( size_t i = 0; i < keypoints.size(); i++ ) + points2f[i] = keypoints[i].pt; + } + else + { + points2f.resize( keypointIndexes.size() ); + for( size_t i = 0; i < keypointIndexes.size(); i++ ) + { + int idx = keypointIndexes[i]; + if( idx >= 0 ) + points2f[i] = keypoints[idx].pt; + else + { + CV_Error( CV_StsBadArg, "keypointIndexes has element < 0. TODO: process this case" ); + //points2f[i] = Point2f(-1, -1); + } + } + } +} + +void KeyPoint::convert( const std::vector& points2f, std::vector& keypoints, + float size, float response, int octave, int class_id ) +{ + keypoints.resize(points2f.size()); + for( size_t i = 0; i < points2f.size(); i++ ) + keypoints[i] = KeyPoint(points2f[i], size, -1, response, octave, class_id); +} + +float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 ) +{ + float a = kp1.size * 0.5f; + float b = kp2.size * 0.5f; + float a_2 = a * a; + float b_2 = b * b; + + Point2f p1 = kp1.pt; + Point2f p2 = kp2.pt; + float c = (float)norm( p1 - p2 ); + + float ovrl = 0.f; + + // one circle is completely encovered by the other => no intersection points! + if( std::min( a, b ) + c <= std::max( a, b ) ) + return std::min( a_2, b_2 ) / std::max( a_2, b_2 ); + + if( c < a + b ) // circles intersect + { + float c_2 = c * c; + float cosAlpha = ( b_2 + c_2 - a_2 ) / ( kp2.size * c ); + float cosBeta = ( a_2 + c_2 - b_2 ) / ( kp1.size * c ); + float alpha = acos( cosAlpha ); + float beta = acos( cosBeta ); + float sinAlpha = sin(alpha); + float sinBeta = sin(beta); + + float segmentAreaA = a_2 * beta; + float segmentAreaB = b_2 * alpha; + + float triangleAreaA = a_2 * sinBeta * cosBeta; + float triangleAreaB = b_2 * sinAlpha * cosAlpha; + + float intersectionArea = segmentAreaA + segmentAreaB - triangleAreaA - triangleAreaB; + float unionArea = (a_2 + b_2) * (float)CV_PI - intersectionArea; + + ovrl = intersectionArea / unionArea; + } + + return ovrl; +} + +} // cv \ No newline at end of file diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index 4184f5ea74..a3a8fe2f70 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -54,64 +54,10 @@ namespace cv CV_EXPORTS bool initModule_features2d(); -/*! - The Keypoint Class - - The class instance stores a keypoint, i.e. a point feature found by one of many available keypoint detectors, such as - Harris corner detector, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT, cv::LDetector etc. - - The keypoint is characterized by the 2D position, scale - (proportional to the diameter of the neighborhood that needs to be taken into account), - orientation and some other parameters. The keypoint neighborhood is then analyzed by another algorithm that builds a descriptor - (usually represented as a feature vector). The keypoints representing the same object in different images can then be matched using - cv::KDTree or another method. -*/ -class CV_EXPORTS_W_SIMPLE KeyPoint -{ -public: - //! the default constructor - CV_WRAP KeyPoint() : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {} - //! the full constructor - KeyPoint(Point2f _pt, float _size, float _angle=-1, - float _response=0, int _octave=0, int _class_id=-1) - : pt(_pt), size(_size), angle(_angle), - response(_response), octave(_octave), class_id(_class_id) {} - //! another form of the full constructor - CV_WRAP KeyPoint(float x, float y, float _size, float _angle=-1, - float _response=0, int _octave=0, int _class_id=-1) - : pt(x, y), size(_size), angle(_angle), - response(_response), octave(_octave), class_id(_class_id) {} - - size_t hash() const; - - //! converts vector of keypoints to vector of points - static void convert(const std::vector& keypoints, - CV_OUT std::vector& points2f, - const std::vector& keypointIndexes=std::vector()); - //! 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 std::vector& points2f, - CV_OUT std::vector& keypoints, - float size=1, float response=1, int octave=0, int class_id=-1); - - //! computes overlap for pair of keypoints; - //! overlap is a ratio between area of keypoint regions intersection and - //! area of keypoint regions union (now keypoint region is circle) - static float overlap(const KeyPoint& kp1, const KeyPoint& kp2); - - CV_PROP_RW Point2f pt; //!< coordinates of the keypoints - CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood - CV_PROP_RW float angle; //!< computed orientation of the keypoint (-1 if not applicable); - //!< it's in [0,360) degrees and measured relative to - //!< image coordinate system, ie in clockwise. - CV_PROP_RW float response; //!< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling - CV_PROP_RW int octave; //!< octave (pyramid layer) from which the keypoint has been extracted - CV_PROP_RW int class_id; //!< object class (if the keypoints need to be clustered by an object they belong to) -}; - -//! writes vector of keypoints to the file storage -CV_EXPORTS void write(FileStorage& fs, const String& name, const std::vector& keypoints); -//! reads vector of keypoints from the specified file storage node -CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector& keypoints); +// //! writes vector of keypoints to the file storage +// CV_EXPORTS void write(FileStorage& fs, const String& name, const std::vector& keypoints); +// //! reads vector of keypoints from the specified file storage node +// CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector& keypoints); /* * A class filters a vector of keypoints. @@ -1028,33 +974,6 @@ template struct CV_EXPORTS HammingMultilevel } }; -/****************************************************************************************\ -* DMatch * -\****************************************************************************************/ -/* - * Struct for matching: query descriptor index, train descriptor index, train image index and distance between descriptors. - */ -struct CV_EXPORTS_W_SIMPLE DMatch -{ - CV_WRAP DMatch() : queryIdx(-1), trainIdx(-1), imgIdx(-1), distance(FLT_MAX) {} - CV_WRAP DMatch( int _queryIdx, int _trainIdx, float _distance ) : - queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), distance(_distance) {} - CV_WRAP DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) : - queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), distance(_distance) {} - - CV_PROP_RW int queryIdx; // query descriptor index - CV_PROP_RW int trainIdx; // train descriptor index - CV_PROP_RW int imgIdx; // train image index - - CV_PROP_RW float distance; - - // less is better - bool operator<( const DMatch &m ) const - { - return distance < m.distance; - } -}; - /****************************************************************************************\ * DescriptorMatcher * \****************************************************************************************/ diff --git a/modules/features2d/src/keypoint.cpp b/modules/features2d/src/keypoint.cpp index cec6fca301..118d3df5ea 100644 --- a/modules/features2d/src/keypoint.cpp +++ b/modules/features2d/src/keypoint.cpp @@ -44,129 +44,6 @@ namespace cv { -size_t KeyPoint::hash() const -{ - size_t _Val = 2166136261U, scale = 16777619U; - Cv32suf u; - u.f = pt.x; _Val = (scale * _Val) ^ u.u; - u.f = pt.y; _Val = (scale * _Val) ^ u.u; - u.f = size; _Val = (scale * _Val) ^ u.u; - u.f = angle; _Val = (scale * _Val) ^ u.u; - u.f = response; _Val = (scale * _Val) ^ u.u; - _Val = (scale * _Val) ^ ((size_t) octave); - _Val = (scale * _Val) ^ ((size_t) class_id); - return _Val; -} - -void write(FileStorage& fs, const String& objname, const std::vector& 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]; - write(fs, kpt.pt.x); - write(fs, kpt.pt.y); - write(fs, kpt.size); - write(fs, kpt.angle); - write(fs, kpt.response); - write(fs, kpt.octave); - write(fs, kpt.class_id); - } -} - - -void read(const FileNode& node, std::vector& keypoints) -{ - keypoints.resize(0); - FileNodeIterator it = node.begin(), it_end = node.end(); - for( ; it != it_end; ) - { - KeyPoint kpt; - it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave >> kpt.class_id; - keypoints.push_back(kpt); - } -} - - -void KeyPoint::convert(const std::vector& keypoints, std::vector& points2f, - const std::vector& keypointIndexes) -{ - if( keypointIndexes.empty() ) - { - points2f.resize( keypoints.size() ); - for( size_t i = 0; i < keypoints.size(); i++ ) - points2f[i] = keypoints[i].pt; - } - else - { - points2f.resize( keypointIndexes.size() ); - for( size_t i = 0; i < keypointIndexes.size(); i++ ) - { - int idx = keypointIndexes[i]; - if( idx >= 0 ) - points2f[i] = keypoints[idx].pt; - else - { - CV_Error( CV_StsBadArg, "keypointIndexes has element < 0. TODO: process this case" ); - //points2f[i] = Point2f(-1, -1); - } - } - } -} - -void KeyPoint::convert( const std::vector& points2f, std::vector& keypoints, - float size, float response, int octave, int class_id ) -{ - keypoints.resize(points2f.size()); - for( size_t i = 0; i < points2f.size(); i++ ) - keypoints[i] = KeyPoint(points2f[i], size, -1, response, octave, class_id); -} - -float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 ) -{ - float a = kp1.size * 0.5f; - float b = kp2.size * 0.5f; - float a_2 = a * a; - float b_2 = b * b; - - Point2f p1 = kp1.pt; - Point2f p2 = kp2.pt; - float c = (float)norm( p1 - p2 ); - - float ovrl = 0.f; - - // one circle is completely encovered by the other => no intersection points! - if( std::min( a, b ) + c <= std::max( a, b ) ) - return std::min( a_2, b_2 ) / std::max( a_2, b_2 ); - - if( c < a + b ) // circles intersect - { - float c_2 = c * c; - float cosAlpha = ( b_2 + c_2 - a_2 ) / ( kp2.size * c ); - float cosBeta = ( a_2 + c_2 - b_2 ) / ( kp1.size * c ); - float alpha = acos( cosAlpha ); - float beta = acos( cosBeta ); - float sinAlpha = sin(alpha); - float sinBeta = sin(beta); - - float segmentAreaA = a_2 * beta; - float segmentAreaB = b_2 * alpha; - - float triangleAreaA = a_2 * sinBeta * cosBeta; - float triangleAreaB = b_2 * sinAlpha * cosAlpha; - - float intersectionArea = segmentAreaA + segmentAreaB - triangleAreaA - triangleAreaB; - float unionArea = (a_2 + b_2) * (float)CV_PI - intersectionArea; - - ovrl = intersectionArea / unionArea; - } - - return ovrl; -} - - struct KeypointResponseGreaterThanThreshold { KeypointResponseGreaterThanThreshold(float _value) : diff --git a/modules/flann/include/opencv2/flann.hpp b/modules/flann/include/opencv2/flann.hpp index 1bc7a3c976..0fc9298e35 100644 --- a/modules/flann/include/opencv2/flann.hpp +++ b/modules/flann/include/opencv2/flann.hpp @@ -47,8 +47,8 @@ #include "opencv2/core/types_c.h" #include "opencv2/core.hpp" -#include "opencv2/flann/flann_base.hpp" #include "opencv2/flann/miniflann.hpp" +#include "opencv2/flann/flann_base.hpp" namespace cvflann { diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java index 5c932110d3..97cdca783a 100644 --- a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java +++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java @@ -19,8 +19,8 @@ import org.opencv.core.Point3; import org.opencv.core.Rect; import org.opencv.core.Scalar; import org.opencv.core.Size; -import org.opencv.features2d.DMatch; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.DMatch; +import org.opencv.core.KeyPoint; import org.opencv.highgui.Highgui; import android.util.Log; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/DMatchTest.java b/modules/java/android_test/src/org/opencv/test/core/DMatchTest.java similarity index 93% rename from modules/java/android_test/src/org/opencv/test/features2d/DMatchTest.java rename to modules/java/android_test/src/org/opencv/test/core/DMatchTest.java index ef3443de3f..b523e0cd64 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/DMatchTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/DMatchTest.java @@ -1,6 +1,6 @@ -package org.opencv.test.features2d; +package org.opencv.test.core; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import junit.framework.TestCase; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/KeyPointTest.java b/modules/java/android_test/src/org/opencv/test/core/KeyPointTest.java similarity index 96% rename from modules/java/android_test/src/org/opencv/test/features2d/KeyPointTest.java rename to modules/java/android_test/src/org/opencv/test/core/KeyPointTest.java index 2a0b9253ef..71f3a320b6 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/KeyPointTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/KeyPointTest.java @@ -1,7 +1,7 @@ -package org.opencv.test.features2d; +package org.opencv.test.core; import org.opencv.core.Point; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; public class KeyPointTest extends OpenCVTestCase { diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java index 4fdaa2db62..060175234f 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java @@ -7,7 +7,7 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.features2d.DescriptorExtractor; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java index 2d43307352..ae8645e488 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java @@ -11,11 +11,11 @@ import org.opencv.core.MatOfDMatch; import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import org.opencv.features2d.DescriptorExtractor; import org.opencv.features2d.DescriptorMatcher; import org.opencv.features2d.FeatureDetector; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java index 08ff220ede..63cb71ad8c 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java @@ -10,7 +10,7 @@ import org.opencv.core.MatOfDMatch; import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import org.opencv.features2d.DescriptorExtractor; import org.opencv.features2d.DescriptorMatcher; import org.opencv.features2d.FeatureDetector; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java index 2d99c75b79..961d93605e 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java @@ -10,7 +10,7 @@ import org.opencv.core.MatOfDMatch; import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import org.opencv.features2d.DescriptorExtractor; import org.opencv.features2d.DescriptorMatcher; import org.opencv.features2d.FeatureDetector; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java index 5d0ab51e4b..485f9686e3 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java @@ -10,11 +10,11 @@ import org.opencv.core.MatOfDMatch; import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import org.opencv.features2d.DescriptorExtractor; import org.opencv.features2d.DescriptorMatcher; import org.opencv.features2d.FeatureDetector; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java index 6a097b4fa5..c19d1d5f5d 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java @@ -10,11 +10,11 @@ import org.opencv.core.MatOfDMatch; import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import org.opencv.features2d.DescriptorExtractor; import org.opencv.features2d.DescriptorMatcher; import org.opencv.features2d.FeatureDetector; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java index 0b7d289d53..df123d2a18 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java @@ -9,7 +9,7 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.features2d.FeatureDetector; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/Features2dTest.java b/modules/java/android_test/src/org/opencv/test/features2d/Features2dTest.java index 5b815fd145..2118b53065 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/Features2dTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/Features2dTest.java @@ -12,12 +12,12 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.MatOfPoint2f; import org.opencv.core.Point; import org.opencv.core.Range; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import org.opencv.features2d.DescriptorExtractor; import org.opencv.features2d.DescriptorMatcher; import org.opencv.features2d.FeatureDetector; import org.opencv.features2d.Features2d; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.highgui.Highgui; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java index 70c994b288..8239473697 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java @@ -11,11 +11,11 @@ import org.opencv.core.MatOfDMatch; import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; import org.opencv.features2d.DescriptorExtractor; import org.opencv.features2d.DescriptorMatcher; import org.opencv.features2d.FeatureDetector; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java index 4ccf09808a..2a14dd99aa 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java @@ -7,7 +7,7 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.features2d.DescriptorExtractor; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java index 8add9f4933..c793a6c3ba 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java @@ -7,7 +7,7 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.features2d.DescriptorExtractor; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/STARFeatureDetectorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/STARFeatureDetectorTest.java index 0b7e4e1031..35e332c5cf 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/STARFeatureDetectorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/STARFeatureDetectorTest.java @@ -9,7 +9,7 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.features2d.FeatureDetector; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java index af2e26efbe..6d63e36d59 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java @@ -7,7 +7,7 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.features2d.DescriptorExtractor; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java index 778d6f3735..b3c59b016f 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java @@ -13,7 +13,7 @@ import org.opencv.core.MatOfKeyPoint; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.features2d.FeatureDetector; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; diff --git a/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java b/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java index 7a07115234..117bbd8083 100644 --- a/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java +++ b/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java @@ -5,8 +5,8 @@ import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Point3; import org.opencv.core.Rect; -import org.opencv.features2d.DMatch; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.DMatch; +import org.opencv.core.KeyPoint; import org.opencv.test.OpenCVTestCase; import org.opencv.utils.Converters; diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 7447be91d3..d387e9aa7d 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -10,7 +10,7 @@ except: class_ignore_list = ( #core - "FileNode", "FileStorage", "KDTree", + "FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch", #highgui "VideoWriter", "VideoCapture", ) diff --git a/modules/java/generator/src/java/features2d+DMatch.java b/modules/java/generator/src/java/core+DMatch.java similarity index 97% rename from modules/java/generator/src/java/features2d+DMatch.java rename to modules/java/generator/src/java/core+DMatch.java index 4b1615ac5b..12bd86ec01 100644 --- a/modules/java/generator/src/java/features2d+DMatch.java +++ b/modules/java/generator/src/java/core+DMatch.java @@ -1,4 +1,4 @@ -package org.opencv.features2d; +package org.opencv.core; //C++: class DMatch diff --git a/modules/java/generator/src/java/features2d+KeyPoint.java b/modules/java/generator/src/java/core+KeyPoint.java similarity index 98% rename from modules/java/generator/src/java/features2d+KeyPoint.java rename to modules/java/generator/src/java/core+KeyPoint.java index ac65097d8b..de5b2151ff 100644 --- a/modules/java/generator/src/java/features2d+KeyPoint.java +++ b/modules/java/generator/src/java/core+KeyPoint.java @@ -1,4 +1,4 @@ -package org.opencv.features2d; +package org.opencv.core; import org.opencv.core.Point; diff --git a/modules/java/generator/src/java/core+MatOfDMatch.java b/modules/java/generator/src/java/core+MatOfDMatch.java index 7a3094933c..2f90f32840 100644 --- a/modules/java/generator/src/java/core+MatOfDMatch.java +++ b/modules/java/generator/src/java/core+MatOfDMatch.java @@ -3,7 +3,7 @@ package org.opencv.core; import java.util.Arrays; import java.util.List; -import org.opencv.features2d.DMatch; +import org.opencv.core.DMatch; public class MatOfDMatch extends Mat { // 32FC4 diff --git a/modules/java/generator/src/java/core+MatOfKeyPoint.java b/modules/java/generator/src/java/core+MatOfKeyPoint.java index b91fedcee8..a30805e18d 100644 --- a/modules/java/generator/src/java/core+MatOfKeyPoint.java +++ b/modules/java/generator/src/java/core+MatOfKeyPoint.java @@ -3,7 +3,7 @@ package org.opencv.core; import java.util.Arrays; import java.util.List; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.KeyPoint; public class MatOfKeyPoint extends Mat { // 32FC7 diff --git a/modules/java/generator/src/java/utils+Converters.java b/modules/java/generator/src/java/utils+Converters.java index 49c0844a87..cd4fb9863a 100644 --- a/modules/java/generator/src/java/utils+Converters.java +++ b/modules/java/generator/src/java/utils+Converters.java @@ -14,8 +14,8 @@ import org.opencv.core.MatOfPoint3f; import org.opencv.core.Point; import org.opencv.core.Point3; import org.opencv.core.Rect; -import org.opencv.features2d.DMatch; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.DMatch; +import org.opencv.core.KeyPoint; public class Converters { diff --git a/modules/java/test/src/org/opencv/test/OpenCVTestCase.java b/modules/java/test/src/org/opencv/test/OpenCVTestCase.java index ac1bf863ce..fd29096649 100644 --- a/modules/java/test/src/org/opencv/test/OpenCVTestCase.java +++ b/modules/java/test/src/org/opencv/test/OpenCVTestCase.java @@ -23,8 +23,8 @@ import org.opencv.core.Point3; import org.opencv.core.Rect; import org.opencv.core.Scalar; import org.opencv.core.Size; -import org.opencv.features2d.DMatch; -import org.opencv.features2d.KeyPoint; +import org.opencv.core.DMatch; +import org.opencv.core.KeyPoint; import org.opencv.highgui.Highgui; public class OpenCVTestCase extends TestCase { diff --git a/modules/ocl/CMakeLists.txt b/modules/ocl/CMakeLists.txt index a7cd3a0715..a46aa5f967 100644 --- a/modules/ocl/CMakeLists.txt +++ b/modules/ocl/CMakeLists.txt @@ -3,5 +3,5 @@ if(NOT HAVE_OPENCL) endif() set(the_description "OpenCL-accelerated Computer Vision") -ocv_define_module(ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video) +ocv_define_module(ocl opencv_core opencv_imgproc opencv_objdetect opencv_video) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow) diff --git a/modules/ocl/include/opencv2/ocl.hpp b/modules/ocl/include/opencv2/ocl.hpp index 1f2b906ba3..2d8f5dfec1 100644 --- a/modules/ocl/include/opencv2/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl.hpp @@ -50,7 +50,7 @@ #include "opencv2/core.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/objdetect.hpp" -#include "opencv2/features2d.hpp" +//#include "opencv2/features2d.hpp" namespace cv { diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt index 1eaeb39336..1b0bba3982 100644 --- a/modules/ts/CMakeLists.txt +++ b/modules/ts/CMakeLists.txt @@ -16,7 +16,7 @@ endif() ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) -ocv_add_module(ts opencv_core opencv_features2d) +ocv_add_module(ts opencv_core opencv_imgproc opencv_highgui) ocv_glob_module_sources() ocv_module_include_directories() diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index de48a8083e..2e333a020e 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -2,7 +2,6 @@ #define __OPENCV_TS_PERF_HPP__ #include "opencv2/core.hpp" -#include "opencv2/features2d.hpp" #include "ts_gtest.h" #ifdef HAVE_TBB From 2edfae5070d5a8cf669e0d72d24eff7c28aeaf95 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 26 Mar 2013 17:20:51 +0400 Subject: [PATCH 2/2] Move documentation for cv::KeyPoint and cv::DMatch to core --- modules/core/doc/basic_structures.rst | 89 +++++++++++++++++++ ...mmon_interfaces_of_descriptor_matchers.rst | 28 ------ ...common_interfaces_of_feature_detectors.rst | 58 ------------ 3 files changed, 89 insertions(+), 86 deletions(-) diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index 2d0faf2c60..de6ecfb142 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -368,6 +368,95 @@ The static method ``Range::all()`` returns a special variable that means "the wh } +KeyPoint +-------- +.. ocv:class:: KeyPoint + + Data structure for salient point detectors. + + .. ocv:member:: Point2f pt + + coordinates of the keypoint + + .. ocv:member:: float size + + diameter of the meaningful keypoint neighborhood + + .. ocv:member:: float angle + + computed orientation of the keypoint (-1 if not applicable). Its possible values are in a range [0,360) degrees. It is measured relative to image coordinate system (y-axis is directed downward), ie in clockwise. + + .. ocv:member:: float response + + the response by which the most strong keypoints have been selected. Can be used for further sorting or subsampling + + .. ocv:member:: int octave + + octave (pyramid layer) from which the keypoint has been extracted + + .. ocv:member:: int class_id + + object id that can be used to clustered keypoints by an object they belong to + +KeyPoint::KeyPoint +------------------ +The keypoint constructors + +.. ocv:function:: KeyPoint::KeyPoint() + +.. ocv:function:: KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1) + +.. ocv:function:: KeyPoint::KeyPoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1) + +.. ocv:pyfunction:: cv2.KeyPoint([x, y, _size[, _angle[, _response[, _octave[, _class_id]]]]]) -> + + :param x: x-coordinate of the keypoint + + :param y: y-coordinate of the keypoint + + :param _pt: x & y coordinates of the keypoint + + :param _size: keypoint diameter + + :param _angle: keypoint orientation + + :param _response: keypoint detector response on the keypoint (that is, strength of the keypoint) + + :param _octave: pyramid octave in which the keypoint has been detected + + :param _class_id: object id + + +DMatch +------ +.. ocv:struct:: DMatch + +Class for matching keypoint descriptors: query descriptor index, +train descriptor index, train image index, and distance between descriptors. :: + + struct DMatch + { + DMatch() : queryIdx(-1), trainIdx(-1), imgIdx(-1), + distance(std::numeric_limits::max()) {} + DMatch( int _queryIdx, int _trainIdx, float _distance ) : + queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), + distance(_distance) {} + DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) : + queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), + distance(_distance) {} + + int queryIdx; // query descriptor index + int trainIdx; // train descriptor index + int imgIdx; // train image index + + float distance; + + // less is better + bool operator<( const DMatch &m ) const; + }; + + + .. _Ptr: Ptr diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst index bdd834c5bb..552bf8491b 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst @@ -9,34 +9,6 @@ that are represented as vectors in a multidimensional space. All objects that im descriptor matchers inherit the :ocv:class:`DescriptorMatcher` interface. -DMatch ------- -.. ocv:struct:: DMatch - -Class for matching keypoint descriptors: query descriptor index, -train descriptor index, train image index, and distance between descriptors. :: - - struct DMatch - { - DMatch() : queryIdx(-1), trainIdx(-1), imgIdx(-1), - distance(std::numeric_limits::max()) {} - DMatch( int _queryIdx, int _trainIdx, float _distance ) : - queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), - distance(_distance) {} - DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) : - queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), - distance(_distance) {} - - int queryIdx; // query descriptor index - int trainIdx; // train descriptor index - int imgIdx; // train image index - - float distance; - - // less is better - bool operator<( const DMatch &m ) const; - }; - DescriptorMatcher ----------------- diff --git a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst index fe52bbe28b..3bbaa8aca1 100644 --- a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst +++ b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst @@ -8,64 +8,6 @@ between different algorithms solving the same problem. All objects that implemen inherit the :ocv:class:`FeatureDetector` interface. -KeyPoint --------- -.. ocv:class:: KeyPoint - - Data structure for salient point detectors. - - .. ocv:member:: Point2f pt - - coordinates of the keypoint - - .. ocv:member:: float size - - diameter of the meaningful keypoint neighborhood - - .. ocv:member:: float angle - - computed orientation of the keypoint (-1 if not applicable). Its possible values are in a range [0,360) degrees. It is measured relative to image coordinate system (y-axis is directed downward), ie in clockwise. - - .. ocv:member:: float response - - the response by which the most strong keypoints have been selected. Can be used for further sorting or subsampling - - .. ocv:member:: int octave - - octave (pyramid layer) from which the keypoint has been extracted - - .. ocv:member:: int class_id - - object id that can be used to clustered keypoints by an object they belong to - -KeyPoint::KeyPoint ------------------- -The keypoint constructors - -.. ocv:function:: KeyPoint::KeyPoint() - -.. ocv:function:: KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1) - -.. ocv:function:: KeyPoint::KeyPoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1) - -.. ocv:pyfunction:: cv2.KeyPoint([x, y, _size[, _angle[, _response[, _octave[, _class_id]]]]]) -> - - :param x: x-coordinate of the keypoint - - :param y: y-coordinate of the keypoint - - :param _pt: x & y coordinates of the keypoint - - :param _size: keypoint diameter - - :param _angle: keypoint orientation - - :param _response: keypoint detector response on the keypoint (that is, strength of the keypoint) - - :param _octave: pyramid octave in which the keypoint has been detected - - :param _class_id: object id - FeatureDetector ---------------