cv::Mat inputMatrix = cv::Mat::ones(3, 2, CV_8UC1); // 3 rows and 2 columns filled with ones cv::Mat outputMatrix = inputMatrix.reshape(1, 6); // Reshape the matrix to have 6 rows and 1 column
cv::Mat inputMatrix = cv::Mat::ones(2, 2, CV_8UC3); // 2 rows, 2 columns and 3 channels filled with ones cv::Mat outputMatrix = inputMatrix.reshape(1, 12); // Reshape the matrix to have 1 row and 12 columnsIn this example, the input matrix has 2 rows, 2 columns, and 3 channels, and the output matrix is reshaped to have 1 row and 12 columns. The reshape function is called on the input matrix with 1 row and 12 columns specified as the output matrix size. Package library: OpenCV.