簡體   English   中英

我可以根據旋轉/平移向量創建變換矩陣嗎?

[英]Can I create a transformation matrix from rotation/translation vectors?

我正在嘗試去掉具有已知大小元素的圖像。 鑒於此圖片:

來源圖片

我可以使用aruco:: estimatePoseBoard返回旋轉和平移向量。 有沒有辦法利用這些信息去除與標記板在同一平面上的所有東西? (不幸的是,我的線性代數充其量是最基本的。)

澄清

我知道如何去除標記板。 我想要做的是在與標記板相同的平面上去除其他東西(在這種情況下,雲形物體)。 我正在試圖確定這是否可行,如果是,那該怎么做。 我已經可以在我想要偏移的對象周圍放置四個標記,並使用檢測到的角作為getPerspectiveTransform輸入以及它們之間的已知距離。 但對於我們的實際應用,用戶可能難以准確地放置標記。 如果他們可以在框架中放置單個標記板並使軟件偏移其他對象,則會容易得多。

因為你標記了OpenCV:從圖像我可以看到你已經檢測到所有黑盒子的角落。 因此,只需以某種方式獲得最多的邊界: 在此輸入圖像描述

那就是這樣的:

std::vector<cv::Point2f> src_points={/*Fill your 4 corners here*/};
std::vector<cv::Point2f> dst_points={cv:Point2f(0,0), cv::Point2f(width,0), cv::Point2f(width,height),cv::Point2f(0,height)}; 
auto H=v::getPerspectiveTransform(src_points,dst_points);
cv::Mat copped_image;
cv::warpPerspective(full_image,copped_image,H,cv::Size(width,height));

我堅持認為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());

這固定了電路板的視角和平面內的一切。 (電路板的波紋是由於紙張沒有平放在原始照片中。)

糾正的觀點

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM