Commit abb211d0 authored by Alexander Alekhin's avatar Alexander Alekhin

avoid `Ptr<> == NULL` checks

parent 5c362968
...@@ -562,7 +562,7 @@ bool RetinaImpl::ocl_run(InputArray inputMatToConvert) ...@@ -562,7 +562,7 @@ bool RetinaImpl::ocl_run(InputArray inputMatToConvert)
void RetinaImpl::run(InputArray inputMatToConvert) void RetinaImpl::run(InputArray inputMatToConvert)
{ {
CV_OCL_RUN((_ocl_retina != 0 && inputMatToConvert.isUMat()), ocl_run(inputMatToConvert)); CV_OCL_RUN((_ocl_retina && inputMatToConvert.isUMat()), ocl_run(inputMatToConvert));
_wasOCLRunCalled = false; _wasOCLRunCalled = false;
// first convert input image to the compatible format : std::valarray<float> // first convert input image to the compatible format : std::valarray<float>
...@@ -830,7 +830,7 @@ bool RetinaImpl::_convertCvMat2ValarrayBuffer(InputArray inputMat, std::valarray ...@@ -830,7 +830,7 @@ bool RetinaImpl::_convertCvMat2ValarrayBuffer(InputArray inputMat, std::valarray
void RetinaImpl::clearBuffers() void RetinaImpl::clearBuffers()
{ {
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
if (_ocl_retina != 0) if (_ocl_retina)
_ocl_retina->clearBuffers(); _ocl_retina->clearBuffers();
#endif #endif
......
...@@ -1055,8 +1055,8 @@ bool Odometry::compute(Ptr<OdometryFrame>& srcFrame, Ptr<OdometryFrame>& dstFram ...@@ -1055,8 +1055,8 @@ bool Odometry::compute(Ptr<OdometryFrame>& srcFrame, Ptr<OdometryFrame>& dstFram
Size Odometry::prepareFrameCache(Ptr<OdometryFrame> &frame, int /*cacheType*/) const Size Odometry::prepareFrameCache(Ptr<OdometryFrame> &frame, int /*cacheType*/) const
{ {
if(frame == 0) if (!frame)
CV_Error(Error::StsBadArg, "Null frame pointer.\n"); CV_Error(Error::StsBadArg, "Null frame pointer.");
return Size(); return Size();
} }
......
...@@ -665,12 +665,12 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) ...@@ -665,12 +665,12 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child)
child->level = child->level*thresholdDelta; child->level = child->level*thresholdDelta;
// before saving calculate P(child|character) and filter if possible // before saving calculate P(child|character) and filter if possible
if (classifier != NULL) if (classifier)
{ {
child->probability = classifier->eval(*child); child->probability = classifier->eval(*child);
} }
if ( (((classifier!=NULL)?(child->probability >= minProbability):true)||(nonMaxSuppression)) && if ( (((classifier)?(child->probability >= minProbability):true)||(nonMaxSuppression)) &&
((child->area >= (minArea*region_mask.rows*region_mask.cols)) && ((child->area >= (minArea*region_mask.rows*region_mask.cols)) &&
(child->area <= (maxArea*region_mask.rows*region_mask.cols)) && (child->area <= (maxArea*region_mask.rows*region_mask.cols)) &&
(child->rect.width > 2) && (child->rect.height > 2)) ) (child->rect.width > 2) && (child->rect.height > 2)) )
...@@ -858,12 +858,12 @@ ERStat* ERFilterNM::er_tree_filter ( InputArray image, ERStat * stat, ERStat *pa ...@@ -858,12 +858,12 @@ ERStat* ERFilterNM::er_tree_filter ( InputArray image, ERStat * stat, ERStat *pa
// calculate P(child|character) and filter if possible // calculate P(child|character) and filter if possible
if ( (classifier != NULL) && (stat->parent != NULL) ) if (classifier && (stat->parent != NULL))
{ {
stat->probability = classifier->eval(*stat); stat->probability = classifier->eval(*stat);
} }
if ( ( ((classifier != NULL)?(stat->probability >= minProbability):true) && if ( ( ((classifier)?(stat->probability >= minProbability):true) &&
((stat->area >= minArea*region_mask.rows*region_mask.cols) && ((stat->area >= minArea*region_mask.rows*region_mask.cols) &&
(stat->area <= maxArea*region_mask.rows*region_mask.cols)) ) || (stat->area <= maxArea*region_mask.rows*region_mask.cols)) ) ||
(stat->parent == NULL) ) (stat->parent == NULL) )
......
...@@ -93,7 +93,7 @@ int main( int argc, char** argv ){ ...@@ -93,7 +93,7 @@ int main( int argc, char** argv ){
//instantiates the specific Tracker //instantiates the specific Tracker
Ptr<Tracker> tracker = createTrackerByName(tracker_algorithm); Ptr<Tracker> tracker = createTrackerByName(tracker_algorithm);
if( tracker == NULL ) if (!tracker)
{ {
cout << "***Error in the instantiation of the tracker...***\n"; cout << "***Error in the instantiation of the tracker...***\n";
return -1; return -1;
......
...@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) ...@@ -145,7 +145,7 @@ int main(int argc, char *argv[])
//Create Tracker //Create Tracker
Ptr<Tracker> tracker = createTrackerByName(tracker_algorithm); Ptr<Tracker> tracker = createTrackerByName(tracker_algorithm);
if (tracker == NULL) if (!tracker)
{ {
cout << "***Error in the instantiation of the tracker...***\n"; cout << "***Error in the instantiation of the tracker...***\n";
getchar(); getchar();
......
...@@ -47,7 +47,7 @@ namespace cv ...@@ -47,7 +47,7 @@ namespace cv
bool MultiTracker_Alt::addTarget(InputArray image, const Rect2d& boundingBox, Ptr<Tracker> tracker_algorithm) bool MultiTracker_Alt::addTarget(InputArray image, const Rect2d& boundingBox, Ptr<Tracker> tracker_algorithm)
{ {
Ptr<Tracker> tracker = tracker_algorithm; Ptr<Tracker> tracker = tracker_algorithm;
if (tracker == NULL) if (!tracker)
return false; return false;
if (!tracker->init(image, boundingBox)) if (!tracker->init(image, boundingBox))
......
...@@ -70,7 +70,7 @@ bool Tracker::init( InputArray image, const Rect2d& boundingBox ) ...@@ -70,7 +70,7 @@ bool Tracker::init( InputArray image, const Rect2d& boundingBox )
bool initTracker = initImpl( image.getMat(), boundingBox ); bool initTracker = initImpl( image.getMat(), boundingBox );
//check if the model component is initialized //check if the model component is initialized
if( model == 0 ) if (!model)
{ {
CV_Error( -1, "The model is not initialized" ); CV_Error( -1, "The model is not initialized" );
} }
......
...@@ -101,7 +101,7 @@ bool TrackerFeatureSet::addTrackerFeature( String trackerFeatureType ) ...@@ -101,7 +101,7 @@ bool TrackerFeatureSet::addTrackerFeature( String trackerFeatureType )
} }
Ptr<TrackerFeature> feature = TrackerFeature::create( trackerFeatureType ); Ptr<TrackerFeature> feature = TrackerFeature::create( trackerFeatureType );
if( feature == 0 ) if (!feature)
{ {
return false; return false;
} }
......
...@@ -61,7 +61,7 @@ TrackerModel::~TrackerModel() ...@@ -61,7 +61,7 @@ TrackerModel::~TrackerModel()
bool TrackerModel::setTrackerStateEstimator( Ptr<TrackerStateEstimator> trackerStateEstimator ) bool TrackerModel::setTrackerStateEstimator( Ptr<TrackerStateEstimator> trackerStateEstimator )
{ {
if( stateEstimator != 0 ) if (stateEstimator.get())
{ {
return false; return false;
} }
...@@ -109,12 +109,12 @@ void TrackerModel::modelUpdate() ...@@ -109,12 +109,12 @@ void TrackerModel::modelUpdate()
bool TrackerModel::runStateEstimator() bool TrackerModel::runStateEstimator()
{ {
if( stateEstimator == 0 ) if (!stateEstimator)
{ {
CV_Error( -1, "Tracker state estimator is not setted" ); CV_Error( -1, "Tracker state estimator is not setted" );
} }
Ptr<TrackerTargetState> targetState = stateEstimator->estimate( confidenceMaps ); Ptr<TrackerTargetState> targetState = stateEstimator->estimate( confidenceMaps );
if( targetState == 0 ) if (!targetState)
return false; return false;
setLastTargetState( targetState ); setLastTargetState( targetState );
......
...@@ -96,7 +96,7 @@ bool TrackerSampler::addTrackerSamplerAlgorithm( String trackerSamplerAlgorithmT ...@@ -96,7 +96,7 @@ bool TrackerSampler::addTrackerSamplerAlgorithm( String trackerSamplerAlgorithmT
} }
Ptr<TrackerSamplerAlgorithm> sampler = TrackerSamplerAlgorithm::create( trackerSamplerAlgorithmType ); Ptr<TrackerSamplerAlgorithm> sampler = TrackerSamplerAlgorithm::create( trackerSamplerAlgorithmType );
if( sampler == 0 ) if (!sampler)
{ {
return false; return false;
} }
...@@ -113,7 +113,7 @@ bool TrackerSampler::addTrackerSamplerAlgorithm( Ptr<TrackerSamplerAlgorithm>& s ...@@ -113,7 +113,7 @@ bool TrackerSampler::addTrackerSamplerAlgorithm( Ptr<TrackerSamplerAlgorithm>& s
return false; return false;
} }
if( sampler == 0 ) if (!sampler)
{ {
return false; return false;
} }
......
...@@ -262,14 +262,14 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression) ...@@ -262,14 +262,14 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression)
const int k = 3; const int k = 3;
Ptr<DescriptorExtractor> ext = SURF::create(); Ptr<DescriptorExtractor> ext = SURF::create();
ASSERT_TRUE(ext != NULL); ASSERT_TRUE(ext);
Ptr<FeatureDetector> det = SURF::create(); Ptr<FeatureDetector> det = SURF::create();
//"%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n" //"%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n"
ASSERT_TRUE(det != NULL); ASSERT_TRUE(det);
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce"); Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce");
ASSERT_TRUE(matcher != NULL); ASSERT_TRUE(matcher);
Mat imgT(256, 256, CV_8U, Scalar(255)); Mat imgT(256, 256, CV_8U, Scalar(255));
line(imgT, Point(20, sz/2), Point(sz-21, sz/2), Scalar(100), 2); line(imgT, Point(20, sz/2), Point(sz-21, sz/2), Scalar(100), 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment