我试图在虚拟现实中使用阿鲁科标记器制作一个圆柱体。我做立方体很容易,因为只有8点被绘制和转换成适当的框架。 但对于圆柱体,它的底部是一个没有角的圆。我用了错误的方法来做同样的事情吗? 我有这种感觉,因为我无法提取圆柱体底部圆的这么多点。你知道吗
def drawCylinder(img, ar_list, ar_id, camera_matrix, dist_coeff):
for x in ar_list:
if ar_id == x[0]:
centre = x[1]
rvec, tvec = x[2], x[3]
markerLength = 100
radius = int(markerLength/2)
height = markerLength*1.5 # Constraint on height of the Cylinder
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
aruco_dict = aruco.Dictionary_get(aruco.DICT_5X5_250)
parameters = aruco.DetectorParameters_create()
corners, ids, _ = aruco.detectMarkers(gray, aruco_dict, parameters=parameters)
pts = np.float32()
pt_dict = {}
imgpts, _ = cv2.projectPoints(pts, rvec, tvec, camera_matrix, dist_coeff)
imgpts = np.int32(imgpts).reshape(-1, 2)
# Confusion1: Make a set of points for a circle
points = [[x1,y1,z1],[x2,y2,z2]]
for i in range(len(pts)):
pt_dict[tuple(pts[i])] = tuple(imgpts[i].ravel())
points.append(pt_dict[tuple(pts[i])])
# Some code to convert points and plot them to Image which I know
return img
目前没有回答
相关问题 更多 >
编程相关推荐