目前,我正在以这种方式在函数中乘以4x4的垫子和Point3f,

有没有更有效的方法来进行这种乘法?

注意:我还需要将结果转换回cv::Point3f

谢谢

    cv::Mat cam_to_world(4, 4, CV_32FC1);
    ///....
    cv::Mat pointA_cam(4, 1, CV_32FC1);
    pointA_cam.at<float>(0, 0) = OAvec_cam.x;
    pointA_cam.at<float>(1, 0) = OAvec_cam.y;
    pointA_cam.at<float>(2, 0) = OAvec_cam.z;
    pointA_cam.at<float>(3, 0) = 1.0;
    cv::Point3f point_A_wld;
    cv::Mat point_A_world = cam_to_world*pointA_cam;
    point_A_wld.x = point_A_world.at<float>(0, 0);
    point_A_wld.y = point_A_world.at<float>(1, 0);
    point_A_wld.z = point_A_world.at<float>(2, 0);

最佳答案

这就是我所拥有的,如果有人有更紧凑的解决方案,它将有所帮助

cv::Mat cam_to_world(4, 4, CV_32FC1);
cv::Mat pointA_cam = cam_to_world*Mat(cv::Vec4f(OAvec_cam.x,OAvec_cam.y,OAvec_cam.z,1.0));
cv::Point3f point_A_wld(cam_to_world.at<float>(0,0),cam_to_world.at<float>(1,0),cam_to_world.at<float>(2,0));

关于c++ - OpenCv,将4x4 cv::Mat与cv::Point3f相乘的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49430681/

10-15 04:26