Commit 94c310fc authored by Anatoly Baksheev's avatar Anatoly Baksheev

added Ptr::operator==

parent aabb40e3
...@@ -1284,6 +1284,8 @@ public: ...@@ -1284,6 +1284,8 @@ public:
operator _Tp* (); operator _Tp* ();
operator const _Tp*() const; operator const _Tp*() const;
bool operator==(const Ptr<_Tp>& ptr) const;
_Tp* obj; //< the object pointer. _Tp* obj; //< the object pointer.
int* refcount; //< the associated reference counter int* refcount; //< the associated reference counter
}; };
......
...@@ -2690,6 +2690,11 @@ template<typename _Tp> template<typename _Tp2> inline const Ptr<_Tp2> Ptr<_Tp>:: ...@@ -2690,6 +2690,11 @@ template<typename _Tp> template<typename _Tp2> inline const Ptr<_Tp2> Ptr<_Tp>::
return p; return p;
} }
template<typename _Tp> inline bool Ptr<_Tp>::operator==(const Ptr<_Tp>& _ptr) const
{
return refcount == _ptr.refcount;
}
//// specializied implementations of Ptr::delete_obj() for classic OpenCV types //// specializied implementations of Ptr::delete_obj() for classic OpenCV types
template<> CV_EXPORTS void Ptr<CvMat>::delete_obj(); template<> CV_EXPORTS void Ptr<CvMat>::delete_obj();
......
...@@ -31,7 +31,7 @@ PERF_TEST_P(fast, detect, testing::Combine( ...@@ -31,7 +31,7 @@ PERF_TEST_P(fast, detect, testing::Combine(
declare.in(frame); declare.in(frame);
Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FAST"); Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FAST");
ASSERT_FALSE( fd == 0 ); ASSERT_FALSE( fd.empty() );
fd->set("threshold", 20); fd->set("threshold", 20);
fd->set("nonmaxSuppression", true); fd->set("nonmaxSuppression", true);
fd->set("type", type); fd->set("type", type);
......
...@@ -531,7 +531,7 @@ void FlannBasedMatcher::train() ...@@ -531,7 +531,7 @@ void FlannBasedMatcher::train()
void FlannBasedMatcher::read( const FileNode& fn) void FlannBasedMatcher::read( const FileNode& fn)
{ {
if (indexParams == 0) if (indexParams.empty())
indexParams = new flann::IndexParams(); indexParams = new flann::IndexParams();
FileNode ip = fn["indexParams"]; FileNode ip = fn["indexParams"];
...@@ -570,7 +570,7 @@ void FlannBasedMatcher::read( const FileNode& fn) ...@@ -570,7 +570,7 @@ void FlannBasedMatcher::read( const FileNode& fn)
}; };
} }
if (searchParams == 0) if (searchParams.empty())
searchParams = new flann::SearchParams(); searchParams = new flann::SearchParams();
FileNode sp = fn["searchParams"]; FileNode sp = fn["searchParams"];
......
...@@ -350,7 +350,7 @@ void SurfFeaturesFinder::find(const Mat &image, ImageFeatures &features) ...@@ -350,7 +350,7 @@ void SurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)
Mat gray_image; Mat gray_image;
CV_Assert(image.type() == CV_8UC3); CV_Assert(image.type() == CV_8UC3);
cvtColor(image, gray_image, CV_BGR2GRAY); cvtColor(image, gray_image, CV_BGR2GRAY);
if (surf == 0) if (surf.empty())
{ {
detector_->detect(gray_image, features.keypoints); detector_->detect(gray_image, features.keypoints);
extractor_->compute(gray_image, features.keypoints, features.descriptors); extractor_->compute(gray_image, features.keypoints, features.descriptors);
......
...@@ -41,7 +41,7 @@ void CV_BackgroundSubtractorTest::run(int) ...@@ -41,7 +41,7 @@ void CV_BackgroundSubtractorTest::run(int)
Algorithm::create<BackgroundSubtractorGMG>("BackgroundSubtractor.GMG"); Algorithm::create<BackgroundSubtractorGMG>("BackgroundSubtractor.GMG");
Mat fgmask; Mat fgmask;
if (fgbg == NULL) if (fgbg.empty())
CV_Error(CV_StsError,"Failed to create Algorithm\n"); CV_Error(CV_StsError,"Failed to create Algorithm\n");
/** /**
......
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