vin*_*vin 5 opencv image-processing python-3.x aruco
我正在关注这个例子。
以下是我用来检测标记的代码片段。我无法理解为什么这个例子对我不起作用。
import numpy as np
import cv2
import cv2.aruco as aruco
import os
im_names = filter(lambda x: x.endswith('.png'),
[f for f in os.listdir('local_vids_ims')])
for imn in im_names:
image = cv2.imread('local_vids_ims/' + imn)
# image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
parameters = aruco.DetectorParameters_create()
corners, ids, rejectedImgPoints = aruco.detectMarkers(
image, aruco_dict, parameters=parameters)
print(corners, ids, rejectedImgPoints)
# aruco.drawDetectedMarkers(image, corners)
aruco.drawDetectedMarkers(image, rejectedImgPoints)
cv2.imshow('gray_im', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
有趣的。你的程序没有任何问题。我在 Python 和 C++ 中尝试了同样的事情,并得到了与你相同的结果。所以我尝试了不同的图像并成功了。
这是我的程序。它基本上与你的相同,但请注意我使用的是不同的字典。
import numpy as np
import cv2
import cv2.aruco as aruco
image = cv2.imread("52814747.png")
aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_50)
parameters = aruco.DetectorParameters_create()
corners, ids, rejectedImgPoints = aruco.detectMarkers(
image, aruco_dict, parameters=parameters)
print(corners, ids, rejectedImgPoints)
aruco.drawDetectedMarkers(image, corners, ids)
aruco.drawDetectedMarkers(image, rejectedImgPoints, borderColor=(100, 0, 240))
cv2.imshow('so52814747', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
我不知道问题是否出在 6X6 字典上,或者源图像没有足够的分辨率来处理 6x6 字典。但该教程肯定有问题。我已在 GitHub 上报告了该问题。
这是我使用的图像。
这就是结果。(找到的标记有绿色边框。被拒绝的候选人有红色边框。)
| 归档时间: |
|
| 查看次数: |
3418 次 |
| 最近记录: |