From 5166a6b71647a8eea483b4907d5692f470de7a8b Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 13 Apr 2026 15:23:48 +0300 Subject: [PATCH] Migrated goodFeaturesToTrack to features module. --- modules/features/include/opencv2/features.hpp | 85 ++++++++++++++++++ modules/features/misc/java/gen_dict.json | 3 + .../features/misc/java/test/FeaturesTest.java | 23 +++++ modules/features/misc/js/gen_dict.json | 3 + modules/features/misc/objc/gen_dict.json | 1 + .../misc/objc/test/FeaturesTest.swift | 30 +++++++ .../perf/opencl/perf_gftt.cpp | 0 .../perf/perf_goodFeaturesToTrack.cpp | 0 .../src/featureselect.cpp | 8 +- .../{imgproc => features}/src/opencl/gftt.cl | 0 .../test/ocl/test_gftt.cpp | 0 .../test/test_goodfeaturetotrack.cpp | 0 modules/features/test/test_precomp.hpp | 1 + modules/imgproc/include/opencv2/imgproc.hpp | 86 ------------------- modules/imgproc/misc/java/gen_dict.json | 1 - .../imgproc/misc/java/test/ImgprocTest.java | 20 ----- modules/imgproc/misc/js/gen_dict.json | 1 - modules/imgproc/misc/objc/gen_dict.json | 1 - .../imgproc/misc/objc/test/ImgprocTest.swift | 20 ----- modules/video/CMakeLists.txt | 1 + .../video/perf/opencl/perf_optflow_pyrlk.cpp | 1 + modules/video/test/ocl/test_optflowpyrlk.cpp | 1 + samples/cpp/lkdemo.cpp | 1 + .../TrackingMotion/cornerSubPix_Demo.cpp | 1 + .../goodFeaturesToTrack_Demo.cpp | 1 + .../video/optical_flow/optical_flow.cpp | 1 + samples/gpu/pyrlk_optical_flow.cpp | 3 +- .../corner_subpixels/CornerSubPixDemo.java | 3 +- .../GoodFeaturesToTrackDemo.java | 3 +- samples/tapi/pyrlk_optical_flow.cpp | 1 + 30 files changed, 164 insertions(+), 136 deletions(-) create mode 100644 modules/features/misc/objc/test/FeaturesTest.swift rename modules/{imgproc => features}/perf/opencl/perf_gftt.cpp (100%) rename modules/{imgproc => features}/perf/perf_goodFeaturesToTrack.cpp (100%) rename modules/{imgproc => features}/src/featureselect.cpp (98%) rename modules/{imgproc => features}/src/opencl/gftt.cl (100%) rename modules/{imgproc => features}/test/ocl/test_gftt.cpp (100%) rename modules/{imgproc => features}/test/test_goodfeaturetotrack.cpp (100%) diff --git a/modules/features/include/opencv2/features.hpp b/modules/features/include/opencv2/features.hpp index a1f4729922..a82e54e7ed 100644 --- a/modules/features/include/opencv2/features.hpp +++ b/modules/features/include/opencv2/features.hpp @@ -130,6 +130,91 @@ public: static void retainBest( std::vector& keypoints, int npoints ); }; +/** @brief Determines strong corners on an image. + +The function finds the most prominent corners in the image or in the specified image region, as +described in @cite Shi94 + +- Function calculates the corner quality measure at every source image pixel using the + #cornerMinEigenVal or #cornerHarris . +- Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are + retained). +- The corners with the minimal eigenvalue less than + \f$\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\f$ are rejected. +- The remaining corners are sorted by the quality measure in the descending order. +- Function throws away each corner for which there is a stronger corner at a distance less than + maxDistance. + +The function can be used to initialize a point-based tracker of an object. + +@note If the function is called with different values A and B of the parameter qualityLevel , and +A \> B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector +with qualityLevel=B . + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param corners Output vector of detected corners. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Optional region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + +@sa cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform, + */ + +CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask = noArray(), int blockSize = 3, + bool useHarrisDetector = false, double k = 0.04 ); + +CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask, int blockSize, + int gradientSize, bool useHarrisDetector = false, + double k = 0.04 ); + +/** @brief Same as above, but returns also quality measure of the detected corners. + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param corners Output vector of detected corners. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param cornersQuality Output vector of quality measure of the detected corners. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param gradientSize Aperture parameter for the Sobel operator used for derivatives computation. +See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + */ +CV_EXPORTS CV_WRAP_AS(goodFeaturesToTrackWithQuality) void goodFeaturesToTrack( + InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask, OutputArray cornersQuality, int blockSize = 3, + int gradientSize = 3, bool useHarrisDetector = false, double k = 0.04); /************************************ Base Classes ************************************/ diff --git a/modules/features/misc/java/gen_dict.json b/modules/features/misc/java/gen_dict.json index 1d62b5f48c..70b6cfbad5 100644 --- a/modules/features/misc/java/gen_dict.json +++ b/modules/features/misc/java/gen_dict.json @@ -14,5 +14,8 @@ "jni_type": "jbyte", "suffix": "B" } + }, + "func_arg_fix" : { + "goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} } } } diff --git a/modules/features/misc/java/test/FeaturesTest.java b/modules/features/misc/java/test/FeaturesTest.java index c32635b119..a46296a199 100644 --- a/modules/features/misc/java/test/FeaturesTest.java +++ b/modules/features/misc/java/test/FeaturesTest.java @@ -10,6 +10,7 @@ import org.opencv.core.Mat; import org.opencv.core.MatOfInt; import org.opencv.core.MatOfDMatch; import org.opencv.core.MatOfKeyPoint; +import org.opencv.core.MatOfPoint; import org.opencv.core.MatOfPoint2f; import org.opencv.core.Point; import org.opencv.core.Range; @@ -19,6 +20,7 @@ import org.opencv.features.DescriptorMatcher; import org.opencv.features.Features; import org.opencv.core.KeyPoint; import org.opencv.imgcodecs.Imgcodecs; +import org.opencv.imgproc.Imgproc; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; import org.opencv.features.Feature2D; @@ -169,4 +171,25 @@ public class FeaturesTest extends OpenCVTestCase { assertMatEqual(ref, outImg); } + + public void testGoodFeaturesToTrackMatListOfPointIntDoubleDouble() { + Mat src = gray0; + Imgproc.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); + MatOfPoint lp = new MatOfPoint(); + + Features.goodFeaturesToTrack(src, lp, 100, 0.01, 3); + + assertEquals(4, lp.total()); + } + + public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble() { + Mat src = gray0; + Imgproc.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); + MatOfPoint lp = new MatOfPoint(); + + Features.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4, 3, true, 0); + + assertEquals(4, lp.total()); + } + } diff --git a/modules/features/misc/js/gen_dict.json b/modules/features/misc/js/gen_dict.json index b6cc973fd7..4e563a68bf 100644 --- a/modules/features/misc/js/gen_dict.json +++ b/modules/features/misc/js/gen_dict.json @@ -1,6 +1,9 @@ { "whitelist": { + "": [ + "goodFeaturesToTrack" + ], "Feature2D": ["detect", "compute", "detectAndCompute", "descriptorSize", "descriptorType", "defaultNorm", "empty", "getDefaultName"], "ORB": ["create", "setMaxFeatures", "setScaleFactor", "setNLevels", "setEdgeThreshold", "setFastThreshold", "setFirstLevel", "setWTA_K", "setScoreType", "setPatchSize", "getFastThreshold", "getDefaultName"], "MSER": ["create", "detectRegions", "setDelta", "getDelta", "setMinArea", "getMinArea", "setMaxArea", "getMaxArea", "setPass2Only", "getPass2Only", "getDefaultName"], diff --git a/modules/features/misc/objc/gen_dict.json b/modules/features/misc/objc/gen_dict.json index e5d0ffc25a..e88518de2d 100644 --- a/modules/features/misc/objc/gen_dict.json +++ b/modules/features/misc/objc/gen_dict.json @@ -9,6 +9,7 @@ "FastFeatureDetector" : { "DetectorType": "FastDetectorType" } }, "func_arg_fix" : { + "goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} }, "Feature2D": { "(void)compute:(NSArray*)images keypoints:(NSMutableArray*>*)keypoints descriptors:(NSMutableArray*)descriptors" : { "compute" : {"name" : "compute2"} }, "(void)detect:(NSArray*)images keypoints:(NSMutableArray*>*)keypoints masks:(NSArray*)masks" : { "detect" : {"name" : "detect2"} } diff --git a/modules/features/misc/objc/test/FeaturesTest.swift b/modules/features/misc/objc/test/FeaturesTest.swift new file mode 100644 index 0000000000..234158d151 --- /dev/null +++ b/modules/features/misc/objc/test/FeaturesTest.swift @@ -0,0 +1,30 @@ +// +// FeaturesTest.swift +// +// Created by Alexander Smorkalov on 2026/13/04. +// + +import XCTest +import OpenCV + +class ImgprocTest: OpenCVTestCase { + func testGoodFeaturesToTrackMatListOfPointIntDoubleDouble() { + let src = gray0 + Imgproc.rectangle(img: src, pt1: Point(x: 2, y: 2), pt2: Point(x: 8, y: 8), color: Scalar(100), thickness: -1) + var lp = [Point]() + + Imgproc.goodFeaturesToTrack(image: src, corners: &lp, maxCorners: 100, qualityLevel: 0.01, minDistance: 3) + + XCTAssertEqual(4, lp.count) + } + + func testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble() { + let src = gray0 + Imgproc.rectangle(img: src, pt1: Point(x: 2, y: 2), pt2: Point(x: 8, y: 8), color: Scalar(100), thickness: -1) + var lp = [Point]() + + Imgproc.goodFeaturesToTrack(image: src, corners: &lp, maxCorners: 100, qualityLevel: 0.01, minDistance: 3, mask: gray1, blockSize: 4, gradientSize: 3, useHarrisDetector: true, k: 0) + + XCTAssertEqual(4, lp.count) + } +} diff --git a/modules/imgproc/perf/opencl/perf_gftt.cpp b/modules/features/perf/opencl/perf_gftt.cpp similarity index 100% rename from modules/imgproc/perf/opencl/perf_gftt.cpp rename to modules/features/perf/opencl/perf_gftt.cpp diff --git a/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp b/modules/features/perf/perf_goodFeaturesToTrack.cpp similarity index 100% rename from modules/imgproc/perf/perf_goodFeaturesToTrack.cpp rename to modules/features/perf/perf_goodFeaturesToTrack.cpp diff --git a/modules/imgproc/src/featureselect.cpp b/modules/features/src/featureselect.cpp similarity index 98% rename from modules/imgproc/src/featureselect.cpp rename to modules/features/src/featureselect.cpp index d7524624c5..f8888e8b8b 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/features/src/featureselect.cpp @@ -40,7 +40,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels_imgproc.hpp" +#include "opencl_kernels_features.hpp" #include #include @@ -100,7 +100,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners, wgs2_aligned <<= 1; wgs2_aligned >>= 1; - ocl::Kernel k("maxEigenVal", ocl::imgproc::gftt_oclsrc, + ocl::Kernel k("maxEigenVal", ocl::features::gftt_oclsrc, format("-D OP_MAX_EIGEN_VAL -D WGS=%d -D groupnum=%d -D WGS2_ALIGNED=%d%s", (int)wgs, dbsize, wgs2_aligned, haveMask ? " -D HAVE_MASK" : "")); if (k.empty()) @@ -123,7 +123,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners, if (!k.run(1, &globalsize, &wgs, false)) return false; - ocl::Kernel k2("maxEigenValTask", ocl::imgproc::gftt_oclsrc, + ocl::Kernel k2("maxEigenValTask", ocl::features::gftt_oclsrc, format("-D OP_MAX_EIGEN_VAL -D WGS=%zu -D WGS2_ALIGNED=%d -D groupnum=%d", wgs, wgs2_aligned, dbsize)); if (k2.empty()) @@ -137,7 +137,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners, // collect list of pointers to features - put them into temporary image { - ocl::Kernel k("findCorners", ocl::imgproc::gftt_oclsrc, + ocl::Kernel k("findCorners", ocl::features::gftt_oclsrc, format("-D OP_FIND_CORNERS%s", haveMask ? " -D HAVE_MASK" : "")); if (k.empty()) return false; diff --git a/modules/imgproc/src/opencl/gftt.cl b/modules/features/src/opencl/gftt.cl similarity index 100% rename from modules/imgproc/src/opencl/gftt.cl rename to modules/features/src/opencl/gftt.cl diff --git a/modules/imgproc/test/ocl/test_gftt.cpp b/modules/features/test/ocl/test_gftt.cpp similarity index 100% rename from modules/imgproc/test/ocl/test_gftt.cpp rename to modules/features/test/ocl/test_gftt.cpp diff --git a/modules/imgproc/test/test_goodfeaturetotrack.cpp b/modules/features/test/test_goodfeaturetotrack.cpp similarity index 100% rename from modules/imgproc/test/test_goodfeaturetotrack.cpp rename to modules/features/test/test_goodfeaturetotrack.cpp diff --git a/modules/features/test/test_precomp.hpp b/modules/features/test/test_precomp.hpp index 6e0c1eaadb..49b925ec42 100644 --- a/modules/features/test/test_precomp.hpp +++ b/modules/features/test/test_precomp.hpp @@ -5,6 +5,7 @@ #define __OPENCV_TEST_PRECOMP_HPP__ #include "opencv2/ts.hpp" +#include "opencv2/ts/ocl_test.hpp" #include "opencv2/features.hpp" #endif diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 4f6a598232..01ca3329a9 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -2103,92 +2103,6 @@ CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria ); -/** @brief Determines strong corners on an image. - -The function finds the most prominent corners in the image or in the specified image region, as -described in @cite Shi94 - -- Function calculates the corner quality measure at every source image pixel using the - #cornerMinEigenVal or #cornerHarris . -- Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are - retained). -- The corners with the minimal eigenvalue less than - \f$\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\f$ are rejected. -- The remaining corners are sorted by the quality measure in the descending order. -- Function throws away each corner for which there is a stronger corner at a distance less than - maxDistance. - -The function can be used to initialize a point-based tracker of an object. - -@note If the function is called with different values A and B of the parameter qualityLevel , and -A \> B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector -with qualityLevel=B . - -@param image Input 8-bit or floating-point 32-bit, single-channel image. -@param corners Output vector of detected corners. -@param maxCorners Maximum number of corners to return. If there are more corners than are found, -the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set -and all detected corners are returned. -@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The -parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue -(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the -quality measure less than the product are rejected. For example, if the best corner has the -quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure -less than 15 are rejected. -@param minDistance Minimum possible Euclidean distance between the returned corners. -@param mask Optional region of interest. If the image is not empty (it needs to have the type -CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. -@param blockSize Size of an average block for computing a derivative covariation matrix over each -pixel neighborhood. See cornerEigenValsAndVecs . -@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) -or #cornerMinEigenVal. -@param k Free parameter of the Harris detector. - -@sa cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform, - */ - -CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, - int maxCorners, double qualityLevel, double minDistance, - InputArray mask = noArray(), int blockSize = 3, - bool useHarrisDetector = false, double k = 0.04 ); - -CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, - int maxCorners, double qualityLevel, double minDistance, - InputArray mask, int blockSize, - int gradientSize, bool useHarrisDetector = false, - double k = 0.04 ); - -/** @brief Same as above, but returns also quality measure of the detected corners. - -@param image Input 8-bit or floating-point 32-bit, single-channel image. -@param corners Output vector of detected corners. -@param maxCorners Maximum number of corners to return. If there are more corners than are found, -the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set -and all detected corners are returned. -@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The -parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue -(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the -quality measure less than the product are rejected. For example, if the best corner has the -quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure -less than 15 are rejected. -@param minDistance Minimum possible Euclidean distance between the returned corners. -@param mask Region of interest. If the image is not empty (it needs to have the type -CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. -@param cornersQuality Output vector of quality measure of the detected corners. -@param blockSize Size of an average block for computing a derivative covariation matrix over each -pixel neighborhood. See cornerEigenValsAndVecs . -@param gradientSize Aperture parameter for the Sobel operator used for derivatives computation. -See cornerEigenValsAndVecs . -@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) -or #cornerMinEigenVal. -@param k Free parameter of the Harris detector. - */ -CV_EXPORTS CV_WRAP_AS(goodFeaturesToTrackWithQuality) void goodFeaturesToTrack( - InputArray image, OutputArray corners, - int maxCorners, double qualityLevel, double minDistance, - InputArray mask, OutputArray cornersQuality, int blockSize = 3, - int gradientSize = 3, bool useHarrisDetector = false, double k = 0.04); - /** @example samples/cpp/tutorial_code/ImgTrans/houghlines.cpp An example using the Hough line detector ![Sample input image](Hough_Lines_Tutorial_Original_Image.jpg) ![Output image](Hough_Lines_Tutorial_Result.jpg) diff --git a/modules/imgproc/misc/java/gen_dict.json b/modules/imgproc/misc/java/gen_dict.json index 5559abc8af..accb4959b3 100644 --- a/modules/imgproc/misc/java/gen_dict.json +++ b/modules/imgproc/misc/java/gen_dict.json @@ -105,7 +105,6 @@ } }, "func_arg_fix" : { - "goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} }, "minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} }, "fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} }, "fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"} }, diff --git a/modules/imgproc/misc/java/test/ImgprocTest.java b/modules/imgproc/misc/java/test/ImgprocTest.java index 0328047c3c..836ddf575b 100644 --- a/modules/imgproc/misc/java/test/ImgprocTest.java +++ b/modules/imgproc/misc/java/test/ImgprocTest.java @@ -1007,26 +1007,6 @@ public class ImgprocTest extends OpenCVTestCase { assertMatEqual(truth, dst); } - public void testGoodFeaturesToTrackMatListOfPointIntDoubleDouble() { - Mat src = gray0; - Imgproc.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); - MatOfPoint lp = new MatOfPoint(); - - Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3); - - assertEquals(4, lp.total()); - } - - public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble() { - Mat src = gray0; - Imgproc.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); - MatOfPoint lp = new MatOfPoint(); - - Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4, 3, true, 0); - - assertEquals(4, lp.total()); - } - public void testGrabCutMatMatRectMatMatInt() { fail("Not yet implemented"); } diff --git a/modules/imgproc/misc/js/gen_dict.json b/modules/imgproc/misc/js/gen_dict.json index a26808e38b..97d7823588 100644 --- a/modules/imgproc/misc/js/gen_dict.json +++ b/modules/imgproc/misc/js/gen_dict.json @@ -59,7 +59,6 @@ "getRectSubPix", "getRotationMatrix2D", "getStructuringElement", - "goodFeaturesToTrack", "grabCut", "HoughCircles", "HoughLines", diff --git a/modules/imgproc/misc/objc/gen_dict.json b/modules/imgproc/misc/objc/gen_dict.json index 76429dd2eb..997b2c0ca3 100644 --- a/modules/imgproc/misc/objc/gen_dict.json +++ b/modules/imgproc/misc/objc/gen_dict.json @@ -45,7 +45,6 @@ }, "func_arg_fix" : { "Imgproc" : { - "goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} }, "minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} }, "fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} }, "fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"}, diff --git a/modules/imgproc/misc/objc/test/ImgprocTest.swift b/modules/imgproc/misc/objc/test/ImgprocTest.swift index 7189c9bfc5..8a32ecb236 100644 --- a/modules/imgproc/misc/objc/test/ImgprocTest.swift +++ b/modules/imgproc/misc/objc/test/ImgprocTest.swift @@ -848,26 +848,6 @@ class ImgprocTest: OpenCVTestCase { try assertMatEqual(truth!, dst) } - func testGoodFeaturesToTrackMatListOfPointIntDoubleDouble() { - let src = gray0 - Imgproc.rectangle(img: src, pt1: Point(x: 2, y: 2), pt2: Point(x: 8, y: 8), color: Scalar(100), thickness: -1) - var lp = [Point]() - - Imgproc.goodFeaturesToTrack(image: src, corners: &lp, maxCorners: 100, qualityLevel: 0.01, minDistance: 3) - - XCTAssertEqual(4, lp.count) - } - - func testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble() { - let src = gray0 - Imgproc.rectangle(img: src, pt1: Point(x: 2, y: 2), pt2: Point(x: 8, y: 8), color: Scalar(100), thickness: -1) - var lp = [Point]() - - Imgproc.goodFeaturesToTrack(image: src, corners: &lp, maxCorners: 100, qualityLevel: 0.01, minDistance: 3, mask: gray1, blockSize: 4, gradientSize: 3, useHarrisDetector: true, k: 0) - - XCTAssertEqual(4, lp.count) - } - func testHoughCirclesMatMatIntDoubleDouble() { let sz:Int32 = 512 let img = Mat(rows: sz, cols: sz, type: CvType.CV_8U, scalar: Scalar(128)) diff --git a/modules/video/CMakeLists.txt b/modules/video/CMakeLists.txt index 410823389c..3e4d613c9f 100644 --- a/modules/video/CMakeLists.txt +++ b/modules/video/CMakeLists.txt @@ -4,6 +4,7 @@ ocv_define_module(video opencv_imgproc OPTIONAL opencv_3d + opencv_features opencv_dnn WRAP java diff --git a/modules/video/perf/opencl/perf_optflow_pyrlk.cpp b/modules/video/perf/opencl/perf_optflow_pyrlk.cpp index 5f03e68b42..5834ad1240 100644 --- a/modules/video/perf/opencl/perf_optflow_pyrlk.cpp +++ b/modules/video/perf/opencl/perf_optflow_pyrlk.cpp @@ -46,6 +46,7 @@ #include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" +#include "opencv2/features.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/test/ocl/test_optflowpyrlk.cpp b/modules/video/test/ocl/test_optflowpyrlk.cpp index 0251f68745..e3c5bada37 100644 --- a/modules/video/test/ocl/test_optflowpyrlk.cpp +++ b/modules/video/test/ocl/test_optflowpyrlk.cpp @@ -44,6 +44,7 @@ #include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" +#include "opencv2/features.hpp" #ifdef HAVE_OPENCL diff --git a/samples/cpp/lkdemo.cpp b/samples/cpp/lkdemo.cpp index 29f1419c66..64e230cbcf 100644 --- a/samples/cpp/lkdemo.cpp +++ b/samples/cpp/lkdemo.cpp @@ -1,5 +1,6 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/imgproc.hpp" +#include "opencv2/features.hpp" #include "opencv2/videoio.hpp" #include "opencv2/highgui.hpp" diff --git a/samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp b/samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp index 5004496a82..6c19aa416b 100644 --- a/samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp +++ b/samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp @@ -6,6 +6,7 @@ #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" +#include "opencv2/features.hpp" #include using namespace cv; diff --git a/samples/cpp/tutorial_code/TrackingMotion/goodFeaturesToTrack_Demo.cpp b/samples/cpp/tutorial_code/TrackingMotion/goodFeaturesToTrack_Demo.cpp index f306f30414..d92c154279 100644 --- a/samples/cpp/tutorial_code/TrackingMotion/goodFeaturesToTrack_Demo.cpp +++ b/samples/cpp/tutorial_code/TrackingMotion/goodFeaturesToTrack_Demo.cpp @@ -7,6 +7,7 @@ #include "opencv2/imgcodecs.hpp" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" +#include "opencv2/features.hpp" #include using namespace cv; diff --git a/samples/cpp/tutorial_code/video/optical_flow/optical_flow.cpp b/samples/cpp/tutorial_code/video/optical_flow/optical_flow.cpp index eb08eee4a5..83aa0a572f 100644 --- a/samples/cpp/tutorial_code/video/optical_flow/optical_flow.cpp +++ b/samples/cpp/tutorial_code/video/optical_flow/optical_flow.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/samples/gpu/pyrlk_optical_flow.cpp b/samples/gpu/pyrlk_optical_flow.cpp index fa6b376362..c39ef80962 100644 --- a/samples/gpu/pyrlk_optical_flow.cpp +++ b/samples/gpu/pyrlk_optical_flow.cpp @@ -9,6 +9,7 @@ #include #include #include +#include using namespace std; using namespace cv; @@ -328,4 +329,4 @@ int main(int argc, const char* argv[]) waitKey(0); return 0; -} \ No newline at end of file +} diff --git a/samples/java/tutorial_code/TrackingMotion/corner_subpixels/CornerSubPixDemo.java b/samples/java/tutorial_code/TrackingMotion/corner_subpixels/CornerSubPixDemo.java index cb1888c08a..9382175747 100644 --- a/samples/java/tutorial_code/TrackingMotion/corner_subpixels/CornerSubPixDemo.java +++ b/samples/java/tutorial_code/TrackingMotion/corner_subpixels/CornerSubPixDemo.java @@ -23,6 +23,7 @@ import org.opencv.core.TermCriteria; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; +import org.opencv.features.Features; class CornerSubPix { private Mat src = new Mat(); @@ -102,7 +103,7 @@ class CornerSubPix { Mat copy = src.clone(); /// Apply corner detection - Imgproc.goodFeaturesToTrack(srcGray, corners, maxCorners, qualityLevel, minDistance, new Mat(), + Features.goodFeaturesToTrack(srcGray, corners, maxCorners, qualityLevel, minDistance, new Mat(), blockSize, gradientSize, useHarrisDetector, k); /// Draw corners detected diff --git a/samples/java/tutorial_code/TrackingMotion/good_features_to_track/GoodFeaturesToTrackDemo.java b/samples/java/tutorial_code/TrackingMotion/good_features_to_track/GoodFeaturesToTrackDemo.java index 2033cd5727..a530d7436d 100644 --- a/samples/java/tutorial_code/TrackingMotion/good_features_to_track/GoodFeaturesToTrackDemo.java +++ b/samples/java/tutorial_code/TrackingMotion/good_features_to_track/GoodFeaturesToTrackDemo.java @@ -20,6 +20,7 @@ import org.opencv.core.Scalar; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; +import org.opencv.features.Features; class GoodFeaturesToTrack { private Mat src = new Mat(); @@ -99,7 +100,7 @@ class GoodFeaturesToTrack { Mat copy = src.clone(); /// Apply corner detection - Imgproc.goodFeaturesToTrack(srcGray, corners, maxCorners, qualityLevel, minDistance, new Mat(), + Features.goodFeaturesToTrack(srcGray, corners, maxCorners, qualityLevel, minDistance, new Mat(), blockSize, gradientSize, useHarrisDetector, k); /// Draw corners detected diff --git a/samples/tapi/pyrlk_optical_flow.cpp b/samples/tapi/pyrlk_optical_flow.cpp index 9c1364d180..51f85cb843 100644 --- a/samples/tapi/pyrlk_optical_flow.cpp +++ b/samples/tapi/pyrlk_optical_flow.cpp @@ -4,6 +4,7 @@ #include "opencv2/core/utility.hpp" #include "opencv2/imgcodecs.hpp" +#include "opencv2/features.hpp" #include "opencv2/videoio.hpp" #include "opencv2/highgui.hpp" #include "opencv2/core/ocl.hpp"