I have the following initialized at the top of a function:
cv::Mat *m;
Then, within a loop I am allocating new matrices with this name and storing them in a list. I want them to initialize as zero matrices with a specific size.
This is what I tried:
m = new cv::Mat::zeros(height, width, CV_32F);
I tried this based on the example given in the OpenCV documentation. What is the correct way to perform this operation?
From the documentation of Mat::zeros it use used like so
cv::Mat m = cv::Mat::zeros(height, width, CV_32F);
If you want to use a Mat
allocated on the heap use
cv::Mat * m = new cv::Mat( cv::Mat::zeros(height, width, CV_32F) );
// use m
delete m; // don't forget to delete m
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With