For what I see in the OpenCV documentation, this is a smart pointer with reference counting, essentially the same as boost::shared_ptr . Even it uses atomic operations in the reference counter.
I would make a choice based on portability and interoperability.
Will your system be moved to another place and, of course, depends on OpenCV, but not on boost ? Then stick with OpenCV cv::Ptr if you can avoid the boost and get rid of the dependency.
Is boost::shared_ptr with the rest of OpenCV? If you have something returning cv :: Ptr from the OpenCV library, it might be better to stick to cv :: Ptr in these cases, because the reference counter will not work correctly if you mix both types of pointers and the resource may be prematurely destroyed .
Are you going to stick with boost wherever you port your project? Then, stick with boost::shared_ptr , when you can do this, this is more standard, people know this and immediately understand your code. UPDATE: In C ++ 11, you have std :: shared_ptr, which has no dependency if you can afford it, so you can use std :: shared_ptr in this case and get rid of boost.
As a note, there is a method for mixing boost and std with common pointers that can properly support links and can be useful to someone. See this question, it may be relevant for mixing other pointers with reference counting: Conversion from boost :: shared_ptr to std :: shared_ptr?
In my experience, when you mess up something, the fewer dependencies, the better, or there are certain platforms for which compilation can be hell. Therefore, make your choice based on portability if this is a problem and pointer compatibility with libraries.
GermΓ‘n Diago
source share