cv::Mat matrix1 = (cv::Mat_(2, 2) << 1, 2, 3, 4); cv::Mat matrix2; cv::invert(matrix1, matrix2); std::cout << matrix2 << std::endl;
cv::Mat matrix3 = (cv::Mat_In this example, we created a 3x3 matrix named matrix3 and initialized it with some values. Then we used the inv function directly on matrix3 to calculate its inverse and store it in matrix4. Lastly, we printed the contents of matrix4 to the console. Both examples show how to use the Mat.inv() function in OpenCV C++.(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9); cv::Mat matrix4 = matrix3.inv(); std::cout << matrix4 << std::endl;