gpt4 book ai didi

c++ - 工业相机无法识别 OpenCV Aruco 标记

转载 作者:太空宇宙 更新时间:2023-11-03 22:46:35 29 4
gpt4 key购买 nike

我正致力于在工业自动化技术 C2 相机上检测 ARUCO 标记,这些相机旨在检测三角测量扫描仪中的激光条纹,但它们也可以捕获图像。我的问题是,除了我之前提到的相机之外,无论我使用什么相机,都会检测到相同的标记。我的代码的最小工作示例如下:

#include <opencv2/highgui.hpp>
#include <opencv2/aruco/charuco.hpp>

using namespace std;
using namespace cv;

int main(int argc, char *argv[]) {

int squaresX = 10;
int squaresY = 7;
float squareLength = 28;
float markerLength = 19;
int dictionaryId = 6;
bool showRejected = true;
bool refindStrategy = true;

Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();

Ptr<aruco::Dictionary> dictionary =
aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));

// create charuco board object
Ptr<aruco::CharucoBoard> charucoboard =
aruco::CharucoBoard::create(squaresX, squaresY, squareLength, markerLength, dictionary);
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>();

Mat image = imread("C:\\Users\\Piotrek\\Desktop\\calib\\022.jpg"), imageCopy;

vector< int > markerIds, charucoIds;
vector< vector< Point2f > > markerCorners, rejectedMarkers;
vector< Point2f > charucoCorners;

// detect markers
aruco::detectMarkers(image, dictionary, markerCorners, markerIds, detectorParams,
rejectedMarkers);

image.copyTo(imageCopy);
if (markerIds.size() > 0) {
aruco::drawDetectedMarkers(imageCopy, markerCorners);
}

if (showRejected && rejectedMarkers.size() > 0)
aruco::drawDetectedMarkers(imageCopy, rejectedMarkers, noArray(), Scalar(100, 0, 255));

//display results
imshow("out", imageCopy);
waitKey(0);

return 0;
}

Sample image from camera:

问题是标记被检测到但由于未知原因被拒绝:

Rejected markers

我使用 OpenCV 3.1。

最佳答案

问题解决了。我必须翻转图像,现在可以完美地检测到标记。

关于c++ - 工业相机无法识别 OpenCV Aruco 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46194768/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com