From the link: https://docs.opencv.org/trunk/d3/d63/classcv_1_1Mat.html
operator+ is not overloaded in the definition of Mat class. However, oprator+ can be used to add two objects of class Mat. It really confuses me.
By consulting the cv::Mat
documentation, the functionality you are looking for is under operator=(const MatExpr& expr)
: https://docs.opencv.org/trunk/d3/d63/classcv_1_1Mat.html#a2a0798475170fb3a23b5bc63686de334
Specifically, this section of the documentation is useful (emphasis mine):
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameters
expr
: Assigned matrix expression object. As opposite to the first form of the assignment operation, the second form can reuse an already allocated matrix if it has the right size and type to fit the matrix expression result . It is automatically handled by the real function that the matrix expressions is expanded to. For example, C=A+B
is expanded to add(A, B, C)
, and add takes care of automatic C
reallocation.
Therefore, what is happening is that the overloaded operator for assignment ( =
) is what is being called, and a MatExpr
expr
, which is a MatExpr
expression is being evaluated on the right hand side of it. It so happens that the expression being evaluated is the addition operator, so the addition of the two cv::Mat
is performed which then creates a new matrix on the left-hand side of the expression.
The moral of this story is to search through the documentation to find your answer. That's how I found out about it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.