In OpenCV, I can add two matrices of the same type using the +
operator, like so:
cv::Mat mat3 = mat1 + mat2;
When I try to add two matrices of different types in this way, I get an error at runtime, which says that "When the input arrays in add/subtract/multiply/divide functions have different types, the output array type must be explicitly specified".
How should I go about specifying the output type for operations like this, when applying them to matrices of different types?
"How should I go about specifying the output type"
unfortunately, the overloaded c++ operators won't let you specify that.
use code like:
cv::Mat mat3;
add(mat1, mat2, mat3, Mat(), CV_32F); // the additional Mat() is an empty Mask
as always, also see docs
Declare the size of Mat C first. Hopefully this can help
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.