Reputation: 103
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:
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.
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.
Upvotes: 2
Views: 4934
Reputation: 249
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:
[0, 0], [1, 1], [1, 1], [1, 1]
Upvotes: 2