Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::Mat* is pointer to the cv::Mat. Believing that much, the trivial assignments should work:

  cv::Mat x;
  cv::Mat *xp = &x;
  cv::Mat y = *xp;

Beware simple assignment does not copy the buffer, so you must be sure that Mat object referenced by that pointer lives at least as long as you y does. If you are not sure, create a complete copy of it:

cv::Mat y = xp->clone();

It is really strange to see pointers to cv::Mat, normally should not be required. I would not recommend, but when working with the third party code it may be no choices.