为什么 InputOutputArray 在构造函数中采用 const Mat& 引用?
Why does InputOutputArray take a const Mat& reference in the constructor?
InputOutputArray 的构造函数采用 const cv::Mat&in 构造函数,这意味着编译时没有任何警告或错误。
为什么 InputOutputArray 采用 const Mat 引用。我理解为什么 InputArray 采用 const 引用,但 OutputArray 真的不应该
void this_shouldnt_compile(const cv::Mat& mat) {
// const, so the header should not be modifiable
// but the data is
putText(mat, "some text", cvPoint(0,10),
FONT_HERSHEY_COMPLEX_SMALL, 0.8,
cvScalar({0,255,0}), 1, CV_AA);
}
所以cv::_InputOutputArray::_InputOutputArray (const Mat & m)
的构造函数确实存在
通过查看 https://github.com/opencv/opencv/issues/7298 似乎
-
对基础数据的"访问锁"在编译时和运行时都不可用。控制这一点是开发人员的责任">
-
"...可能没有真正的解决方案(即使使用 C++17(">
-
"像这样的问题在C++是众所周知的,并不是OpenCV独有的。