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

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!!