YuanxunLu / LiveSpeechPortraits

Live Speech Portraits: Real-Time Photorealistic Talking-Head Animation (SIGGRAPH Asia 2021)
MIT License
1.16k stars 200 forks source link

fix the bug about open cv type error in line function. #38

Closed fishfl closed 2 years ago

fishfl commented 2 years ago

For the latest version of OpenCV, the line function make the parameter must be 'Int' type. which here got float list. So we will got this error:

Traceback (most recent call last): File "demo.py", line 262, in current_pred_feature_map = facedataset.dataset.get_data_test_mode(pred_landmarks[ind], File "D:\codebase\pydl\cv\73_LiveSpeechPortraits-main\datasets\face_dataset.py", line 280, in get_data_test_mode feature_map = torch.from_numpy(self.get_feature_image(landmarks, (self.opt.loadSize, self.opt.loadSize), shoulder, pad)[np.newaxis, :].astype(np.float32)/255.) File "D:\codebase\pydl\cv\73_LiveSpeechPortraits-main\datasets\face_dataset.py", line 295, in get_feature_image im_edges = self.draw_shoulder_points(im_edges, shoulders) File "D:\codebase\pydl\cv\73_LiveSpeechPortraits-main\datasets\face_dataset.py", line 305, in draw_shoulder_points img = cv2.line(img, tuple(shoulder_points[i num + j]), tuple(shoulder_points[i num + j + 1]), 255, 2) # BGR cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'line'

Overload resolution failed:

  • Can't parse 'pt1'. Sequence item with index 0 has a wrong type
  • Can't parse 'pt1'. Sequence item with index 0 has a wrong type

So convert the float list to a int list to fix this error. Pass test in torch1.7 & opencv 4.5.5.