【问题标题】:Finding perspective transformation between two planes寻找两个平面之间的透视变换
【发布时间】:2013-09-06 08:11:05
【问题描述】:

我有一个从多个图像创建的点云。我从中提取了一个平面,它也在 3d 坐标系中,这意味着我有那个平面的平面方程。但在所有原始图像中,平面都没有正交视图,即平面不平行于观察平面。但是,由于我有平面的 3d 云,我想将它投影到 XY 平面上,即我想让平面平行于观察平面并从中创建图像。在 C++/OpenCV 中实现它的算法或函数是什么?

【问题讨论】:

    标签: opencv perspectivecamera


    【解决方案1】:

    我不确定你到底想做什么,但这些可能会对你有所帮助,我是用棋盘做的:

    std::vector<cv::Point2f> not_a_rect_shape;  // In this vector you should save the x,y coordinates of your 3D rect  
    
    // the not_a_rect_shapecoordinates are from you source frame 
    
    
    
    // Define the destination image
                quad = cv::Mat::zeros(300, 220, CV_8UC3);  // the size is important, it depends on your application, I have to say that 300x220 isn't always the right one. you have to give more infomations!! 
    
    
    // these will be the parallel plane vector of point 
    quad_pts.push_back(cv::Point2f(0, 0));
                quad_pts.push_back(cv::Point2f(quad.cols, 0));
                quad_pts.push_back(cv::Point2f(quad.cols, quad.rows));
                quad_pts.push_back(cv::Point2f(0,quad.rows));
    
    
    transformationMatrix= cv::getPerspectiveTransform(not_a_rect_shape, quad_pts);// this is you transformation matirx 
    
    cv::warpPerspective(src, quad, transformationMatrix,quad.size(),CV_INTER_LINEAR,cv::BORDER_ISOLATED); // the flags could change 
    

    现在四帧应该是您正在寻找的! 希望对你有帮助

    【讨论】:

    • 嗯,当我实际拥有已知矩形形状的图像(即扑克牌)时,我使用了它。从该图像中,我可以得到准确的 cv::Point2fs。但是,我现在拥有的是图像的 3d 世界坐标,也有负 (x,y)s。所以,首先我必须得到平面平行于视图平面的二维图像点(我事先没有这样的图像)。所以,我想要来自 3d 世界坐标的 2d 图像坐标(事先不存在)。
    • 简单地说,我想将 3d 世界坐标投影到 2d 图像坐标中,在那里我将获得对象
    • 你可以上传你的图片以便我更好地理解它
    • 嗯,根据你的建议,我找到了答案。虽然,我拥有的对象不是一个完美的矩形,但我计算了它周围的凸包,然后我再次手动计算了它周围的最小四边形。然后,我按照您上面所说的方式使用了四个顶点。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-12
    • 2018-08-31
    相关资源
    最近更新 更多