- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 ArUco 标记来校正透视图并计算图像的大小。在此图像中,我知道标记外边缘之间的确切距离,并使用它来计算黑色矩形的大小。
我的问题是 aruco::detectMarkers
并不总能识别标记的真实边缘(如细节图所示)。当我根据标记的角校正透视时,它会导致失真,影响图像中对象的大小计算。
有没有办法提高aruco::detectMarkers
的边缘检测精度?
这是整个电路板的缩小照片:
这是左下角标记的细节,显示了边缘检测的不准确性:
这是右上角标记的详细信息,显示了相同标记 ID 的准确边缘检测:
在这张缩小的图像中很难看清,但左上角的标记是准确的,右下角的标记不准确。
我调用 detectMarkers
的函数:
bool findMarkers(const Mat image, Point2d outerMarkerCoordinates[], Point2d innerMarkerCoordinates[], Size2d *boardSize) {
Ptr<aruco::Dictionary> theDictionary = aruco::getPredefinedDictionary(aruco::DICT_4X4_1000);
vector<vector<Point2f> > markers;
vector<int> ids;
aruco::detectMarkers(image, theDictionary, markers, ids);
aruco::drawDetectedMarkers(image, markers, ids);
return true; //There's actually more code here that makes sure there are four markers.
}
最佳答案
检查 optional detectorParameters
argument detectMarkers
显示了一个名为 doCornerRefinement
的参数。它的描述是“是否进行子像素细化”。由于我看到的错误大于一个像素,我认为这不适用于我的情况。无论如何,我都尝试了一下,并尝试了 cornerRefinementWinSize
值,发现它确实解决了我的问题。现在我认为 ArUco 意义上的“像素”是标记内的一个正方形的大小,而不是图像像素。
修改后的 detectMarkers
调用:
bool findMarkers(const Mat image, Point2d outerMarkerCoordinates[], Point2d innerMarkerCoordinates[], Size2d *boardSize) {
Ptr<aruco::Dictionary> theDictionary = aruco::getPredefinedDictionary(aruco::DICT_4X4_1000);
vector<vector<Point2f> > markers;
vector<int> ids;
Ptr<aruco::DetectorParameters> detectorParameters = new aruco::DetectorParameters;
detectorParameters->doCornerRefinement = true;
detectorParameters->cornerRefinementWinSize = 11;
aruco::detectMarkers(image, theDictionary, markers, ids, detectorParameters);
aruco::drawDetectedMarkers(image, markers, ids);
return true; //There's actually more code here that makes sure there are four markers.
}
成功!
关于opencv - aruco::detectMarkers 没有找到标记的真正边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41051858/
我正在使用 ArUco 标记来校正透视图并计算图像的大小。在此图像中,我知道标记外边缘之间的确切距离,并使用它来计算黑色矩形的大小。 我的问题是 aruco::detectMarkers 并不总能识别
我的相机校准和失真矩阵,从 aruco_calibration_fromimages.exe 获得: [[3.19439125e+03 0.00000000e+00 1.98509417e+
我正在尝试跟踪我的 aruco 标记,但是当我调用 detectMarkers() 函数时,我的应用程序停止了,我完全不知道为什么。 所以我这样使用它: aruco::detectMarkers(co
opencv:4.1.0(带有“contrib”扩展) swift :5 IOS:12.2 我试图在 iPhone 相机的每一帧上运行 opencv 的方法 cv::aruco::detectMark
我是一名优秀的程序员,十分优秀!