Exemplo n.º 1
0
    indexs = [0, 1, 3, 2]
    cube_points = [(-100, 100, -100), (-100, -100, -100), (100, 100, -100), (100, -100, -100), (100, 100, 100), (100, -100, 100), (-100, 100, 100), (-100, -100, 100)]
    # 测量值列表
    measured_points = []
    quaternions = []
    for i in range(200):
        temp = []
        for index in indexs:
            pos = getImagePosition(cube_points[index][0], cube_points[index][1], cube_points[index][2], 0, 0, i, 0)
            # 相机坐标系转换到图像坐标系
            x, y = fromCameraToImage(pos[0], pos[1], pos[2])
            # temp.append((x, y))
            temp.append([x + 0.01*np.random.randn()])
            temp.append([y + 0.01*np.random.randn()])

        quaternions.append(getQuaternion(0, 0, -i))
        measured_points.append(temp)

    # 验证坐标是否正确
    # for i in range(200):
    #     prefix = "/Users/apple/Desktop/test/img4/"
    #     filename = "img" + "0" * (4 - len(str(i))) + str(i) + ".jpg"
    #
    #     img = cv2.imread(prefix + filename)
    #     result = []
    #     for p in measured_points[i]:
    #         result.append((fromImageToPixel(p[0], p[1])))
    #     drawPoint(img, result)
    #     cv2.imwrite("test/" + filename, img)

Exemplo n.º 2
0
    # 测量值列表
    measured_points = []
    quaternions = []
    for i in range(180):
        temp = []
        for index in indexs:
            pos = getImagePosition2(cube_points[index][0],
                                    cube_points[index][1],
                                    cube_points[index][2], 0, 0, i)
            # 相机坐标系转换到图像坐标系
            x, y = fromCameraToImage(pos[0], pos[1], pos[2])
            # temp.append((x, y))
            temp.append([x])
            temp.append([y])

        quaternions.append(getQuaternion(-45, 0, -i))
        measured_points.append(temp)

    # 验证坐标是否正确
    # for i in range(180):
    #     prefix = "/Users/apple/Desktop/test/img/"
    #     filename = "img" + "0" * (4 - len(str(i))) + str(i) + ".jpg"
    #
    #     img = cv2.imread(prefix + filename)
    #     result = []
    #     for p in measured_points[i]:
    #         result.append((fromImageToPixel(p[0], p[1])))
    #     drawPoint(img, result)
    #     cv2.imwrite("test/" + filename, img)

    # 估计值列表