cv::Mat P_c = R.inv() * (N_c - t);
时间: 2023-07-15 15:10:48 浏览: 45
这段代码是用于计算点的世界坐标,其中R是旋转矩阵,t是平移向量,N_c是相机坐标系下的点的坐标,P_c是世界坐标系下的点的坐标。
首先,R.inv()是旋转矩阵R的逆矩阵,这是因为在相机坐标系下的点坐标是通过将世界坐标系下的点坐标进行旋转和平移得到的。因此,如果要将相机坐标系下的点坐标转换为世界坐标系下的点坐标,需要将其先平移回到原点,再通过旋转矩阵的逆矩阵进行旋转。
接着,对相机坐标系下的点坐标进行平移变换,即将其减去平移向量t,得到相对于相机坐标系原点的坐标。
最后,通过R.inv() * (N_c - t)计算出点的世界坐标,即先将其从相机坐标系下转换到世界坐标系下,再通过旋转和平移得到其在世界坐标系下的坐标。
相关问题
cv::Mat N_c = K.inv() * uv;
这段代码使用了OpenCV库中的Mat类和inv函数,其作用是计算相机坐标系下的点坐标。具体来说,N_c表示相机坐标系下的点坐标,K表示相机内参矩阵,uv表示图像平面上的点坐标。首先,K.inv()表示K的逆矩阵,然后将其与uv相乘就可以得到N_c。需要注意的是,uv需要转换成齐次坐标形式,即在末尾添加一个1,才能与K.inv()相乘。
std::vector<cv::Mat> channels(2); cv::Mat undistorted_points_temp = cv::Mat::ones(3, rows * cols, CV_64FC1); undistorted_points_temp = K.inv() * undistorted_points; cv::Mat undistorted_mat = cv::Mat::zeros(1, rows * cols, CV_64FC2); cv::s
std::vector<cv::Mat> channels(2);
cv::Mat undistorted_points_temp = cv::Mat::ones(3, rows * cols, CV_64FC1);
undistorted_points_temp = K.inv() * undistorted_points;
cv::Mat undistorted_mat = cv::Mat::zeros(1, rows * cols, CV_64FC2);
cv::split(undistorted_points_temp, channels);
cv::merge(channels, undistorted_mat);
以上代码实现了以下功能:
1. 定义了一个名为 channels 的 cv::Mat 类型的 vector,其大小为 2。
2. 创建了一个 3 行 rows*cols 列的 CV_64FC1 类型的矩阵 undistorted_points_temp,并将其所有元素初始化为 1。
3. 通过 K 的逆矩阵与 undistorted_points 相乘,得到一个新的矩阵 undistorted_points_temp。
4. 创建了一行 rows*cols 列的 CV_64FC2 类型的矩阵 undistorted_mat,并将其所有元素初始化为 0。
5. 将 undistorted_points_temp 矩阵拆分成多个通道,存储在名为 channels 的 vector 中。
6. 将 channels 中的通道合并成一个矩阵 undistorted_mat。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)