Plane construction from 3D Points in OpenCV

前端 未结 2 664
梦毁少年i
梦毁少年i 2021-01-16 21:29

I would like to construct a plane from a list of 3D points in OpenCV. I would like to obtain the result by finding the four parameters in the following form: Ax+By+Cz+

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-16 22:07

    Answer by leveraging OpenCV

    If you want to have equation solved by 3 points, just like follows:

    ax + by + cz = 1

    Example

    you have three points: cv::Point3f p1, p2 and p3, and here is the code:

    cv::Matx33f M(p1.x, p1.y, p1.z,
                  p2.x, p2.y, p2.z,
                  p3.x, p3.y, p3.z);
    cv::Vec3f d(1, 1, 1);
    cv::Vec3f coef = M.inv() * d;
    

    Then, a, b, c are coef(0), coef(1), coef(2) sequentially.

提交回复
热议问题