I'm using OpenCV 3.2.
Let's suppose I have a 3 x 1
Mat:
cv::Mat foo = (cv::Mat_<float>(3,1) << 0, 1, 2);
Now I want to concatenate a single value to foo
, and then having a resulting 4 x 1
Mat.
A simple solution would be:
cv::Mat bar = (cv::Mat_<float>(4,1) << foo.at<float>(0,0),
foo.at<float>(1,0),
foo.at<float>(2,0),
3);
But this solution overfits to the problem dimensions. Of course, I can generalize it by looping all the values of an n x 1
Mat, resulting in an n+1 x 1
.
What I'm looking for is a smarter solution that takes advantage of OpenCV syntax, and directly returns the concatenation of a single-column Mat and a single value.