7.c++的矩阵运算

代码如下:

#include<opencv2/opencv.hpp>
#include<opencv2/imgcodecs.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<iostream>
#include <string>
#include <cmath>
//#include "check.h"
using namespace cv;
using namespace std;



//角度值转换为弧度制
double Angular_radians(double angle) {

	double M_PI = 3.1415926;
	double radians = angle * M_PI / 180.0;
	return radians;
}


int main() {

	//1.输入角度值
	double angle = -3.0;
	double angles = Angular_radians(angle);//角度转为弧度的函数
	double results = sin(angles);//求正弦值
	double resultc = cos(angles);//求余弦值
	//cout<< results<<"    " << resultc << endl;

	//2.初始化矩阵(获得旋转矩阵),并求逆矩阵
	Mat K = (Mat_<double>(3, 3)<< resultc,0,(-1)* results,0,1,0, results,0, resultc);
	//Mat K1 = (Mat_<double>(3, 3) << 1, 0, 0, 0, resultc, (-1) * results,0, results, resultc);
	//Mat K = (Mat_<double>(3, 3) << 0, 0,  1, 0, 1, 0, 1, 1, 1);
	Mat meinv = K.inv();//求逆矩阵
	//cout<< "逆矩阵:" << endl << K << endl;
	 
	//cout << K << endl;

	//3.输入一组三维的坐标(x,y,z)
	Mat X = (Mat_<double>(3, 1) << 500,0.0,1000);
	//cout << X << endl;

	//4.旋转矩阵与三维坐标相乘
	Mat KX = K *X;
	cout << KX << endl;

	//mians();
	
	return 0;
}




void ImageThreshold(String str) {
	Mat image = imread(str);
	Mat binary;
	//cvtColor(image, binary, COLOR_BGR2GRAY);
	imshow("test_opencv_srtup", image);
	waitKey(0);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值