I am using a 3rd party SDK in my project which accepts void *
pointer for setting user specific metadata. But my metadata is in cv::Mat
format thus I need to cast the cv::Mat
as void *
pointer as shown here:
void *set_metadata_ptr(cv::Mat frame)
{
cv::Mat *user_metadata = new cv::Mat();
frame.copyTo(*user_metadata);
return (void *)user_metadata;
}
void foo()
{
UserMeta *user_meta = /* ... */;
user_meta->user_meta_data = (void *)set_metadata_ptr(frame);
}
This works good, but many of the OpenCV power users discourage using pointers with cv::Mat as cv::Mat has smart pointer itself. I wonder is there any better way to cast the cv::Mat as void-pointer in my case?