diff --git a/doc/tutorials/features2d/detection_of_planar_objects/detection_of_planar_objects.rst b/doc/tutorials/features2d/detection_of_planar_objects/detection_of_planar_objects.rst index add22756eb0f4c2a488d1db26b654dc956e86116..5075be3c03c17c3a3d9ffc8f0ad16e9a40849cdd 100644 --- a/doc/tutorials/features2d/detection_of_planar_objects/detection_of_planar_objects.rst +++ b/doc/tutorials/features2d/detection_of_planar_objects/detection_of_planar_objects.rst @@ -16,24 +16,15 @@ The goal of this tutorial is to learn how to use *features2d* and *calib3d* modu Mat img2 = imread(argv[2], IMREAD_GRAYSCALE); #. - Detect keypoints in both images. :: + Detect keypoints in both images and compute descriptors for each of the keypoints. :: // detecting keypoints - FastFeatureDetector detector(15); + Ptr surf = SURF::create(); vector keypoints1; - detector.detect(img1, keypoints1); - - ... // do the same for the second image - -#. - Compute descriptors for each of the keypoints. :: - - // computing descriptors - SurfDescriptorExtractor extractor; Mat descriptors1; - extractor.compute(img1, keypoints1, descriptors1); + surf->detectAndCompute(img1, Mat(), keypoints1, descriptors1); - ... // process keypoints from the second image as well + ... // do the same for the second image #. Now, find the closest matches between descriptors from the first image to the second: :: diff --git a/doc/user_guide/ug_features2d.rst b/doc/user_guide/ug_features2d.rst index 37f2097ff248f580bb7735ce8f6219b766fbd823..e5903c1f44c2e1d407674567ba4c51b6303408b0 100644 --- a/doc/user_guide/ug_features2d.rst +++ b/doc/user_guide/ug_features2d.rst @@ -65,18 +65,18 @@ Let us break the code down. :: We load two images and check if they are loaded correctly.:: // detecting keypoints - FastFeatureDetector detector(15); + Ptr detector = FastFeatureDetector::create(15); vector keypoints1, keypoints2; - detector.detect(img1, keypoints1); - detector.detect(img2, keypoints2); + detector->detect(img1, keypoints1); + detector->detect(img2, keypoints2); First, we create an instance of a keypoint detector. All detectors inherit the abstract ``FeatureDetector`` interface, but the constructors are algorithm-dependent. The first argument to each detector usually controls the balance between the amount of keypoints and their stability. The range of values is different for different detectors (For instance, *FAST* threshold has the meaning of pixel intensity difference and usually varies in the region *[0,40]*. *SURF* threshold is applied to a Hessian of an image and usually takes on values larger than *100*), so use defaults in case of doubt. :: // computing descriptors - SurfDescriptorExtractor extractor; + Ptr extractor = SURF::create(); Mat descriptors1, descriptors2; - extractor.compute(img1, keypoints1, descriptors1); - extractor.compute(img2, keypoints2, descriptors2); + extractor->compute(img1, keypoints1, descriptors1); + extractor->compute(img2, keypoints2, descriptors2); We create an instance of descriptor extractor. The most of OpenCV descriptors inherit ``DescriptorExtractor`` abstract interface. Then we compute descriptors for each of the keypoints. The output ``Mat`` of the ``DescriptorExtractor::compute`` method contains a descriptor in a row *i* for each *i*-th keypoint. Note that the method can modify the keypoints vector by removing the keypoints such that a descriptor for them is not defined (usually these are the keypoints near image border). The method makes sure that the ouptut keypoints and descriptors are consistent with each other (so that the number of keypoints is equal to the descriptors row count). :: diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 3250358bdae5aef3cf1b0070cf652ab7126b804c..62d7ccec684c07edfc2c2b698984c31ca87f3866 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -185,7 +185,7 @@ CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSiz //! finds circles' grid pattern of the specified size in the image CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID, - const Ptr &blobDetector = makePtr()); + const Ptr &blobDetector = SimpleBlobDetector::create()); //! finds intrinsic and extrinsic camera parameters from several fews of a known calibration pattern. CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints, diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index 6b03b0023bd85d55f8f1963eab0dcc4c017a5b70..bf8464877e8f685b80b9b25880760ba8231ee8ba 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -115,7 +115,10 @@ bool cv::solvePnP( InputArray _opoints, InputArray _ipoints, cv::Mat R, rvec = _rvec.getMat(), tvec = _tvec.getMat(); double f = PnP.compute_pose(R, tvec); cv::Rodrigues(R, rvec); - cameraMatrix.at(0,0) = cameraMatrix.at(1,1) = f; + if(cameraMatrix.type() == CV_32F) + cameraMatrix.at(0,0) = cameraMatrix.at(1,1) = f; + else + cameraMatrix.at(0,0) = cameraMatrix.at(1,1) = f; return true; } else diff --git a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst index f4e4244457b4a42efcf17770bd67b4b20f10ef53..5ebbe813443990ab4f83392fddf1041d66802eb6 100644 --- a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst +++ b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst @@ -59,100 +59,60 @@ Detects keypoints in an image (first variant) or image set (second variant). :param masks: Masks for each input image specifying where to look for keypoints (optional). ``masks[i]`` is a mask for ``images[i]``. -FeatureDetector::create ------------------------ -Creates a feature detector by its name. - -.. ocv:function:: Ptr FeatureDetector::create( const String& detectorType ) - -.. ocv:pyfunction:: cv2.FeatureDetector_create(detectorType) -> retval - - :param detectorType: Feature detector type. - -The following detector types are supported: - -* ``"FAST"`` -- :ocv:class:`FastFeatureDetector` -* ``"ORB"`` -- :ocv:class:`ORB` -* ``"BRISK"`` -- :ocv:class:`BRISK` -* ``"MSER"`` -- :ocv:class:`MSER` -* ``"GFTT"`` -- :ocv:class:`GoodFeaturesToTrackDetector` -* ``"HARRIS"`` -- :ocv:class:`GoodFeaturesToTrackDetector` with Harris detector enabled -* ``"SimpleBlob"`` -- :ocv:class:`SimpleBlobDetector` - FastFeatureDetector ------------------- -.. ocv:class:: FastFeatureDetector : public FeatureDetector +.. ocv:class:: FastFeatureDetector : public Feature2D Wrapping class for feature detection using the :ocv:func:`FAST` method. :: - class FastFeatureDetector : public FeatureDetector + class FastFeatureDetector : public Feature2D { public: - FastFeatureDetector( int threshold=1, bool nonmaxSuppression=true, type=FastFeatureDetector::TYPE_9_16 ); - virtual void read( const FileNode& fn ); - virtual void write( FileStorage& fs ) const; - protected: - ... + static Ptr create( int threshold=1, bool nonmaxSuppression=true, type=FastFeatureDetector::TYPE_9_16 ); }; -GoodFeaturesToTrackDetector +GFTTDetector --------------------------- -.. ocv:class:: GoodFeaturesToTrackDetector : public FeatureDetector +.. ocv:class:: GFTTDetector : public FeatureDetector Wrapping class for feature detection using the :ocv:func:`goodFeaturesToTrack` function. :: - class GoodFeaturesToTrackDetector : public FeatureDetector + class GFTTDetector : public Feature2D { public: - class Params - { - public: - Params( int maxCorners=1000, double qualityLevel=0.01, - double minDistance=1., int blockSize=3, - bool useHarrisDetector=false, double k=0.04 ); - void read( const FileNode& fn ); - void write( FileStorage& fs ) const; - - int maxCorners; - double qualityLevel; - double minDistance; - int blockSize; - bool useHarrisDetector; - double k; - }; - - GoodFeaturesToTrackDetector( const GoodFeaturesToTrackDetector::Params& params= - GoodFeaturesToTrackDetector::Params() ); - GoodFeaturesToTrackDetector( int maxCorners, double qualityLevel, - double minDistance, int blockSize=3, - bool useHarrisDetector=false, double k=0.04 ); - virtual void read( const FileNode& fn ); - virtual void write( FileStorage& fs ) const; - protected: - ... + enum { USE_HARRIS_DETECTOR=10000 }; + static Ptr create( int maxCorners=1000, double qualityLevel=0.01, + double minDistance=1, int blockSize=3, + bool useHarrisDetector=false, double k=0.04 ); }; -MserFeatureDetector +MSER ------------------- -.. ocv:class:: MserFeatureDetector : public FeatureDetector +.. ocv:class:: MSER : public Feature2D -Wrapping class for feature detection using the -:ocv:class:`MSER` class. :: +Maximally stable region detector :: - class MserFeatureDetector : public FeatureDetector + class MSER : public Feature2D { public: - MserFeatureDetector( CvMSERParams params=cvMSERParams() ); - MserFeatureDetector( int delta, int minArea, int maxArea, - double maxVariation, double minDiversity, - int maxEvolution, double areaThreshold, - double minMargin, int edgeBlurSize ); - virtual void read( const FileNode& fn ); - virtual void write( FileStorage& fs ) const; - protected: - ... + enum + { + DELTA=10000, MIN_AREA=10001, MAX_AREA=10002, PASS2_ONLY=10003, + MAX_EVOLUTION=10004, AREA_THRESHOLD=10005, + MIN_MARGIN=10006, EDGE_BLUR_SIZE=10007 + }; + + //! the full constructor + static Ptr create( int _delta=5, int _min_area=60, int _max_area=14400, + double _max_variation=0.25, double _min_diversity=.2, + int _max_evolution=200, double _area_threshold=1.01, + double _min_margin=0.003, int _edge_blur_size=5 ); + + virtual void detectRegions( InputArray image, + std::vector >& msers, + std::vector& bboxes ) = 0; }; SimpleBlobDetector @@ -189,10 +149,8 @@ Class for extracting blobs from an image. :: float minConvexity, maxConvexity; }; - SimpleBlobDetector(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params()); - - protected: - ... + static Ptr create(const SimpleBlobDetector::Params + ¶meters = SimpleBlobDetector::Params()); }; The class implements a simple algorithm for extracting blobs from an image: diff --git a/modules/features2d/doc/feature_detection_and_description.rst b/modules/features2d/doc/feature_detection_and_description.rst index de024a41c74852da7a581530e1621dc07d918677..20e2df8fa3b0aeaccf3dc6a749e5e941ef11f4d4 100644 --- a/modules/features2d/doc/feature_detection_and_description.rst +++ b/modules/features2d/doc/feature_detection_and_description.rst @@ -14,11 +14,6 @@ Detects corners using the FAST algorithm .. ocv:function:: void FAST( InputArray image, vector& keypoints, int threshold, bool nonmaxSuppression=true ) .. ocv:function:: void FAST( InputArray image, vector& keypoints, int threshold, bool nonmaxSuppression, int type ) -.. ocv:pyfunction:: cv2.FastFeatureDetector([, threshold[, nonmaxSuppression]]) -> -.. ocv:pyfunction:: cv2.FastFeatureDetector(threshold, nonmaxSuppression, type) -> -.. ocv:pyfunction:: cv2.FastFeatureDetector.detect(image[, mask]) -> keypoints - - :param image: grayscale image where keypoints (corners) are detected. :param keypoints: keypoints detected on the image. @@ -55,7 +50,7 @@ Maximally stable extremal region extractor. :: // runs the extractor on the specified image; returns the MSERs, // each encoded as a contour (vector, see findContours) // the optional mask marks the area where MSERs are searched for - void operator()( const Mat& image, vector >& msers, const Mat& mask ) const; + void detectRegions( InputArray image, vector >& msers, vector& bboxes ) const; }; The class encapsulates all the parameters of the MSER extraction algorithm (see diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index a42d454c400e82b061d1097dc834f5f01137bee3..193d5b93eb80b91434a2f45cb3a10ea0025ca778 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -164,7 +164,13 @@ class CV_EXPORTS_W ORB : public Feature2D { public: // the size of the signature in bytes - enum { kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1 }; + enum + { + kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1, + NFEATURES=10000, SCALE_FACTOR=10001, NLEVELS=10002, + EDGE_THRESHOLD=10003, FIRST_LEVEL=10004, WTA_K=10005, + SCORE_TYPE=10006, PATCH_SIZE=10007, FAST_THRESHOLD=10008 + }; CV_WRAP static Ptr create(int nfeatures = 500, float scaleFactor = 1.2f, int nlevels = 8, int edgeThreshold = 31, int firstLevel = 0, int WTA_K=2, int scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold = 20); diff --git a/modules/features2d/src/gftt.cpp b/modules/features2d/src/gftt.cpp index 899e2f274a31db948c555e9275a184739666c354..9cfc77d83efbaeff28b0778dc1ad7ba2ca646dd7 100644 --- a/modules/features2d/src/gftt.cpp +++ b/modules/features2d/src/gftt.cpp @@ -55,6 +55,24 @@ public: { } + void set(int prop, double value) + { + if( prop == USE_HARRIS_DETECTOR ) + useHarrisDetector = value != 0; + else + CV_Error(Error::StsBadArg, ""); + } + + double get(int prop) const + { + double value = 0; + if( prop == USE_HARRIS_DETECTOR ) + value = useHarrisDetector; + else + CV_Error(Error::StsBadArg, ""); + return value; + } + void detect( InputArray _image, std::vector& keypoints, InputArray _mask ) { std::vector corners; diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index d7b8fce40eb3aac8d8bd0b4c81e40346095556b7..97d29e29c54d410e345d6304f1519040b8bb4145 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -100,12 +100,12 @@ ocl_ICAngles(const UMat& imgbuf, const UMat& layerinfo, static bool ocl_computeOrbDescriptors(const UMat& imgbuf, const UMat& layerInfo, const UMat& keypoints, UMat& desc, const UMat& pattern, - int nkeypoints, int dsize, int WTA_K) + int nkeypoints, int dsize, int wta_k) { size_t globalSize[] = {nkeypoints}; ocl::Kernel desc_ker("ORB_computeDescriptor", ocl::features2d::orb_oclsrc, - format("-D ORB_DESCRIPTORS -D WTA_K=%d", WTA_K)); + format("-D ORB_DESCRIPTORS -D wta_k=%d", wta_k)); if( desc_ker.empty() ) return false; @@ -209,7 +209,7 @@ static void ICAngles(const Mat& img, const std::vector& layerinfo, static void computeOrbDescriptors( const Mat& imagePyramid, const std::vector& layerInfo, const std::vector& layerScale, std::vector& keypoints, - Mat& descriptors, const std::vector& _pattern, int dsize, int WTA_K ) + Mat& descriptors, const std::vector& _pattern, int dsize, int wta_k ) { int step = (int)imagePyramid.step; int j, i, nkeypoints = (int)keypoints.size(); @@ -248,7 +248,7 @@ computeOrbDescriptors( const Mat& imagePyramid, const std::vector& layerIn center[iy*step + ix+1]*x*(1-y) + center[(iy+1)*step + ix+1]*x*y)) #endif - if( WTA_K == 2 ) + if( wta_k == 2 ) { for (i = 0; i < dsize; ++i, pattern += 16) { @@ -273,7 +273,7 @@ computeOrbDescriptors( const Mat& imagePyramid, const std::vector& layerIn desc[i] = (uchar)val; } } - else if( WTA_K == 3 ) + else if( wta_k == 3 ) { for (i = 0; i < dsize; ++i, pattern += 12) { @@ -293,7 +293,7 @@ computeOrbDescriptors( const Mat& imagePyramid, const std::vector& layerIn desc[i] = (uchar)val; } } - else if( WTA_K == 4 ) + else if( wta_k == 4 ) { for (i = 0; i < dsize; ++i, pattern += 16) { @@ -334,7 +334,7 @@ computeOrbDescriptors( const Mat& imagePyramid, const std::vector& layerIn } } else - CV_Error( Error::StsBadSize, "Wrong WTA_K. It can be only 2, 3 or 4." ); + CV_Error( Error::StsBadSize, "Wrong wta_k. It can be only 2, 3 or 4." ); #undef GET_VALUE } } @@ -652,10 +652,60 @@ public: explicit ORB_Impl(int _nfeatures, float _scaleFactor, int _nlevels, int _edgeThreshold, int _firstLevel, int _WTA_K, int _scoreType, int _patchSize, int _fastThreshold) : nfeatures(_nfeatures), scaleFactor(_scaleFactor), nlevels(_nlevels), - edgeThreshold(_edgeThreshold), firstLevel(_firstLevel), WTA_K(_WTA_K), + edgeThreshold(_edgeThreshold), firstLevel(_firstLevel), wta_k(_WTA_K), scoreType(_scoreType), patchSize(_patchSize), fastThreshold(_fastThreshold) {} + void set(int prop, double value) + { + if( prop == NFEATURES ) + nfeatures = cvRound(value); + else if( prop == SCALE_FACTOR ) + scaleFactor = value; + else if( prop == NLEVELS ) + nlevels = cvRound(value); + else if( prop == EDGE_THRESHOLD ) + edgeThreshold = cvRound(value); + else if( prop == FIRST_LEVEL ) + firstLevel = cvRound(value); + else if( prop == WTA_K ) + wta_k = cvRound(value); + else if( prop == SCORE_TYPE ) + scoreType = cvRound(value); + else if( prop == PATCH_SIZE ) + patchSize = cvRound(value); + else if( prop == FAST_THRESHOLD ) + fastThreshold = cvRound(value); + else + CV_Error(Error::StsBadArg, ""); + } + + double get(int prop) const + { + double value = 0; + if( prop == NFEATURES ) + value = nfeatures; + else if( prop == SCALE_FACTOR ) + value = scaleFactor; + else if( prop == NLEVELS ) + value = nlevels; + else if( prop == EDGE_THRESHOLD ) + value = edgeThreshold; + else if( prop == FIRST_LEVEL ) + value = firstLevel; + else if( prop == WTA_K ) + value = wta_k; + else if( prop == SCORE_TYPE ) + value = scoreType; + else if( prop == PATCH_SIZE ) + value = patchSize; + else if( prop == FAST_THRESHOLD ) + value = fastThreshold; + else + CV_Error(Error::StsBadArg, ""); + return value; + } + // returns the descriptor size in bytes int descriptorSize() const; // returns the descriptor type @@ -674,7 +724,7 @@ protected: int nlevels; int edgeThreshold; int firstLevel; - int WTA_K; + int wta_k; int scoreType; int patchSize; int fastThreshold; @@ -1095,14 +1145,14 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask, makeRandomPattern(patchSize, patternbuf, npoints); } - CV_Assert( WTA_K == 2 || WTA_K == 3 || WTA_K == 4 ); + CV_Assert( wta_k == 2 || wta_k == 3 || wta_k == 4 ); - if( WTA_K == 2 ) + if( wta_k == 2 ) std::copy(pattern0, pattern0 + npoints, std::back_inserter(pattern)); else { int ntuples = descriptorSize()*4; - initializeOrbPattern(pattern0, pattern, ntuples, WTA_K, npoints); + initializeOrbPattern(pattern0, pattern, ntuples, wta_k, npoints); } for( level = 0; level < nLevels; level++ ) @@ -1125,23 +1175,23 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask, UMat udescriptors = _descriptors.getUMat(); useOCL = ocl_computeOrbDescriptors(uimagePyramid, ulayerInfo, ukeypoints, udescriptors, upattern, - nkeypoints, dsize, WTA_K); + nkeypoints, dsize, wta_k); } if( !useOCL ) { Mat descriptors = _descriptors.getMat(); computeOrbDescriptors(imagePyramid, layerInfo, layerScale, - keypoints, descriptors, pattern, dsize, WTA_K); + keypoints, descriptors, pattern, dsize, wta_k); } } } Ptr ORB::create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, - int firstLevel, int WTA_K, int scoreType, int patchSize, int fastThreshold) + int firstLevel, int wta_k, int scoreType, int patchSize, int fastThreshold) { return makePtr(nfeatures, scaleFactor, nlevels, edgeThreshold, - firstLevel, WTA_K, scoreType, patchSize, fastThreshold); + firstLevel, wta_k, scoreType, patchSize, fastThreshold); } } diff --git a/modules/features2d/test/test_detectors_regression.cpp b/modules/features2d/test/test_detectors_regression.cpp index a3ca0a9f389f9455032f8466598562646cc924a6..d06418cfe044d0cd6b1e40a9085daef9228dada5 100644 --- a/modules/features2d/test/test_detectors_regression.cpp +++ b/modules/features2d/test/test_detectors_regression.cpp @@ -267,7 +267,9 @@ TEST( Features2d_Detector_GFTT, regression ) TEST( Features2d_Detector_Harris, regression ) { - CV_FeatureDetectorTest test( "detector-harris", GFTTDetector::create(1000, 0.01, 1, 3, true, 0.04)); + Ptr gftt = GFTTDetector::create(); + gftt->set(GFTTDetector::USE_HARRIS_DETECTOR, 1); + CV_FeatureDetectorTest test( "detector-harris", gftt); test.safe_run(); } diff --git a/modules/features2d/test/test_keypoints.cpp b/modules/features2d/test/test_keypoints.cpp index 46fd3957848732db188c7e9e70ec2a14091984c3..7ede4540383296c31c783da72a99fe43a69e0178 100644 --- a/modules/features2d/test/test_keypoints.cpp +++ b/modules/features2d/test/test_keypoints.cpp @@ -133,13 +133,16 @@ TEST(Features2d_Detector_Keypoints_FAST, validation) TEST(Features2d_Detector_Keypoints_HARRIS, validation) { + CV_FeatureDetectorKeypointsTest test(GFTTDetector::create(1000, 0.01, 1, 3, true, 0.04)); test.safe_run(); } TEST(Features2d_Detector_Keypoints_GFTT, validation) { - CV_FeatureDetectorKeypointsTest test(GFTTDetector::create()); + Ptr gftt = GFTTDetector::create(); + gftt->set(GFTTDetector::USE_HARRIS_DETECTOR, 1); + CV_FeatureDetectorKeypointsTest test(gftt); test.safe_run(); } diff --git a/modules/java/generator/src/cpp/features2d_manual.hpp b/modules/java/generator/src/cpp/features2d_manual.hpp index 81668f3ff629243a1463f841295334b4007037a4..346180fe295bacec29496523a6b6dce728a233e4 100644 --- a/modules/java/generator/src/cpp/features2d_manual.hpp +++ b/modules/java/generator/src/cpp/features2d_manual.hpp @@ -133,6 +133,7 @@ public: break; case HARRIS: fd = GFTTDetector::create(); + fd->set(GFTTDetector::USE_HARRIS_DETECTOR, 1); break; case SIMPLEBLOB: fd = SimpleBlobDetector::create(); diff --git a/modules/python/test/test.py b/modules/python/test/test.py index 76f64fc52e517063ca96b56a5f27ed59ea31eebe..e4edc88b5a0b505994b4dc6bb0679df6b1856b56 100644 --- a/modules/python/test/test.py +++ b/modules/python/test/test.py @@ -91,7 +91,7 @@ class Hackathon244Tests(NewOpenCVTests): self.assertEqual(cv2.countNonZero(inliers), pattern_size[0]*pattern_size[1]) def test_fast(self): - fd = cv2.FastFeatureDetector(30, True) + fd = cv2.FastFeatureDetector_create(30, True) img = self.get_sample("samples/cpp/right02.jpg", 0) img = cv2.medianBlur(img, 3) imgc = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index ad3f6320fb78aeca77724162071fbb8a1563d316..0d6edb679102516b23e67238f7c3e6ecfbd3d38e 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -50,6 +50,8 @@ using namespace cv::cuda; #include "opencv2/xfeatures2d.hpp" #endif +using xfeatures2d::SURF; + namespace { struct DistIdxPair @@ -321,27 +323,27 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int { if (num_octaves_descr == num_octaves && num_layers_descr == num_layers) { - surf = xfeatures2d::SURF::create(); + surf = SURF::create(); if( !surf ) CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" ); - surf->set("hessianThreshold", hess_thresh); - surf->set("nOctaves", num_octaves); - surf->set("nOctaveLayers", num_layers); + surf->set(SURF::HESSIAN_THRESHOLD, hess_thresh); + surf->set(SURF::NOCTAVES, num_octaves); + surf->set(SURF::NOCTAVE_LAYERS, num_layers); } else { - detector_ = xfeatures2d::SURF::create(); - extractor_ = xfeatures2d::SURF::create(); + detector_ = SURF::create(); + extractor_ = SURF::create(); if( !detector_ || !extractor_ ) CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" ); - detector_->set("hessianThreshold", hess_thresh); - detector_->set("nOctaves", num_octaves); - detector_->set("nOctaveLayers", num_layers); + detector_->set(SURF::HESSIAN_THRESHOLD, hess_thresh); + detector_->set(SURF::NOCTAVES, num_octaves); + detector_->set(SURF::NOCTAVE_LAYERS, num_layers); - extractor_->set("nOctaves", num_octaves_descr); - extractor_->set("nOctaveLayers", num_layers_descr); + extractor_->set(SURF::NOCTAVES, num_octaves_descr); + extractor_->set(SURF::NOCTAVE_LAYERS, num_layers_descr); } } diff --git a/samples/android/tutorial-2-mixedprocessing/jni/jni_part.cpp b/samples/android/tutorial-2-mixedprocessing/jni/jni_part.cpp index f8e3ada726fbf7c3114b38a02e0e233dccb23084..2c099615636fbd1712bb19200aa20d84a69f75b4 100644 --- a/samples/android/tutorial-2-mixedprocessing/jni/jni_part.cpp +++ b/samples/android/tutorial-2-mixedprocessing/jni/jni_part.cpp @@ -16,8 +16,8 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial2_Tutorial2Activity_FindF Mat& mRgb = *(Mat*)addrRgba; vector v; - FastFeatureDetector detector(50); - detector.detect(mGr, v); + Ptr detector = FastFeatureDetector::create(50); + detector->detect(mGr, v); for( unsigned int i = 0; i < v.size(); i++ ) { const KeyPoint& kp = v[i]; diff --git a/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp b/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp index 4de13401d5554651115fd37380a866d8611f6857..6d5ac04bdab6b73cab00dabc69ecccf9f2b56d3a 100644 --- a/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp +++ b/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp @@ -129,12 +129,12 @@ cv::Mat OcvImageProcessing::MainPage::ApplyFindFeaturesFilter(const cv::Mat& ima { cv::Mat result; cv::Mat intermediateMat; - cv::FastFeatureDetector detector(50); + cv::Ptr detector = cv::FastFeatureDetector::create(50); std::vector features; image.copyTo(result); cv::cvtColor(image, intermediateMat, CV_RGBA2GRAY); - detector.detect(intermediateMat, features); + detector->detect(intermediateMat, features); for( unsigned int i = 0; i < std::min(features.size(), (size_t)50); i++ ) {