How to convert CvMat to cv::Mat and use += operator on cv::Mat object?

Hi,

I want to convert CvMat to cv::Mat. When I google I got to know cvarrToMat() can be used for this. Below is pseudo code that is creating run time error.
Note : I’m using Opencv 4.4 version .

CvMat m ;  // suppose these all variables are initialized.
cv::Mat n ;
cv::Mat p;
cv::Mat q;
n = cvarrToMat(&m); // I want to replace m value of type CvMat to Mat.
q += p.t()*n;  // getting error in this line.

This run time error is belonging to operator in mat.inl.hpp.

I go through almost all available solution that is discussed regarding this on the forums . Please help me to fix this.

Thanks !!

please show the error !

(and, in the long run, cvarrToMat() is not a solution,
you will need to replace all the CVMat code, too !)

btw,

p is never initialized in the code you show

Hi berak,
Thanks for your quick reply.
Actually I just write a pseudo code. So please assume ‘p’ is also initialized.
Here I paste snippet

This question is related to my experiment, it’s originally belongs to my other query I posted on the forum . You can check here.

Please let me know if you found something on this.

Thanks in advance!!

screenshots of code or errors are NEVER helpful ANYWHERE
(a debug stacktrace would be …)
((but congrats, looks like you broke the library))

not that this helps, either ;(

Could you please suggest other ways how CvMat converts to cv::Mat while using Opencv 4.4 version ? Rather than replacing CvMat by cv::Mat.

well, you’ll HAVE TO replace that opencv 1.0 legacy C code. no way around it

we’re at 4.5.4 now

besides that – what about exact code, and a stacktrace ?

Thanks for the info.
Sorry , due to some reason , I’m unable to send the code and stack trace.