MCPcopy
hub / github.com/zju3dv/4K4D / test_gl_mesh_rast

Function test_gl_mesh_rast

tests/headless_opengl_tests.py:50–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48
49
50def test_gl_mesh_rast():
51 gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
52
53 mesh_path = 'assets/meshes/bunny.ply'
54 img_path = 'test_gl_mesh_rast.png'
55 camera = Camera(H=HEIGHT, W=WIDTH,
56 K=torch.tensor([[592., 0., 256.],
57 [0., 592., 256.],
58 [0., 0., 1.]]),
59 R=torch.tensor([[0.9908, -0.1353, 0.0000],
60 [-0.1341, -0.9815, -0.1365],
61 [0.0185, 0.1353, -0.9906]]),
62 T=torch.tensor([[0.0178],
63 [0.0953],
64 [0.3137]])
65 )
66 mesh = Mesh(filename=mesh_path, shade_flat=False)
67 mesh.render(camera)
68 # ndc = torch.cat([mesh.verts, torch.ones_like(mesh.verts)[..., -1:]], dim=-1).numpy() @ glm.transpose(camera.gl_ext) @ glm.transpose(camera.gl_ixt)
69
70 # Read result
71 img_buf = gl.glReadPixels(0, 0, WIDTH, HEIGHT, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE)
72 img = np.frombuffer(img_buf, np.uint8).reshape(HEIGHT, WIDTH, 4)[::-1]
73 save_image(img_path, img)
74 log(f'Rendered image saved at: {blue(img_path)}')
75
76
77def test_gl_tex_blit():

Callers

nothing calls this directly

Calls 6

renderMethod · 0.95
CameraClass · 0.90
MeshClass · 0.90
save_imageFunction · 0.90
blueFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected