Ask Your Question

Revision history [back]

Why does InputOutputArray take a const cv::Mat& reference for creation?

The constructor for an InputOutputArray takes a const cv::Mat& reference in the constructor. I'm wondering why this call doesn't fail:

void this_shouldnt_compile(const cv::Mat& mat) {
//const, so the header should not be modifiable (I realize the data is)
      putText(mat, "some text", cvPoint(0,10), 
                   FONT_HERSHEY_COMPLEX_SMALL, 0.8, 
                   cvScalar({0,255,0}), 1, CV_AA);
}
click to hide/show revision 2
None

updated 2018-02-02 14:26:24 -0600

berak gravatar image

Why does InputOutputArray take a const cv::Mat& reference for creation?

The constructor for an InputOutputArray takes a const cv::Mat& reference in the constructor. I'm wondering why this call doesn't fail:

void this_shouldnt_compile(const cv::Mat& mat) {
//const, so the header should not be modifiable (I realize the data is)
      putText(mat, "some text", cvPoint(0,10), 
                   FONT_HERSHEY_COMPLEX_SMALL, 0.8, 
                   cvScalar({0,255,0}), Scalar({0,255,0}), 1, CV_AA);
}
click to hide/show revision 3
None

updated 2018-02-02 14:26:49 -0600

berak gravatar image

Why does InputOutputArray take a const cv::Mat& reference for creation?

The constructor for an InputOutputArray takes a const cv::Mat& reference in the constructor. I'm wondering why this call doesn't fail:

void this_shouldnt_compile(const cv::Mat& mat) {
//const, so the header should not be modifiable (I realize the data is)
      putText(mat, "some text", cvPoint(0,10), 
                   FONT_HERSHEY_COMPLEX_SMALL, 0.8, 
                   Scalar({0,255,0}), Scalar(0,255,0), 1, CV_AA);
}

Why does InputOutputArray take a const cv::Mat& reference for creation?

The constructor for an InputOutputArray takes a const cv::Mat& reference in the constructor. I'm wondering why this call doesn't fail:

void this_shouldnt_compile(const cv::Mat& mat) {
//const, so the header should not be modifiable (I realize the data is)
      putText(mat, "some text", cvPoint(0,10), 
                   FONT_HERSHEY_COMPLEX_SMALL, 0.8, 
                   Scalar(0,255,0), 1, CV_AA);
}