The cv::Mat is a matrix data structure used in OpenCV library to store and manipulate image data. The reshape function is used to change the shape and size of matrices. It reshapes a matrix to a new size without changing any data, but simply reinterpreting the matrix header.
Here are some examples of how to use the cv::Mat reshape function in C++:
Example 1:
cv::Mat img = cv::imread("image.png");
cv::Mat img_reshape = img.reshape(0, 1);
This example reads an image into a cv::Mat object and then uses the reshape function to convert the matrix into a row vector.
Example 2:
cv::Mat mat(2, 4, CV_32FC1);
cv::Mat mat_reshape = mat.reshape(0, 1);
This example creates a 2x4 matrix of float values, and then reshapes it into a row vector.
Package library : OpenCV (cv::Mat)
C++ (Cpp) Mat::reshape - 29 examples found. These are the top rated real world C++ (Cpp) examples of cv::Mat::reshape extracted from open source projects. You can rate examples to help us improve the quality of examples.