gpt4 book ai didi

opencv - OpenCV fisheye::projectpoints断言失败

转载 作者:行者123 更新时间:2023-12-02 17:23:50 26 4
gpt4 key购买 nike

我想在图像上投影一个点(-1450,-1660)
我正在使用opencv 4.0.1 c++
我有相机矩阵和失真系数
我的代码是

    vector <Point3f> inputpoints;
Point3f myPoint;
myPoint.x = -1450;
myPoint.y = -1660;
myPoint.z = 0;
inputpoints.push_back(myPoint);

vector<Point2f> outputpoints;

vector<Point3f> tvec;
tvec.push_back(Point3f(0, 0, 0));

vector<Point3f> rvec;
rvec.push_back(Point3f(0, 0, 0));

double mydata[9] = { 3.3202343554882879e+02, 1., 6.4337059696010670e+02, 0, 3.3196938477610536e+02, 5.3844814394773562e+02, 0., 0., 1. };

Mat mycameraMatrix = Mat(3, 3, CV_64F, mydata);

double mydata2[4] = { -1.1129472191078109e-03, 4.9443845791693870e-02,
-7.2244333582166609e-03, -1.7309984187889034e-03 };

Mat mydiscoff = Mat{ 4,1, CV_64F ,mydata2 };
Mat newCamMat1= Mat(3, 3, CV_64F);

cv::fisheye::projectPoints(inputpoints, rvec, tvec, mycameraMatrix, mydiscoff, outputpoints);

当我运行程序时,出现此异常
OpenCV(4.0.1) Error: Assertion failed (mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0)) in cv::debug_build_guard::_OutputArray::create, file c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\matrix_wrap.cpp, line 1395

我将相机矩阵的类型和失真系数更改为CV_32f,但仍然遇到相同的错误,我是openCV的初学者..所以有人可以告诉我是什么导致了此异常吗?
我知道rvec应该是3 * 3,但是我只是跟随别人写的代码,可以这样写

最佳答案

好的,问题是projectpoints和fisheye::projectpoints在参数顺序上是不同的..so所以我把属于projectpoints的顺序

关于opencv - OpenCV fisheye::projectpoints断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60696387/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com