Boring changes - legacy.
authorRoman Donchenko <roman.donchenko@itseez.com>
Tue, 13 Aug 2013 14:29:36 +0000 (18:29 +0400)
committerRoman Donchenko <roman.donchenko@itseez.com>
Thu, 5 Sep 2013 15:02:59 +0000 (19:02 +0400)
modules/legacy/src/features2d.cpp
modules/legacy/src/kdtree.cpp
modules/legacy/src/oneway.cpp
modules/legacy/src/planardetect.cpp

index 578b732..f313875 100644 (file)
@@ -73,7 +73,7 @@ cvExtractSURF( const CvArr* _img, const CvArr* _mask,
     Mat descr;
 
     Ptr<Feature2D> surf = Algorithm::create<Feature2D>("Feature2D.SURF");
-    if( surf.empty() )
+    if( !surf )
         CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support");
 
     surf->set("hessianThreshold", params.hessianThreshold);
@@ -107,10 +107,10 @@ CV_IMPL CvSeq*
 cvGetStarKeypoints( const CvArr* _img, CvMemStorage* storage,
                     CvStarDetectorParams params )
 {
-    Ptr<StarDetector> star = new StarDetector(params.maxSize, params.responseThreshold,
-                                              params.lineThresholdProjected,
-                                              params.lineThresholdBinarized,
-                                              params.suppressNonmaxSize);
+    Ptr<StarDetector> star(new StarDetector(params.maxSize, params.responseThreshold,
+                                            params.lineThresholdProjected,
+                                            params.lineThresholdBinarized,
+                                            params.suppressNonmaxSize));
     std::vector<KeyPoint> kpts;
     star->detect(cvarrToMat(_img), kpts, Mat());
 
index a32677b..4183950 100644 (file)
@@ -172,7 +172,7 @@ public:
       CV_Error(CV_StsUnsupportedFormat, "dist must be CV_64FC1");
 
     if (CV_MAT_TYPE(type()) != CV_MAT_TYPE(desc->type)) {
-      tmp_desc = cvCreateMat(desc->rows, desc->cols, type());
+      tmp_desc.reset(cvCreateMat(desc->rows, desc->cols, type()));
       cvConvert(desc, tmp_desc);
       desc = tmp_desc;
     }
index 7fa4bee..43ded85 100644 (file)
@@ -1736,7 +1736,7 @@ namespace cv{
     {
         std::vector<KeyPoint> features;
         Ptr<FeatureDetector> surf_extractor = FeatureDetector::create("SURF");
-        if( surf_extractor.empty() )
+        if( !surf_extractor )
             CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support");
         surf_extractor->set("hessianThreshold", 1.0);
         //printf("Extracting SURF features...");
@@ -2186,7 +2186,7 @@ namespace cv{
     {
         clear();
 
-        if( _base.empty() )
+        if( !_base )
             base = _base;
 
         params = _params;
@@ -2197,16 +2197,17 @@ namespace cv{
         GenericDescriptorMatcher::clear();
 
         prevTrainCount = 0;
-        if( !base.empty() )
+        if( base )
             base->clear();
     }
 
     void OneWayDescriptorMatcher::train()
     {
-        if( base.empty() || prevTrainCount < (int)trainPointCollection.keypointCount() )
+        if( !base || prevTrainCount < (int)trainPointCollection.keypointCount() )
         {
-            base = new OneWayDescriptorObject( params.patchSize, params.poseCount, params.pcaFilename,
-                                              params.trainPath, params.trainImagesList, params.minScale, params.maxScale, params.stepScale );
+            base.reset(
+                new OneWayDescriptorObject( params.patchSize, params.poseCount, params.pcaFilename,
+                                            params.trainPath, params.trainImagesList, params.minScale, params.maxScale, params.stepScale ));
 
             base->Allocate( (int)trainPointCollection.keypointCount() );
             prevTrainCount = (int)trainPointCollection.keypointCount();
@@ -2270,8 +2271,9 @@ namespace cv{
 
     void OneWayDescriptorMatcher::read( const FileNode &fn )
     {
-        base = new OneWayDescriptorObject( params.patchSize, params.poseCount, String (), String (), String (),
-                                          params.minScale, params.maxScale, params.stepScale );
+        base.reset(
+            new OneWayDescriptorObject( params.patchSize, params.poseCount, String (), String (), String (),
+                                        params.minScale, params.maxScale, params.stepScale ));
         base->Read (fn);
     }
 
@@ -2282,12 +2284,12 @@ namespace cv{
 
     bool OneWayDescriptorMatcher::empty() const
     {
-        return base.empty() || base->empty();
+        return !base || base->empty();
     }
 
     Ptr<GenericDescriptorMatcher> OneWayDescriptorMatcher::clone( bool emptyTrainData ) const
     {
-        OneWayDescriptorMatcher* matcher = new OneWayDescriptorMatcher( params );
+        Ptr<OneWayDescriptorMatcher> matcher = makePtr<OneWayDescriptorMatcher>( params );
 
         if( !emptyTrainData )
         {
index 2bffea0..fa9152d 100644 (file)
@@ -1240,7 +1240,7 @@ FernDescriptorMatcher::FernDescriptorMatcher( const Params& _params )
     params = _params;
     if( !params.filename.empty() )
     {
-        classifier = new FernClassifier;
+        classifier = makePtr<FernClassifier>();
         FileStorage fs(params.filename, FileStorage::READ);
         if( fs.isOpened() )
             classifier->read( fs.getFirstTopLevelNode() );
@@ -1260,7 +1260,7 @@ void FernDescriptorMatcher::clear()
 
 void FernDescriptorMatcher::train()
 {
-    if( classifier.empty() || prevTrainCount < (int)trainPointCollection.keypointCount() )
+    if( !classifier || prevTrainCount < (int)trainPointCollection.keypointCount() )
     {
         assert( params.filename.empty() );
 
@@ -1268,9 +1268,10 @@ void FernDescriptorMatcher::train()
         for( size_t imgIdx = 0; imgIdx < trainPointCollection.imageCount(); imgIdx++ )
             KeyPoint::convert( trainPointCollection.getKeypoints((int)imgIdx), points[imgIdx] );
 
-        classifier = new FernClassifier( points, trainPointCollection.getImages(), std::vector<std::vector<int> >(), 0, // each points is a class
-                                        params.patchSize, params.signatureSize, params.nstructs, params.structSize,
-                                        params.nviews, params.compressionMethod, params.patchGenerator );
+        classifier.reset(
+            new FernClassifier( points, trainPointCollection.getImages(), std::vector<std::vector<int> >(), 0, // each points is a class
+                                params.patchSize, params.signatureSize, params.nstructs, params.structSize,
+                                params.nviews, params.compressionMethod, params.patchGenerator ));
     }
 }
 
@@ -1384,12 +1385,12 @@ void FernDescriptorMatcher::write( FileStorage& fs ) const
 
 bool FernDescriptorMatcher::empty() const
 {
-    return classifier.empty() || classifier->empty();
+    return !classifier || classifier->empty();
 }
 
 Ptr<GenericDescriptorMatcher> FernDescriptorMatcher::clone( bool emptyTrainData ) const
 {
-    FernDescriptorMatcher* matcher = new FernDescriptorMatcher( params );
+    Ptr<FernDescriptorMatcher> matcher = makePtr<FernDescriptorMatcher>( params );
     if( !emptyTrainData )
     {
         CV_Error( CV_StsNotImplemented, "deep clone dunctionality is not implemented, because "