I have cv::Mat
and my custom struct that holds the data. Is it safe to pass the data from cv::Mat
to my structure like this?
struct MyStruct {
uint8_t* data;
}
MyStruct foo(){
MyStruct s;
cv::Mat m = cv::imread("test.png", 0);
s.data = m.data;
m.data = nullptr;
return s;
}
Basically, I need OpenCV not to destroy allocated cv::Mat
data. I also dont want to create copy, since the data may be quite large.
Or is there any other way?