How to convert cv::Mat* to cv::Mat?

asked 2019-07-16 01:16:05 -0500

updated 2019-07-16 02:43:50 -0500

Hi all,
How to convert cv::Mat* to cv::Mat by C++ in opencv-4.1.0?
I'm using some third party SDK that return the result as cv::Mat*.
How do can I convert it to cv::Mat to manipulate by opencv.

edit retag flag offensive close merge delete

Comments

WHY is there a cv::Mat* in your code (it shouldn't be !) ?

please show us, so we get a better idea, what to do.

also please look up "how to dereference c++ pointers", it's a very basic c++ topic, and you should have it covered before venturing into more complicated things, like computer-vision.

berak gravatar imageberak ( 2019-07-16 02:50:34 -0500 )edit

some third party SDK that return the result as cv::Mat*

RED FLAG here. unless it's open src you wouldn't know, whether to delete it in the end or not.

again, please show us some code (function signatures, etc)

berak gravatar imageberak ( 2019-07-16 03:01:16 -0500 )edit

Thanks @berak,
Actually it is not in my code, Third party sdk is response their result as cv::Mat* .
According by their document, OpenCV can be used in case if OpenCV library is available.

cv::Mat resultImage = result.image.mat(); 
 //IDE warning: no suitable constructor exists to convert from "cv::Mat *" to "cv::Mat"

I will check with third party vendor again. thanks again.

MinChanSike gravatar imageMinChanSike ( 2019-07-16 03:08:50 -0500 )edit

5 posts already, and we still don't know, which sdk you're talking about (link ?) what result.image.mat(); might be, exactly, constraints of it's usage (null pointers ? pointer ownage ?), etc.

berak gravatar imageberak ( 2019-07-16 03:18:11 -0500 )edit

https://www.carrida-technologies.com/...

Well that's remarkably un-informative. I think it's just returning a pointer to the internal cv::Mat, so don't delete it. But it copies a cv::Mat you use to construct it, with an optional bool.

Oh dear, it actually stores a cv::Mat* as it's member variable. Eww.

Tetragramm gravatar imageTetragramm ( 2019-07-17 23:14:13 -0500 )edit