Move cv::KeyPoint and cv::DMatch to core
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Tue, 26 Mar 2013 10:58:09 +0000 (14:58 +0400)
committerAndrey Kamaev <andrey.kamaev@itseez.com>
Tue, 26 Mar 2013 12:08:43 +0000 (16:08 +0400)
37 files changed:
modules/contrib/CMakeLists.txt
modules/core/include/opencv2/core.hpp
modules/core/include/opencv2/core/operations.hpp
modules/core/src/persistence.cpp
modules/core/src/types.cpp [new file with mode: 0644]
modules/features2d/include/opencv2/features2d.hpp
modules/features2d/src/keypoint.cpp
modules/flann/include/opencv2/flann.hpp
modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
modules/java/android_test/src/org/opencv/test/core/DMatchTest.java [moved from modules/java/android_test/src/org/opencv/test/features2d/DMatchTest.java with 93% similarity]
modules/java/android_test/src/org/opencv/test/core/KeyPointTest.java [moved from modules/java/android_test/src/org/opencv/test/features2d/KeyPointTest.java with 96% similarity]
modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java
modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java
modules/java/android_test/src/org/opencv/test/features2d/Features2dTest.java
modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java
modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java
modules/java/android_test/src/org/opencv/test/features2d/STARFeatureDetectorTest.java
modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java
modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java
modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java
modules/java/generator/gen_java.py
modules/java/generator/src/java/core+DMatch.java [moved from modules/java/generator/src/java/features2d+DMatch.java with 97% similarity]
modules/java/generator/src/java/core+KeyPoint.java [moved from modules/java/generator/src/java/features2d+KeyPoint.java with 98% similarity]
modules/java/generator/src/java/core+MatOfDMatch.java
modules/java/generator/src/java/core+MatOfKeyPoint.java
modules/java/generator/src/java/utils+Converters.java
modules/java/test/src/org/opencv/test/OpenCVTestCase.java
modules/ocl/CMakeLists.txt
modules/ocl/include/opencv2/ocl.hpp
modules/ts/CMakeLists.txt
modules/ts/include/opencv2/ts/ts_perf.hpp

index 81c9ea4..1d3432b 100644 (file)
@@ -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)
index ec4f561..4034421 100644 (file)
@@ -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<KeyPoint>& keypoints,
+                        CV_OUT std::vector<Point2f>& points2f,
+                        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
+    static void convert(const std::vector<Point2f>& points2f,
+                        CV_OUT std::vector<KeyPoint>& 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 ////////////////////////////////
 
 /*!
index 26f9146..ef34581 100644 (file)
@@ -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<KeyPoint>& keypoints);
+CV_EXPORTS void write(FileStorage& fs, const String& objname, const std::vector<KeyPoint>& keypoints);
+
 inline FileNode::operator int() const
 {
     int value;
index bd3aab9..52be883 100644 (file)
@@ -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<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];
+        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<KeyPoint>& 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 (file)
index 0000000..4dbb06f
--- /dev/null
@@ -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<KeyPoint>& keypoints, std::vector<Point2f>& points2f,
+                       const std::vector<int>& 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<Point2f>& points2f, std::vector<KeyPoint>& 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
index 4184f5e..a3a8fe2 100644 (file)
@@ -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<KeyPoint>& keypoints,
-                        CV_OUT std::vector<Point2f>& points2f,
-                        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
-    static void convert(const std::vector<Point2f>& points2f,
-                        CV_OUT std::vector<KeyPoint>& 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<KeyPoint>& keypoints);
-//! reads vector of keypoints from the specified file storage node
-CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector<KeyPoint>& keypoints);
+// //! writes vector of keypoints to the file storage
+// CV_EXPORTS void write(FileStorage& fs, const String& name, const std::vector<KeyPoint>& keypoints);
+// //! reads vector of keypoints from the specified file storage node
+// CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector<KeyPoint>& keypoints);
 
 /*
  * A class filters a vector of keypoints.
@@ -1029,33 +975,6 @@ template<int cellsize> 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                                     *
 \****************************************************************************************/
 /*
index cec6fca..118d3df 100644 (file)
 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<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];
-        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<KeyPoint>& 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<KeyPoint>& keypoints, std::vector<Point2f>& points2f,
-                       const std::vector<int>& 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<Point2f>& points2f, std::vector<KeyPoint>& 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) :
index 1bc7a3c..0fc9298 100644 (file)
@@ -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
 {
index 5c93211..97cdca7 100644 (file)
@@ -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;
@@ -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 {
index 4fdaa2d..0601752 100644 (file)
@@ -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;
 
index 2d43307..ae8645e 100644 (file)
@@ -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;
 
index 08ff220..63cb71a 100644 (file)
@@ -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;
index 2d99c75..961d936 100644 (file)
@@ -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;
index 5d0ab51..485f968 100644 (file)
@@ -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;
 
index 6a097b4..c19d1d5 100644 (file)
@@ -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;
 
index 0b7d289..df123d2 100644 (file)
@@ -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;
 
index 5b815fd..2118b53 100644 (file)
@@ -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;
index 70c994b..8239473 100644 (file)
@@ -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;
 
index 4ccf098..2a14dd9 100644 (file)
@@ -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;
 
index 8add9f4..c793a6c 100644 (file)
@@ -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;
 
index 0b7e4e1..35e332c 100644 (file)
@@ -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;
 
index af2e26e..6d63e36 100644 (file)
@@ -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;
 
index 778d6f3..b3c59b0 100644 (file)
@@ -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;
 
index 7a07115..117bbd8 100644 (file)
@@ -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;
 
index 7447be9..d387e9a 100755 (executable)
@@ -10,7 +10,7 @@ except:
 
 class_ignore_list = (
     #core
-    "FileNode", "FileStorage", "KDTree",
+    "FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch",
     #highgui
     "VideoWriter", "VideoCapture",
 )
index 7a30949..2f90f32 100644 (file)
@@ -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
index b91fedc..a30805e 100644 (file)
@@ -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
index 49c0844..cd4fb98 100644 (file)
@@ -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 {
 
index ac1bf86..fd29096 100644 (file)
@@ -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 {
index a7cd3a0..a46aa5f 100644 (file)
@@ -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)
index 1f2b906..2d8f5df 100644 (file)
@@ -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
 {
index 1eaeb39..1b0bba3 100644 (file)
@@ -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()
index de48a80..2e333a0 100644 (file)
@@ -2,7 +2,6 @@
 #define __OPENCV_TS_PERF_HPP__
 
 #include "opencv2/core.hpp"
-#include "opencv2/features2d.hpp"
 #include "ts_gtest.h"
 
 #ifdef HAVE_TBB