From 3bef3f5d101eab504185a3ce5cacbfb2b70bc83b Mon Sep 17 00:00:00 2001 From: zpeng11 Date: Sat, 15 Feb 2025 21:58:49 -0500 Subject: [PATCH] feat:more stable eye rotation with osf --- main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.py b/main.py index 6302a0c..8a03b68 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,7 @@ from pyanime4k import ac from tha2.mocap.ifacialmocap_constants import * from args import args +import copy from tha3.util import torch_linear_to_srgb, resize_PIL_image, extract_PIL_image_from_filelike, \ extract_pytorch_image_from_PIL_image @@ -644,6 +645,8 @@ def main(): print("Ready. Close this console to exit.") + mouth_eye_vector_c_hist = [] + while True: # ret, frame = cap.read() # input_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) @@ -719,6 +722,16 @@ def main(): position_vector[1] = -(blender_data['translationY']-position_vector_0[1])*0.1 position_vector[2] = -(blender_data['translationZ']-position_vector_0[2])*0.1 + # Apply filter + if len(mouth_eye_vector_c_hist) == 0: + for _ in range(3): + mouth_eye_vector_c_hist.append(copy.deepcopy(mouth_eye_vector_c)) + else: + mouth_eye_vector_c_hist.pop(0) + mouth_eye_vector_c_hist.append(mouth_eye_vector_c) + mouth_eye_vector_c[25] = mouth_eye_vector_c_hist[0][25] * 0.2 + mouth_eye_vector_c_hist[1][25] * 0.5 + mouth_eye_vector_c_hist[2][25] * 0.3 + mouth_eye_vector_c[26] = mouth_eye_vector_c_hist[0][26] * 0.2 + mouth_eye_vector_c_hist[1][26] * 0.5 + mouth_eye_vector_c_hist[2][26] * 0.3 + elif args.ifm is not None: # get pose from ifm try: