1. 程式人生 > 其它 >opencv-invert求逆矩陣

opencv-invert求逆矩陣

#include<opencv2/opencv.hpp>
#include<iostream>
#include  <vector>


int main(int argc, char** argv) {

    cv::Mat A = (cv::Mat_<double>(3, 3) << 2, -10, 5, -11, 10, 20, 30, 88, 1);
    std::cerr << A << std::endl<< std::endl;
    cv::Mat B;
    cv::invert(A, B);  
//求逆矩陣 //引數1:輸入,浮點型(32位或者64位)的M×N的矩陣,當引數3的使用方法 // 為DECOMP_CHOLESKY DECOMP_LU DECOMP_EIG時函式功能為求逆,此時需保證M=N //引數2:輸出,與輸入矩陣型別一致的N×M的矩陣 //引數3:提供4種可選擇的方法: // DECOMP_CHOLESKY(基於CHOLESKY分解的方法) // DECOMP_LU(基於LU分解的方法) // DECOMP_EIG(基於特徵值分解的方法) // DECOMP_SVD(基於奇異值分解的方法)
std::cerr << B << std::endl << std::endl; cv::Mat C; C = A * B; std::cerr << C << std::endl << std::endl; cv::waitKey(0); return 0; }