The constructor for an InputOutputArray takes a const cv::Mat&in the constructor, meaning this compiles without any warnings or errors.
Why does the InputOutputArray take a const Mat reference. I understand why the InputArray takes a const reference, but an OutputArray really should not
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);
}
So constructor for cv::_InputOutputArray::_InputOutputArray (const Mat & m)
indeed exists
By looking at https://github.com/opencv/opencv/issues/7298 it seems that
"Access "locks" to underlying data are not available neither in compile time, nor during runtime. It is developer responsibility to control this"
"... may be there is no real solution (even with c++17)"
"Issues such as this are well known in C++, and are not unique to OpenCV."