我正在尝试校正具有已知大小的元素的图像。鉴于此图像:
我可以使用aruco:: estimatePoseBoard
它返回旋转和平移向量。有没有一种方法可以使用这些信息来校正与标记板在同一平面上的所有内容?(不幸的是,我的线性代数充其量是基本的。)
我知道如何校正标记板。我想要做的是将其他物体(在这种情况下为云形物体)与标记板在同一平面上进行倾斜校正。我正在尝试确定这是否可行,如果可以的话,怎么做。我已经可以在要校正倾斜的对象周围放置四个标记,并使用检测到的角作为输入getPerspectiveTransform
以及它们之间的已知距离。但是对于我们的实际应用程序,用户可能很难准确放置标记。如果他们可以在框架中放置单个标记板,并使软件使其他对象倾斜,那将容易得多。
我一直坚持这样的假设,到的呼叫中的目的地getPerspectiveTransform
必须是输出图像的角点(就像Humam的建议一样)。当我意识到目的地可能在输出图像中的某个地方时,我便有了答案。
float boardX = 1240;
float boardY = 1570;
float boardWidth = 1730;
float boardHeight = 1400;
vector<Point2f> destinationCorners;
destinationCorners(Point2f(boardX+boardWidth, boardY));
destinationCorners(Point2f(boardX+boardWidth, boardY+boardHeight));
destinationCorners(Point2f(boardX, boardY+boardHeight));
destinationCorners(Point2f(boardX, boardY));
Mat h = getPerspectiveTransform(detectedCorners, destinationCorners);
Mat bigImage(image.size() * 3, image.type(), Scalar(0, 50, 50));
warpPerspective(image, bigImage, h, bigImage.size());
这样可以固定电路板及其所在平面的所有角度。(木板的波纹是由于纸张未在原始照片中平放而造成的。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句