Yzy00518 commited on
Commit
ed5089d
·
verified ·
1 Parent(s): 8f913c2

Update src/app/render.py

Browse files
Files changed (1) hide show
  1. src/app/render.py +11 -12
src/app/render.py CHANGED
@@ -32,7 +32,7 @@ def render_motion_to_video(motion, device, output_path, title, step=2):
32
  temp_dir = "temp_render_images"
33
  os.makedirs(temp_dir, exist_ok=True)
34
 
35
- width, height = 854, 480
36
  images = []
37
  for i in range(0, length, step):
38
  trimesh_mesh = trimesh.Trimesh(vertices=vertices[i], faces=faces)
@@ -45,8 +45,8 @@ def render_motion_to_video(motion, device, output_path, title, step=2):
45
  angle = -np.pi / 8
46
  camera_pose = np.array([
47
  [1, 0, 0, 0],
48
- [0, np.cos(angle), -np.sin(angle), 2.5],
49
- [0, np.sin(angle), np.cos(angle), 5],
50
  [0, 0, 0, 1]
51
  ])
52
  scene.add(camera, pose=camera_pose)
@@ -62,15 +62,14 @@ def render_motion_to_video(motion, device, output_path, title, step=2):
62
  img_path = os.path.join(temp_dir, f"frame_{i:04d}.png")
63
  cv2.imwrite(img_path, image)
64
 
65
- font = cv2.FONT_HERSHEY_SIMPLEX
66
- font_scale = 1.0
67
- font_color = (0, 55, 0) # 白色
68
- font_thickness = 2
69
- text_size = cv2.getTextSize(title, font, font_scale, font_thickness)[0]
70
- text_x = (image.shape[1] - text_size[0]) // 2 # 水平居中
71
- text_y = image.shape[0] - 30 # 底部上方30像素
72
- cv2.putText(image, title, (text_x, text_y), font, font_scale, font_color, font_thickness)
73
-
74
  images.append(image)
75
 
76
  if images:
 
32
  temp_dir = "temp_render_images"
33
  os.makedirs(temp_dir, exist_ok=True)
34
 
35
+ width, height = 568, 320
36
  images = []
37
  for i in range(0, length, step):
38
  trimesh_mesh = trimesh.Trimesh(vertices=vertices[i], faces=faces)
 
45
  angle = -np.pi / 8
46
  camera_pose = np.array([
47
  [1, 0, 0, 0],
48
+ [0, np.cos(angle), -np.sin(angle), 2.0],
49
+ [0, np.sin(angle), np.cos(angle), 3.8],
50
  [0, 0, 0, 1]
51
  ])
52
  scene.add(camera, pose=camera_pose)
 
62
  img_path = os.path.join(temp_dir, f"frame_{i:04d}.png")
63
  cv2.imwrite(img_path, image)
64
 
65
+ # font = cv2.FONT_HERSHEY_SIMPLEX
66
+ # font_scale = 1.0
67
+ # font_color = (0, 55, 0) # 白色
68
+ # font_thickness = 2
69
+ # text_size = cv2.getTextSize(title, font, font_scale, font_thickness)[0]
70
+ # text_x = (image.shape[1] - text_size[0]) // 2 # 水平居中
71
+ # text_y = image.shape[0] - 30 # 底部上方30像素
72
+ # cv2.putText(image, title, (text_x, text_y), font, font_scale, font_color, font_thickness)
 
73
  images.append(image)
74
 
75
  if images: