1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge remote-tracking branch 'upstream/master' into bow_desc

Conflicts:
	modules/features2d/src/bagofwords.cpp
This commit is contained in:
Mathieu Barnachon
2013-11-24 14:21:44 +01:00
2649 changed files with 192492 additions and 87401 deletions
-1
View File
@@ -1,3 +1,2 @@
set(the_description "2D Features Framework")
ocv_define_module(features2d opencv_imgproc opencv_flann OPTIONAL opencv_highgui)
@@ -9,7 +9,10 @@ represented as vectors in a multidimensional space. All objects that implement t
descriptor extractors inherit the
:ocv:class:`DescriptorExtractor` interface.
.. note::
* An example explaining keypoint extraction can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp
* An example on descriptor evaluation can be found at opencv_source_code/samples/cpp/detector_descriptor_evaluation.cpp
DescriptorExtractor
-------------------
@@ -82,9 +85,10 @@ The current implementation supports the following types of a descriptor extracto
* ``"SIFT"`` -- :ocv:class:`SIFT`
* ``"SURF"`` -- :ocv:class:`SURF`
* ``"ORB"`` -- :ocv:class:`ORB`
* ``"BRISK"`` -- :ocv:class:`BRISK`
* ``"BRIEF"`` -- :ocv:class:`BriefDescriptorExtractor`
* ``"BRISK"`` -- :ocv:class:`BRISK`
* ``"ORB"`` -- :ocv:class:`ORB`
* ``"FREAK"`` -- :ocv:class:`FREAK`
A combined format is also supported: descriptor extractor adapter name ( ``"Opponent"`` --
:ocv:class:`OpponentColorDescriptorExtractor` ) + descriptor extractor name (see above),
@@ -141,4 +145,6 @@ Strecha C., Fua P. *BRIEF: Binary Robust Independent Elementary Features* ,
...
};
.. note::
* A complete BRIEF extractor sample can be found at opencv_source_code/samples/cpp/brief_match_test.cpp
@@ -9,6 +9,11 @@ that are represented as vectors in a multidimensional space. All objects that im
descriptor matchers inherit the
:ocv:class:`DescriptorMatcher` interface.
.. note::
* An example explaining keypoint matching can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp
* An example on descriptor matching evaluation can be found at opencv_source_code/samples/cpp/detector_descriptor_matcher_evaluation.cpp
* An example on one to many image matching can be found at opencv_source_code/samples/cpp/matching_to_many_images.cpp
DescriptorMatcher
-----------------
@@ -271,4 +276,3 @@ Flann-based descriptor matcher. This matcher trains :ocv:class:`flann::Index_` o
};
..
@@ -8,6 +8,9 @@ between different algorithms solving the same problem. All objects that implemen
inherit the
:ocv:class:`FeatureDetector` interface.
.. note::
* An example explaining keypoint detection can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp
FeatureDetector
---------------
@@ -166,7 +169,7 @@ StarFeatureDetector
-------------------
.. ocv:class:: StarFeatureDetector : public FeatureDetector
The class implements the keypoint detector introduced by K. Konolige, synonym of ``StarDetector``. ::
The class implements the keypoint detector introduced by [Agrawal08]_, synonym of ``StarDetector``. ::
class StarFeatureDetector : public FeatureDetector
{
@@ -180,6 +183,9 @@ The class implements the keypoint detector introduced by K. Konolige, synonym of
...
};
.. [Agrawal08] Agrawal, M., Konolige, K., & Blas, M. R. (2008). Censure: Center surround extremas for realtime feature detection and matching. In Computer VisionECCV 2008 (pp. 102-115). Springer Berlin Heidelberg.
DenseFeatureDetector
--------------------
.. ocv:class:: DenseFeatureDetector : public FeatureDetector
@@ -11,7 +11,11 @@ Every descriptor with the
:ocv:class:`VectorDescriptorMatcher` ).
There are descriptors such as the One-way descriptor and Ferns that have the ``GenericDescriptorMatcher`` interface implemented but do not support ``DescriptorExtractor``.
.. note::
* An example explaining keypoint description can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp
* An example on descriptor matching evaluation can be found at opencv_source_code/samples/cpp/detector_descriptor_matcher_evaluation.cpp
* An example on one to many image matching can be found at opencv_source_code/samples/cpp/matching_to_many_images.cpp
GenericDescriptorMatcher
------------------------
@@ -270,5 +274,3 @@ Example: ::
VectorDescriptorMatcher matcher( new SurfDescriptorExtractor,
new BruteForceMatcher<L2<float> > );
@@ -83,4 +83,4 @@ Draws keypoints.
:param flags: Flags setting drawing features. Possible ``flags`` bit values are defined by ``DrawMatchesFlags``. See details above in :ocv:func:`drawMatches` .
.. note:: For Python API, flags are modified as `cv2.DRAW_MATCHES_FLAGS_DEFAULT`, `cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS`, `cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG`, `cv2.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS`
.. note:: For Python API, flags are modified as `cv2.DRAW_MATCHES_FLAGS_DEFAULT`, `cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS`, `cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG`, `cv2.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS`
@@ -3,6 +3,10 @@ Feature Detection and Description
.. highlight:: cpp
.. note::
* An example explaining keypoint detection and description can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp
FAST
----
Detects corners using the FAST algorithm
@@ -58,6 +62,10 @@ Maximally stable extremal region extractor. ::
The class encapsulates all the parameters of the MSER extraction algorithm (see
http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions). Also see http://code.opencv.org/projects/opencv/wiki/MSER for useful comments and parameters description.
.. note::
* (Python) A complete example showing the use of the MSER detector can be found at opencv_source_code/samples/python2/mser.py
ORB
---
@@ -112,7 +120,7 @@ Finds keypoints in an image and computes their descriptors
:param descriptors: The output descriptors. Pass ``cv::noArray()`` if you do not need it.
:param useProvidedKeypoints: If it is true, then the method will use the provided vector of keypoints instead of detecting them.
BRISK
-----
@@ -182,6 +190,10 @@ Class implementing the FREAK (*Fast Retina Keypoint*) keypoint descriptor, descr
.. [AOV12] A. Alahi, R. Ortiz, and P. Vandergheynst. FREAK: Fast Retina Keypoint. In IEEE Conference on Computer Vision and Pattern Recognition, 2012. CVPR 2012 Open Source Award Winner.
.. note::
* An example on how to use the FREAK descriptor can be found at opencv_source_code/samples/cpp/freak_demo.cpp
FREAK::FREAK
------------
The FREAK constructor
@@ -5,6 +5,12 @@ Object Categorization
This section describes approaches based on local 2D features and used to categorize objects.
.. note::
* A complete Bag-Of-Words sample can be found at opencv_source_code/samples/cpp/bagofwords_classification.cpp
* (Python) An example using the features2D framework to perform object categorization can be found at opencv_source_code/samples/python2/find_obj.py
BOWTrainer
----------
.. ocv:class:: BOWTrainer
@@ -205,4 +211,3 @@ BOWImgDescriptorExtractor::descriptorType
Returns an image descriptor type.
.. ocv:function:: int BOWImgDescriptorExtractor::descriptorType() const
@@ -517,7 +517,7 @@ CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector
{
public:
enum
enum Type
{
TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2
};
@@ -646,7 +646,7 @@ public:
* gridRows Grid rows count.
* gridCols Grid column count.
*/
CV_WRAP GridAdaptedFeatureDetector( const Ptr<FeatureDetector>& detector=0,
CV_WRAP GridAdaptedFeatureDetector( const Ptr<FeatureDetector>& detector=Ptr<FeatureDetector>(),
int maxTotalKeypoints=1000,
int gridRows=4, int gridCols=4 );
@@ -961,7 +961,7 @@ struct CV_EXPORTS Hamming
typedef Hamming HammingLUT;
template<int cellsize> struct CV_EXPORTS HammingMultilevel
template<int cellsize> struct HammingMultilevel
{
enum { normType = NORM_HAMMING + (cellsize>1) };
typedef unsigned char ValueType;
@@ -1143,8 +1143,8 @@ protected:
class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher
{
public:
CV_WRAP FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=new flann::KDTreeIndexParams(),
const Ptr<flann::SearchParams>& searchParams=new flann::SearchParams() );
CV_WRAP FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=makePtr<flann::KDTreeIndexParams>(),
const Ptr<flann::SearchParams>& searchParams=makePtr<flann::SearchParams>() );
virtual void add( const std::vector<Mat>& descriptors );
virtual void clear();
@@ -45,4 +45,4 @@
#error this is a compatibility header which should not be used inside the OpenCV library
#endif
#include "opencv2/features2d.hpp"
#include "opencv2/features2d.hpp"
-1
View File
@@ -41,4 +41,3 @@ PERF_TEST_P(fast, detect, testing::Combine(
SANITY_CHECK_KEYPOINTS(points);
}
-1
View File
@@ -1 +0,0 @@
#include "perf_precomp.hpp"
+10
View File
@@ -204,4 +204,14 @@ void BOWImgDescriptorExtractor::compute( const Mat& descriptors, Mat& imgDescrip
imgDescriptor /= descriptors.rows;
}
int BOWImgDescriptorExtractor::descriptorSize() const
{
return vocabulary.empty() ? 0 : vocabulary.rows;
}
int BOWImgDescriptorExtractor::descriptorType() const
{
return CV_32FC1;
}
}
+2 -2
View File
@@ -2003,7 +2003,7 @@ BriskLayer::BriskLayer(const cv::Mat& img_in, float scale_in, float offset_in)
scale_ = scale_in;
offset_ = offset_in;
// create an agast detector
fast_9_16_ = new FastFeatureDetector(1, true, FastFeatureDetector::TYPE_9_16);
fast_9_16_ = makePtr<FastFeatureDetector>(1, true, FastFeatureDetector::TYPE_9_16);
makeOffsets(pixel_5_8_, (int)img_.step, 8);
makeOffsets(pixel_9_16_, (int)img_.step, 16);
}
@@ -2025,7 +2025,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode)
offset_ = 0.5f * scale_ - 0.5f;
}
scores_ = cv::Mat::zeros(img_.rows, img_.cols, CV_8U);
fast_9_16_ = new FastFeatureDetector(1, false, FastFeatureDetector::TYPE_9_16);
fast_9_16_ = makePtr<FastFeatureDetector>(1, false, FastFeatureDetector::TYPE_9_16);
makeOffsets(pixel_5_8_, (int)img_.step, 8);
makeOffsets(pixel_9_16_, (int)img_.step, 16);
}
+3 -3
View File
@@ -99,7 +99,7 @@ Ptr<DescriptorExtractor> DescriptorExtractor::create(const String& descriptorExt
{
size_t pos = String("Opponent").size();
String type = descriptorExtractorType.substr(pos);
return new OpponentColorDescriptorExtractor(DescriptorExtractor::create(type));
return makePtr<OpponentColorDescriptorExtractor>(DescriptorExtractor::create(type));
}
return Algorithm::create<DescriptorExtractor>("Feature2D." + descriptorExtractorType);
@@ -119,7 +119,7 @@ CV_WRAP void Feature2D::compute( const Mat& image, CV_OUT CV_IN_OUT std::vector<
OpponentColorDescriptorExtractor::OpponentColorDescriptorExtractor( const Ptr<DescriptorExtractor>& _descriptorExtractor ) :
descriptorExtractor(_descriptorExtractor)
{
CV_Assert( !descriptorExtractor.empty() );
CV_Assert( descriptorExtractor );
}
static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, std::vector<Mat>& opponentChannels )
@@ -249,7 +249,7 @@ int OpponentColorDescriptorExtractor::descriptorType() const
bool OpponentColorDescriptorExtractor::empty() const
{
return descriptorExtractor.empty() || (DescriptorExtractor*)(descriptorExtractor)->empty();
return !descriptorExtractor || descriptorExtractor->empty();
}
}
+5 -5
View File
@@ -90,19 +90,19 @@ Ptr<FeatureDetector> FeatureDetector::create( const String& detectorType )
{
if( detectorType.find("Grid") == 0 )
{
return new GridAdaptedFeatureDetector(FeatureDetector::create(
return makePtr<GridAdaptedFeatureDetector>(FeatureDetector::create(
detectorType.substr(strlen("Grid"))));
}
if( detectorType.find("Pyramid") == 0 )
{
return new PyramidAdaptedFeatureDetector(FeatureDetector::create(
return makePtr<PyramidAdaptedFeatureDetector>(FeatureDetector::create(
detectorType.substr(strlen("Pyramid"))));
}
if( detectorType.find("Dynamic") == 0 )
{
return new DynamicAdaptedFeatureDetector(AdjusterAdapter::create(
return makePtr<DynamicAdaptedFeatureDetector>(AdjusterAdapter::create(
detectorType.substr(strlen("Dynamic"))));
}
@@ -190,7 +190,7 @@ GridAdaptedFeatureDetector::GridAdaptedFeatureDetector( const Ptr<FeatureDetecto
bool GridAdaptedFeatureDetector::empty() const
{
return detector.empty() || (FeatureDetector*)detector->empty();
return !detector || detector->empty();
}
struct ResponseComparator
@@ -295,7 +295,7 @@ PyramidAdaptedFeatureDetector::PyramidAdaptedFeatureDetector( const Ptr<FeatureD
bool PyramidAdaptedFeatureDetector::empty() const
{
return detector.empty() || (FeatureDetector*)detector->empty();
return !detector || detector->empty();
}
void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
+7 -7
View File
@@ -51,7 +51,7 @@ DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector(const Ptr<AdjusterA
bool DynamicAdaptedFeatureDetector::empty() const
{
return adjuster_.empty() || adjuster_->empty();
return !adjuster_ || adjuster_->empty();
}
void DynamicAdaptedFeatureDetector::detectImpl(const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
@@ -124,7 +124,7 @@ bool FastAdjuster::good() const
Ptr<AdjusterAdapter> FastAdjuster::clone() const
{
Ptr<AdjusterAdapter> cloned_obj = new FastAdjuster( init_thresh_, nonmax_, min_thresh_, max_thresh_ );
Ptr<AdjusterAdapter> cloned_obj(new FastAdjuster( init_thresh_, nonmax_, min_thresh_, max_thresh_ ));
return cloned_obj;
}
@@ -158,7 +158,7 @@ bool StarAdjuster::good() const
Ptr<AdjusterAdapter> StarAdjuster::clone() const
{
Ptr<AdjusterAdapter> cloned_obj = new StarAdjuster( init_thresh_, min_thresh_, max_thresh_ );
Ptr<AdjusterAdapter> cloned_obj(new StarAdjuster( init_thresh_, min_thresh_, max_thresh_ ));
return cloned_obj;
}
@@ -195,7 +195,7 @@ bool SurfAdjuster::good() const
Ptr<AdjusterAdapter> SurfAdjuster::clone() const
{
Ptr<AdjusterAdapter> cloned_obj = new SurfAdjuster( init_thresh_, min_thresh_, max_thresh_ );
Ptr<AdjusterAdapter> cloned_obj(new SurfAdjuster( init_thresh_, min_thresh_, max_thresh_ ));
return cloned_obj;
}
@@ -205,15 +205,15 @@ Ptr<AdjusterAdapter> AdjusterAdapter::create( const String& detectorType )
if( !detectorType.compare( "FAST" ) )
{
adapter = new FastAdjuster();
adapter = makePtr<FastAdjuster>();
}
else if( !detectorType.compare( "STAR" ) )
{
adapter = new StarAdjuster();
adapter = makePtr<StarAdjuster>();
}
else if( !detectorType.compare( "SURF" ) )
{
adapter = new SurfAdjuster();
adapter = makePtr<SurfAdjuster>();
}
return adapter;
+3 -3
View File
@@ -257,7 +257,7 @@ struct IntersectAreaCounter
{
CV_Assert( miny < maxy );
CV_Assert( dr > FLT_EPSILON );
int temp_bua = bua, temp_bna = bna;
for( int i = range.begin(); i != range.end(); i++ )
{
@@ -461,7 +461,7 @@ void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H
keypoints1 = _keypoints1 != 0 ? _keypoints1 : &buf1;
keypoints2 = _keypoints2 != 0 ? _keypoints2 : &buf2;
if( (keypoints1->empty() || keypoints2->empty()) && fdetector.empty() )
if( (keypoints1->empty() || keypoints2->empty()) && !fdetector )
CV_Error( Error::StsBadArg, "fdetector must not be empty when keypoints1 or keypoints2 is empty" );
if( keypoints1->empty() )
@@ -575,7 +575,7 @@ void cv::evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, con
if( keypoints1.empty() )
CV_Error( Error::StsBadArg, "keypoints1 must not be empty" );
if( matches1to2->empty() && dmatcher.empty() )
if( matches1to2->empty() && !dmatcher )
CV_Error( Error::StsBadArg, "dmatch must not be empty when matches1to2 is empty" );
bool computeKeypoints2ByPrj = keypoints2.empty();
-1
View File
@@ -357,4 +357,3 @@ int cornerScore<8>(const uchar* ptr, const int pixel[], int threshold)
}
} // namespace cv
+1 -1
View File
@@ -176,7 +176,7 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense",
obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale));
CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid",
obj.info()->addParam(obj, "detector", obj.detector);
obj.info()->addParam<FeatureDetector>(obj, "detector", obj.detector, false, 0, 0); // Extra params added to avoid VS2013 fatal error in opencv2/core.hpp (decl. of addParam)
obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints);
obj.info()->addParam(obj, "gridRows", obj.gridRows);
obj.info()->addParam(obj, "gridCols", obj.gridCols));
+22 -22
View File
@@ -326,7 +326,7 @@ BFMatcher::BFMatcher( int _normType, bool _crossCheck )
Ptr<DescriptorMatcher> BFMatcher::clone( bool emptyTrainData ) const
{
BFMatcher* matcher = new BFMatcher(normType, crossCheck);
Ptr<BFMatcher> matcher = makePtr<BFMatcher>(normType, crossCheck);
if( !emptyTrainData )
{
matcher->trainDescCollection.resize(trainDescCollection.size());
@@ -458,31 +458,31 @@ void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, std::vector<std::v
*/
Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatcherType )
{
DescriptorMatcher* dm = 0;
Ptr<DescriptorMatcher> dm;
if( !descriptorMatcherType.compare( "FlannBased" ) )
{
dm = new FlannBasedMatcher();
dm = makePtr<FlannBasedMatcher>();
}
else if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2
{
dm = new BFMatcher(NORM_L2);
dm = makePtr<BFMatcher>(int(NORM_L2)); // anonymous enums can't be template parameters
}
else if( !descriptorMatcherType.compare( "BruteForce-SL2" ) ) // Squared L2
{
dm = new BFMatcher(NORM_L2SQR);
dm = makePtr<BFMatcher>(int(NORM_L2SQR));
}
else if( !descriptorMatcherType.compare( "BruteForce-L1" ) )
{
dm = new BFMatcher(NORM_L1);
dm = makePtr<BFMatcher>(int(NORM_L1));
}
else if( !descriptorMatcherType.compare("BruteForce-Hamming") ||
!descriptorMatcherType.compare("BruteForce-HammingLUT") )
{
dm = new BFMatcher(NORM_HAMMING);
dm = makePtr<BFMatcher>(int(NORM_HAMMING));
}
else if( !descriptorMatcherType.compare("BruteForce-Hamming(2)") )
{
dm = new BFMatcher(NORM_HAMMING2);
dm = makePtr<BFMatcher>(int(NORM_HAMMING2));
}
else
CV_Error( Error::StsBadArg, "Unknown matcher name" );
@@ -497,8 +497,8 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatche
FlannBasedMatcher::FlannBasedMatcher( const Ptr<flann::IndexParams>& _indexParams, const Ptr<flann::SearchParams>& _searchParams )
: indexParams(_indexParams), searchParams(_searchParams), addedDescCount(0)
{
CV_Assert( !_indexParams.empty() );
CV_Assert( !_searchParams.empty() );
CV_Assert( _indexParams );
CV_Assert( _searchParams );
}
void FlannBasedMatcher::add( const std::vector<Mat>& descriptors )
@@ -522,17 +522,17 @@ void FlannBasedMatcher::clear()
void FlannBasedMatcher::train()
{
if( flannIndex.empty() || mergedDescriptors.size() < addedDescCount )
if( !flannIndex || mergedDescriptors.size() < addedDescCount )
{
mergedDescriptors.set( trainDescCollection );
flannIndex = new flann::Index( mergedDescriptors.getDescriptors(), *indexParams );
flannIndex = makePtr<flann::Index>( mergedDescriptors.getDescriptors(), *indexParams );
}
}
void FlannBasedMatcher::read( const FileNode& fn)
{
if (indexParams.empty())
indexParams = new flann::IndexParams();
if (!indexParams)
indexParams = makePtr<flann::IndexParams>();
FileNode ip = fn["indexParams"];
CV_Assert(ip.type() == FileNode::SEQ);
@@ -570,8 +570,8 @@ void FlannBasedMatcher::read( const FileNode& fn)
};
}
if (searchParams.empty())
searchParams = new flann::SearchParams();
if (!searchParams)
searchParams = makePtr<flann::SearchParams>();
FileNode sp = fn["searchParams"];
CV_Assert(sp.type() == FileNode::SEQ);
@@ -725,7 +725,7 @@ bool FlannBasedMatcher::isMaskSupported() const
Ptr<DescriptorMatcher> FlannBasedMatcher::clone( bool emptyTrainData ) const
{
FlannBasedMatcher* matcher = new FlannBasedMatcher(indexParams, searchParams);
Ptr<FlannBasedMatcher> matcher = makePtr<FlannBasedMatcher>(indexParams, searchParams);
if( !emptyTrainData )
{
CV_Error( Error::StsNotImplemented, "deep clone functionality is not implemented, because "
@@ -1066,7 +1066,7 @@ Ptr<GenericDescriptorMatcher> GenericDescriptorMatcher::create( const String& ge
Ptr<GenericDescriptorMatcher> descriptorMatcher =
Algorithm::create<GenericDescriptorMatcher>("DescriptorMatcher." + genericDescritptorMatcherType);
if( !paramsFilename.empty() && !descriptorMatcher.empty() )
if( !paramsFilename.empty() && descriptorMatcher )
{
FileStorage fs = FileStorage( paramsFilename, FileStorage::READ );
if( fs.isOpened() )
@@ -1086,7 +1086,7 @@ VectorDescriptorMatcher::VectorDescriptorMatcher( const Ptr<DescriptorExtractor>
const Ptr<DescriptorMatcher>& _matcher )
: extractor( _extractor ), matcher( _matcher )
{
CV_Assert( !extractor.empty() && !matcher.empty() );
CV_Assert( extractor && matcher );
}
VectorDescriptorMatcher::~VectorDescriptorMatcher()
@@ -1152,14 +1152,14 @@ void VectorDescriptorMatcher::write (FileStorage& fs) const
bool VectorDescriptorMatcher::empty() const
{
return extractor.empty() || extractor->empty() ||
matcher.empty() || matcher->empty();
return !extractor || extractor->empty() ||
!matcher || matcher->empty();
}
Ptr<GenericDescriptorMatcher> VectorDescriptorMatcher::clone( bool emptyTrainData ) const
{
// TODO clone extractor
return new VectorDescriptorMatcher( extractor, matcher->clone(emptyTrainData) );
return makePtr<VectorDescriptorMatcher>( extractor, matcher->clone(emptyTrainData) );
}
}
+8 -5
View File
@@ -138,13 +138,16 @@ static void computeOrbDescriptor(const KeyPoint& kpt,
const uchar* center = &img.at<uchar>(cvRound(kpt.pt.y), cvRound(kpt.pt.x));
int step = (int)img.step;
#if 1
#define GET_VALUE(idx) \
center[cvRound(pattern[idx].x*b + pattern[idx].y*a)*step + \
cvRound(pattern[idx].x*a - pattern[idx].y*b)]
#else
float x, y;
int ix, iy;
#if 1
#define GET_VALUE(idx) \
(x = pattern[idx].x*a - pattern[idx].y*b, \
y = pattern[idx].x*b + pattern[idx].y*a, \
ix = cvRound(x), \
iy = cvRound(y), \
*(center + iy*step + ix) )
#else
#define GET_VALUE(idx) \
(x = pattern[idx].x*a - pattern[idx].y*b, \
y = pattern[idx].x*b + pattern[idx].y*a, \
-44
View File
@@ -1,44 +0,0 @@
/*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.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, 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 Intel Corporation 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"
/* End of file. */
-1
View File
@@ -93,4 +93,3 @@ void CV_BRISKTest::run( int )
}
TEST(Features2d_BRISK, regression) { CV_BRISKTest test; test.safe_run(); }
@@ -80,10 +80,10 @@ static Mat readMatFromBin( const string& filename )
size_t elements_read4 = fread( (void*)&dataSize, sizeof(int), 1, f );
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
size_t step = dataSize / rows / CV_ELEM_SIZE(type);
CV_Assert(step >= (size_t)cols);
int step = dataSize / rows / CV_ELEM_SIZE(type);
CV_Assert(step >= cols);
Mat m = Mat( rows, step, type).colRange(0, cols);
Mat m = Mat(rows, step, type).colRange(0, cols);
size_t elements_read = fread( m.ptr(), 1, dataSize, f );
CV_Assert(elements_read == (size_t)(dataSize));
@@ -141,7 +141,7 @@ protected:
void emptyDataTest()
{
assert( !dextractor.empty() );
assert( dextractor );
// One image.
Mat image;
@@ -186,7 +186,7 @@ protected:
void regressionTest()
{
assert( !dextractor.empty() );
assert( dextractor );
// Read the test image.
string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME;
@@ -267,7 +267,7 @@ protected:
void run(int)
{
createDescriptorExtractor();
if( dextractor.empty() )
if( !dextractor )
{
ts->printf(cvtest::TS::LOG, "Descriptor extractor is empty.\n");
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
@@ -230,7 +230,7 @@ void CV_FeatureDetectorTest::regressionTest()
void CV_FeatureDetectorTest::run( int /*start_from*/ )
{
if( fdetector.empty() )
if( !fdetector )
{
ts->printf( cvtest::TS::LOG, "Feature detector is empty.\n" );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
-1
View File
@@ -135,4 +135,3 @@ void CV_FastTest::run( int )
}
TEST(Features2d_FAST, regression) { CV_FastTest test; test.safe_run(); }
+1 -3
View File
@@ -62,7 +62,7 @@ protected:
virtual void run(int)
{
cv::initModule_features2d();
CV_Assert(!detector.empty());
CV_Assert(detector);
string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME;
// Read the test image.
@@ -166,5 +166,3 @@ TEST(Features2d_Detector_Keypoints_Dense, validation)
CV_FeatureDetectorKeypointsTest test(Algorithm::create<FeatureDetector>("Feature2D.Dense"));
test.safe_run();
}
-1
View File
@@ -205,4 +205,3 @@ void CV_MserTest::run(int)
}
TEST(Features2d_MSER, DISABLED_regression) { CV_MserTest test; test.safe_run(); }
-1
View File
@@ -1 +0,0 @@
#include "test_precomp.hpp"
@@ -196,7 +196,7 @@ public:
minKeyPointMatchesRatio(_minKeyPointMatchesRatio),
minAngleInliersRatio(_minAngleInliersRatio)
{
CV_Assert(!featureDetector.empty());
CV_Assert(featureDetector);
}
protected:
@@ -307,8 +307,8 @@ public:
normType(_normType),
minDescInliersRatio(_minDescInliersRatio)
{
CV_Assert(!featureDetector.empty());
CV_Assert(!descriptorExtractor.empty());
CV_Assert(featureDetector);
CV_Assert(descriptorExtractor);
}
protected:
@@ -392,7 +392,7 @@ public:
minKeyPointMatchesRatio(_minKeyPointMatchesRatio),
minScaleInliersRatio(_minScaleInliersRatio)
{
CV_Assert(!featureDetector.empty());
CV_Assert(featureDetector);
}
protected:
@@ -510,8 +510,8 @@ public:
normType(_normType),
minDescInliersRatio(_minDescInliersRatio)
{
CV_Assert(!featureDetector.empty());
CV_Assert(!descriptorExtractor.empty());
CV_Assert(featureDetector);
CV_Assert(descriptorExtractor);
}
protected: