使用OpenCV中的Aruco标记在VR中制作圆柱体

时间:2018-11-29 06:09:56

标签: python opencv virtual-reality aruco

我正在尝试使用Aruco标记在虚拟现实中制造圆柱体。我已经轻松地制作了立方体,因为只有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

0 个答案:

没有答案