![](/img/trans.png)
[英]error: invalid initialization of non-const reference of type 'cv::Mat&'
[英]Why does InputOutputArray take a const Mat& reference in the constructor?
InputOutputArray的构造函数在构造函数中使用const cv :: Mat&,这意味着编译时不会出现任何警告或错误。
为什么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独有。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.