How to convert numpy array to cv::Mat
Hi,
We are using OpenCV 4 (latest 4.1.2) with Python 3.6 and latest numpy 1.17 and we would like to convert some numpy arrays to cv::Mat type..
how to do that ? is that possible ?
given I can pass numpy arrays from python to c++ (with boost) I can do that either on python side or in c++ side.. (but my preferrence would be to python side).
Thanks for any info.
Greg.
just to scare you -- have a look here
i seriously doubt, that mixing opencv's attempt at wrapping Mat / UMat and your idea using boost will ever work out nicely together.
Hi, thx for the link. How are we supposed to use that ? :| I already saw it but I dont see any example in the sources or nowhere on internet.. Regards.
heh, you are not supposed to use that, it's part of the automated wrapping system.
honestly, i'm more trying to scare you away from the whole idea.
I don't quite get you :/
there is no way to convert a numpy array to a cv::Mat (direcly or indirectly) ?
thx anyway.
why do you want to do this ?
if you have existing c++ (opencv) code, it's probably easier to use the existing wrapping mechanism, than to roll your own
we have previously python code doing operations on numpy arrays. we converted this code to c++ and use opencv to do operations but we want to be able to still pass (or convert) numpy arrays from python to our c++ code (wrapped with boost)..
I am quite suprised this isn't a common need :/
I could create a cv::Mat from a numpy array. I now have to be able to do that opposite and my problem would be solved..