Programming Language: C++ (Cpp)

Namespace/Package Name: cv

Class/Type: Mat

Method/Function: inv

Examples at hotexamples.com: 30

The Mat.inv() function is a part of OpenCV library in C++. It is used to calculate the inverse matrix of the given matrix. The inverse of a matrix is a matrix that when multiplied with the original matrix gives the identity matrix.

**Example 1:**

In this example, we created a 2x2 matrix named matrix1 and initialized it with some values. Then we created another matrix named matrix2 and used the invert function to calculate the inverse of matrix1 and store it in matrix2. Lastly, we printed the contents of matrix2 to the console.

**Example 2:**

cv::Mat matrix1 = (cv::Mat_(2, 2) << 1, 2, 3, 4); cv::Mat matrix2; cv::invert(matrix1, matrix2); std::cout << matrix2 << std::endl;

In this example, we created a 2x2 matrix named matrix1 and initialized it with some values. Then we created another matrix named matrix2 and used the invert function to calculate the inverse of matrix1 and store it in matrix2. Lastly, we printed the contents of matrix2 to the console.

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;

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods