#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
//#include <cmath>

#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    Mat mat_src = Mat::eye(3, 4, CV_32F);

    cout << "mat_src :" << endl;
    cout << mat_src    << endl;

    cout << endl;
    cout << "Rows : " << mat_src.rows << endl;
    cout << "Cols : " << mat_src.cols << endl;
    mat_src.at<float>(0, 2) = 9000000; 
    mat_src.at<float>(2, 0) = 4000000;
   Mat B;
   sqrt(mat_src,B);
   cout << "B " << endl << B << endl;
    cout << endl;
    cout << "mat_src :" << endl;
    cout << mat_src    << endl;
	int k = mat_src.at<float>(0, 2);
	cout << " k = " << k <<endl;

    return 0;
}

之前 sqrt 运算写成 Mat B = sqrt ( mat_str, B )结果报错

注意 : sqrt( A, B)的解释为将矩阵A开平方结果放到矩阵B中,不需要重新赋值。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐