1 | initial version |
one module of our OpenCV software will be developed by another company
please try to convince them to use cv::Mat, not a shared_ptr.
you might try something like this:
Mat src = ...
shared_ptr<char> p( static_cast<char>(src.data) );
PartnerCompanyModule( p, src.type(), src.cols, src.rows );
but now youre in trouble, since both Mat and shared_ptr want to delete the data !
once you use a shared_ptr, it tries to take ownership of the data.
you could again hack it:
src.addref(); // so the Mat won't delete it
shared_ptr<char> p( static_cast<char>(src.data) );
but seriously, that's terrible. a "whack a mole" game with refcounts, design HELL !
2 | No.2 Revision |
one module of our OpenCV software will be developed by another company
please try to convince them to use cv::Mat, not a shared_ptr.
you might try something like this:
Mat src = ...
shared_ptr<char> p( static_cast<char>(src.data) );
PartnerCompanyModule( p, src.type(), src.cols, src.rows );
but now youre in trouble, since both Mat and shared_ptr want to delete the data !
once you use a shared_ptr, it tries to take ownership of the data.
you could again hack it:
src.addref(); // so the Mat won't delete it
shared_ptr<char> p( static_cast<char>(src.data) );
but seriously, that's terrible. a "whack a mole" game with refcounts, design HELL !terrible.