gpt4 book ai didi

java - 断言失败。 convertPointsFromHomogenous

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:57 26 4
gpt4 key购买 nike

A 在执行我的代码时出现以下错误:

Caused by: CvException [org.opencv.core.CvException: cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/calib3d/src/fundam.cpp:1152: error: (-215) npoints >= 0 && (src.depth() == CV_32F || src.depth() == CV_32S) in function void cv::convertPointsFromHomogeneous(cv::InputArray, cv::OutputArray)

这是我使用的代码:

    Mat res = new Mat(); // Result mat for triangulation

Mat P1 = new Mat(3,4,CvType.CV_32F);
double[] diagVal = {1,0,0,0,
0,1,0,0,
0,0,1,0};
P1.put(0, 0, diagVal);



int[] max = new int[4];
for(int i = 0; i < max.length; i++)
max[i] = 0;

Mat P2 = buildCameraMatrix(R1, T1);
Calib3d.triangulatePoints(P1, P2, objLeft, objRight, res);

TriangulatePoints 产生 CV_32F 类型的 (914,4) 垫(res.type() == 5 为真)。

我做错了什么?

最佳答案

我改用下面的转换函数:

private Mat convertPointsFromHomogeneous(Mat src) {
Mat ret = new Mat(3, src.cols(), src.type());
double[] data = new double[4];
for (int i = 0; i < src.cols(); i++) {
src.col(i).get(0, 0, data);
ret.col(i).put(0, 0, data[0] / data[3], data[1] / data[3], data[2] / data[3]);
}
return ret;
}

关于java - 断言失败。 convertPointsFromHomogenous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23290000/

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