I have an OpenCV function which return type is Mat.
How do I convert that to a 2 dimensional float array (** float)?
Probably very simple but I have not been able to do it myself.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A quick look at the documentation for the
Matclass doesn’t reveal any obvious ‘convert tofloat**‘ operator, but you could probably do it by hand:If you’re not dead-set on using
float**, you could usestd::vectororboost::multi_arrayto avoid the awkward memory allocation/deallocation and reduce the potential for leaks.You might also have some luck using
Mat::ptr<float>(n)to get afloat*to thenth row of a matrix, but if you don’t copy the data out, I’m not sure what guarantees you’ll have about how long that pointer will remain valid.