我可以根据旋转/平移向量创建变换矩阵吗?

SSt*_*eve 6 c++ opencv matrix aruco

我正在尝试去掉具有已知大小元素的图像.鉴于此图片:

来源图片

我可以使用aruco:: estimatePoseBoard它返回旋转和平移向量.有没有办法利用这些信息去除与标记板在同一平面上的所有东西?(不幸的是,我的线性代数充其量是最基本的.)

澄清

我知道如何去除标记板.我想要做的是在与标记板相同的平面上去除其他东西(在这种情况下,云形物体).我正在试图确定这是否可行,如果是,那该怎么做.我已经可以在我想要偏斜的物体周围放置四个标记,并使用检测到的角作为输入getPerspectiveTransform以及它们之间的已知距离.但对于我们的实际应用,用户可能难以准确地放置标记.如果他们可以在框架中放置单个标记板并使软件偏移其他对象,则会容易得多.

SSt*_*eve 1

我坚持这样的假设:调用中的目标点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());
Run Code Online (Sandbox Code Playgroud)

这固定了棋盘及其平面上所有物体的视角。(纸板的波纹是由于原始照片中的纸张没有平放所致。)

矫正透视