小编Vla*_*lad的帖子

undistortPoints()无法处理镜头扭曲

我使用openCV函数projectPoints()来旋转,平移和投影一组3D点和solvePnp()来找到这个旋转和平移.当镜头失真系数全为零但是否则失败时,这很有效.完全失败只需要很少的失真:

 distCoeffs << 0.0, 0.01, 0.0, 0.0, 0.0;  
Run Code Online (Sandbox Code Playgroud)

代码如下:

#include <iostream>
#include "opencv.hpp"
using namespace std;
using namespace cv;
#define DEG2RAD (3.1415293/180.0)
#define RAD2DEG (1.0/DEG2RAD)

int main() {
    const int npoints = 10; // number of points

    // extrinsic
    const Point3f tvec(10, 20, 30);
    Point3f rvec(3, 5, 7);
    cout << "Finding extrinsic parameters (PnP)" << endl;
    cout<<"Test transformations: ";
    cout<<"Rotation: "<<rvec<<"; translation: "<<tvec<<endl;
    rvec*=DEG2RAD;

    // intrinsic
    Mat_ <double>cameraMatrix(3, 3);
    cameraMatrix << 300., 0., 200., 0, 300., 100., 0., 0., 1.; …
Run Code Online (Sandbox Code Playgroud)

opencv image-processing computer-vision

8
推荐指数
1
解决办法
3678
查看次数

标签 统计

computer-vision ×1

image-processing ×1

opencv ×1