What causes this error?
OpenCV: terminate handler is called!The last OpenCV error is : OpenCV(4.0.1) Error : Assertion failed(m.dims <= 2) in cv::F
This error is on this line:
cout << obj << endl;
OpenCV, will only try to output 2D images (maybe 3D is too hard if it has more than 1 channel).
A possible workaround is:
int ordo[3] = { 2, 2, 2 };
cv::Mat obj(2, 2, CV_8UC2, cv::Scalar::all(0));
std::cout << obj << std::endl;
Which is allowed and prints:
[ 0, 0, 0, 0;
0, 0, 0, 0]
First 2 numbers is the first "pixel". You can easily access the x,y,z coordinate doing something like:
// obj.at<cv::Vec2b>(y, x)[z] = uchar value
obj.at<cv::Vec2b>(1, 0)[0] = 255;
Which will print out:
[ 0, 0, 0, 0;
255, 0, 0, 0]
Another possibility is to create a self made printing function which takes the matrix and draws it.