コード例 #1
0
ファイル: math.py プロジェクト: PolarNick239/Triangulum3D
def create_frustum_points(rt_mtx, k_mtx, ratio, frustums_depth=1.0):
    rt_inv = np.linalg.inv(rt_mtx)
    camera_corners = homo_translate(np.linalg.inv(k_mtx), aabb.rect_to_quad([[-1.0, -1.0 * ratio],
                                                                             [1.0, 1.0 * ratio]]))
    corners = np.hstack([camera_corners, [[-1]] * 4]) * frustums_depth
    frustum_points = homo_translate(rt_inv, np.vstack([[[0, 0, 0]], corners]))
    return frustum_points
コード例 #2
0
ファイル: camera.py プロジェクト: caomw/Triangulum3D
 def create_frustum_points(self, frustums_depth=1.0):
     rt_inv = np.linalg.inv(self.get_mv_matrix())
     p = self.get_p_matrix()[:-1, :-1]
     camera_corners = math.homo_translate(np.linalg.inv(p), aabb.rect_to_quad([[-1.0, -1.0 * self.aspect],
                                                                               [1.0, 1.0 * self.aspect]]))
     corners = np.hstack([camera_corners, [[-1]] * 4]) * frustums_depth
     frustum_points = math.homo_translate(rt_inv, np.vstack([[[0, 0, 0]], corners]))
     return frustum_points
コード例 #3
0
ファイル: math.py プロジェクト: nesquik011/Triangulum3D
def create_frustum_points(rt_mtx, k_mtx, ratio, frustums_depth=1.0):
    rt_inv = np.linalg.inv(rt_mtx)
    camera_corners = homo_translate(
        np.linalg.inv(k_mtx),
        aabb.rect_to_quad([[-1.0, -1.0 * ratio], [1.0, 1.0 * ratio]]))
    corners = np.hstack([camera_corners, [[-1]] * 4]) * frustums_depth
    frustum_points = homo_translate(rt_inv, np.vstack([[[0, 0, 0]], corners]))
    return frustum_points
コード例 #4
0
 def create_frustum_points(self, frustums_depth=1.0):
     rt_inv = np.linalg.inv(self.get_mv_matrix())
     p = self.get_p_matrix()[:-1, :-1]
     camera_corners = math.homo_translate(
         np.linalg.inv(p),
         aabb.rect_to_quad([[-1.0, -1.0 * self.aspect],
                            [1.0, 1.0 * self.aspect]]))
     corners = np.hstack([camera_corners, [[-1]] * 4]) * frustums_depth
     frustum_points = math.homo_translate(rt_inv,
                                          np.vstack([[[0, 0, 0]], corners]))
     return frustum_points
コード例 #5
0
ファイル: frame3d.py プロジェクト: PolarNick239/Triangulum3D
if __name__ == '__main__':
    import sys
    from triangulum_test.test_support import resources_dir_path

    logging.basicConfig(level=logging.DEBUG,
                        format='%(relativeCreated)d [%(threadName)s]\t%(name)s [%(levelname)s]:\t %(message)s')

    frame = Frame3D()
    datas = []
    for points_path in sys.argv[1:]:
        points = points_cloud.load_ply(points_path)
        frame.add_points_cloud(points)
    if len(sys.argv[1:]) == 0:
        dog_mesh = PointsCloud(np.array([[1, -0.5, 0], [0, -0.5, 0], [0, -0.5, 1.5], [1, -0.5, 1.5]], np.float32),
                               uv=np.float32(aabb.rect_to_quad([[0, 0], [1, 1]])),
                               faces=np.int32([[0, 1, 2], [0, 2, 3]]), name='USSR Cute Dog Poster')
        box1 = Box(xs=[0.2, 0.4], ys=[0.0, -0.4], zs=[0.6, 0.8],
                   course=-20, roll=45)
        box2 = Box(xs=[0.2, 0.5], ys=[0.0, -0.3], zs=[0.1, 0.4],
                   course=15, pitch=10)
        texture = asyncio.get_event_loop().run_until_complete(frame._gl_executor.map(gl.create_image_texture,
                                                                                     resources_dir_path / 'data' / 'dog.jpg'))
        bunny = ply.read_ply(resources_dir_path / 'scenes' / 'bunny' / 'bunny.ply')
        dog_mesh.set_texture(texture)

        def move_bunny(ps):
            world_pos = np.array([0.5, -0.2, 0.0])
            ps[:, 0] += world_pos[0]
            ps[:, [0, 1, 2]] = ps[:, [0, 2, 1]]
            ps = world_pos + (ps - world_pos) * 7
コード例 #6
0
ファイル: frame3d.py プロジェクト: nesquik011/Triangulum3D
        level=logging.DEBUG,
        format=
        '%(relativeCreated)d [%(threadName)s]\t%(name)s [%(levelname)s]:\t %(message)s'
    )

    frame = Frame3D()
    datas = []
    for points_path in sys.argv[1:]:
        points = points_cloud.load_ply(points_path)
        frame.add_points_cloud(points)
    if len(sys.argv[1:]) == 0:
        dog_mesh = PointsCloud(np.array(
            [[1, -0.5, 0], [0, -0.5, 0], [0, -0.5, 1.5], [1, -0.5, 1.5]],
            np.float32),
                               uv=np.float32(
                                   aabb.rect_to_quad([[0, 0], [1, 1]])),
                               faces=np.int32([[0, 1, 2], [0, 2, 3]]),
                               name='USSR Cute Dog Poster')
        box1 = Box(xs=[0.2, 0.4],
                   ys=[0.0, -0.4],
                   zs=[0.6, 0.8],
                   course=-20,
                   roll=45)
        box2 = Box(xs=[0.2, 0.5],
                   ys=[0.0, -0.3],
                   zs=[0.1, 0.4],
                   course=15,
                   pitch=10)
        texture = asyncio.get_event_loop().run_until_complete(
            frame._gl_executor.map(gl.create_image_texture,
                                   resources_dir_path / 'data' / 'dog.jpg'))