I would like to cast rays from the camera and check the intersected points on the table, which is I assume at (0,0,0) with normal (0,1,0).. so for example I choose a point on a table by mouse, then I cast rays from the origin (0,0,0) to the plane, but the problem is I get a false point, that is not on the plane but still positive.
here is a picture to show what I'm doing
//Generate a camera intrinsic matrix
Mat K = (Mat_<double>(3, 3)
<< 1600, 0,src.cols/2,
0, 1600,src.rows/2,
0, 0, 1);
Mat invCameraIntrinsics = K.inv();
cout << "inv" << invCameraIntrinsics;
std::vector<cv::Vec3d> pointsTransformed3D;
std::vector<cv::Vec3d> points3D;
for (int i = 0; i < corners.size(); i++)
{
cv::Vec3d pt;
pt[2] = 1.0f;
pt[0] = (corners[i].x );
pt[1] = (corners[i].y );
points3D.push_back(pt);
}
cv::transform(points3D, pointsTransformed3D, invCameraIntrinsics);
std::vector<Ray> rays;
for (int i = 0; i < pointsTransformed3D.size(); i++)
{
Ray ray;
ray.origin = Vec3f(0, 0, 0);
ray.direction = Vec3f(pointsTransformed3D[i][0], pointsTransformed3D[i][1], pointsTransformed3D[i][2]);
rays.push_back(ray);
}
std::vector<cv::Vec3f> contacts;
for (int i = 0; i < pointsTransformed3D.size(); i++)
{
Vec3f pt(pointsTransforme/