我有cameraMatrix
和distCoeff
不需要的图像或点矢量.现在我想扭曲它们.
Opencv有可能吗?我记得我在stackoverflow中读到了一些关于它但现在找不到的东西.
编辑:我找到了在这个答案中做到这一点的方法.它也在opencv开发人员专区(本期)
但我的结果不正确.或多或少存在2-4像素的误差.可能我的代码有问题,因为在答案中我把单元测试中的一切看起来都很好.也许从浮动到双重的类型转换,或者我看不到的其他东西.
这是我的测试用例:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
void distortPoints(const std::vector<cv::Point2d> & src, std::vector<cv::Point2d> & dst,
const cv::Mat & cameraMatrix, const cv::Mat & distorsionMatrix)
{
dst.clear();
double fx = cameraMatrix.at<double>(0,0);
double fy = cameraMatrix.at<double>(1,1);
double ux = cameraMatrix.at<double>(0,2);
double uy = cameraMatrix.at<double>(1,2);
double k1 = distorsionMatrix.at<double>(0, 0);
double k2 = distorsionMatrix.at<double>(0, 1);
double p1 = distorsionMatrix.at<double>(0, 2);
double p2 = distorsionMatrix.at<double>(0, 3);
double …
Run Code Online (Sandbox Code Playgroud) 通常,投影矩阵P的定义是3x4矩阵,其将点从世界坐标投影到图像/像素坐标.投影矩阵可以分为:
投影矩阵是则P = ķ*Ť.
OpenCV的stereoRectify的以下输入有哪些明确的定义: