[英]How to convert homogeneous points to inhomogeneous points using OpenCV (in C++)
I want to convert points. 我想转换点。 At the moment my code looks like this:
目前,我的代码如下所示:
std::vector<cv::Point3d> homCamPoints(4);
// some assignments to homCamPoints
std::vector<cv::Point2d> inhomCamPoints(4);
convertPointsFromHomogeneous(homCamPoints, inhomCamPoints);
But I always get an exception error concerning a memory position. 但是我总是会收到关于内存位置的异常错误。 So, I assume that my input type is wrong, although the OpenCV documentation is saying:
因此,尽管OpenCV文档在说:
That sounds like my input types are ok. 听起来我的输入类型还可以。 However in the internet I only found examples using
cv::Mat
types, but due to time concerns I would like to avoid the restructuring at that stage. 但是在互联网上,我仅找到使用
cv::Mat
类型的示例,但由于时间问题,我希望避免在此阶段进行重组。
I run my code in debugging mode. 我在调试模式下运行代码。 When calling the function the parameters really seem to be fine.
调用该函数时,参数似乎确实不错。 The error then occures right after entering the function, but I can't figure it out exactly, as I can't get into the function code itself.
然后在进入函数后立即发生错误,但是由于无法进入函数代码本身,因此我无法准确地找出它。 Does anybody have an idea why this is not working?
有人知道为什么这不起作用吗? Thanks.
谢谢。
I tried this: 我尝试了这个:
std::vector<cv::Point3d> homCamPoints(4, cv::Point3d(0,0,0));
homCamPoints[0] = cv::Point3d(0,0,0);
homCamPoints[1] = cv::Point3d(1,1,1);
homCamPoints[2] = cv::Point3d(-1,-1,-1);
homCamPoints[3] = cv::Point3d(2,2,2);
std::vector<cv::Point2d> inhomCamPoints(4);
cv::convertPointsFromHomogeneous(homCamPoints, inhomCamPoints);
and it works without exception. 它毫无例外地工作。 Maybe your Problem is somewhere else in your code.
也许您的问题在代码中的其他地方。 inhomCamPoints are:
inhomCamPoints是:
[0, 0], [1, 1], [1, 1], [1, 1] [0,0],[1,1],[1,1],[1,1]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.