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);
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());
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;
}
{
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...");
{
clear();
- if( _base.empty() )
+ if( !_base )
base = _base;
params = _params;
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();
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);
}
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 )
{
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() );
void FernDescriptorMatcher::train()
{
- if( classifier.empty() || prevTrainCount < (int)trainPointCollection.keypointCount() )
+ if( !classifier || prevTrainCount < (int)trainPointCollection.keypointCount() )
{
assert( params.filename.empty() );
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 ));
}
}
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 "