1 | initial version |
Okay, in case anybody else is wondering about the same, here are my findings:
As pointed out in the comments already (thanks), cv::Mat::zeros
seems to replace cvZero
and cv::Mat::setTo
replaces cvSet
. What I now learned about memory management in the C++ interface here clarifies some obscurity. From diving into the source code, I learned that e.g. myMat = cv::Mat::zeros( ... );
, while looking totally like an inefficient assignment, in reality isn't one. It rather creates an expression which in combination with the overloaded assignment operator for Mat = MatExp
just applies an operation on the existing matrix, in case size and format match. I must say, while being convenient, the C++ interface is not really intuitive. Things like that aren't self-explanatory and I think they should be pointed out much clearer to OpenCV beginners, especially to those with strong C++ background. To a general programming beginner it might be fine, but for experienced C++ programmers, writing some expressions surely set off the alarm bells. In case I missed a detailled explaination about those mechanisms in the documentation, I would be glad about somebody pointing me to it.
2 | No.2 Revision |
Okay, in case anybody else is wondering about the same, here are my findings:
As pointed out in the comments already (thanks), cv::Mat::zeros
seems to replace cvZero
and cv::Mat::setTo
replaces cvSet
. What I now learned about memory management in the C++ interface here clarifies some obscurity. From diving into the source code, I learned that e.g. myMat = cv::Mat::zeros( ... );
, while looking totally like an inefficient assignment, in reality isn't one. It rather creates an expression which in combination with the overloaded assignment operator for Mat = MatExp
just applies an operation on the existing matrix, in case size and format match.
I must say, while being convenient, the C++ interface is not really intuitive. Things like that aren't self-explanatory and I think they should be pointed out much clearer to OpenCV beginners, especially to those with strong C++ background. To a general programming beginner it might be fine, but for experienced C++ programmers, writing some expressions surely set sets off the alarm bells. In case I missed a detailled explaination about those mechanisms in the documentation, I would be glad about somebody pointing me to it.