Compare commits
1 Commits
master
...
fix_module
Author | SHA1 | Date |
---|---|---|
Derek | e09639b267 |
|
@ -1,7 +1,7 @@
|
||||||
"""Estimate head pose according to the facial landmarks"""
|
"""Estimate head pose according to the facial landmarks"""
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import os
|
||||||
|
|
||||||
class PoseEstimator:
|
class PoseEstimator:
|
||||||
"""Estimate head pose according to the facial landmarks"""
|
"""Estimate head pose according to the facial landmarks"""
|
||||||
|
@ -19,7 +19,8 @@ class PoseEstimator:
|
||||||
(150.0, -150.0, -125.0) # Mouth right corner
|
(150.0, -150.0, -125.0) # Mouth right corner
|
||||||
]) / 4.5
|
]) / 4.5
|
||||||
|
|
||||||
self.model_points_68 = self._get_full_model_points()
|
default_model = os.path.join(os.path.dirname(__file__), 'assets/model.txt')
|
||||||
|
self.model_points_68 = self._get_full_model_points(default_model)
|
||||||
|
|
||||||
# Camera internals
|
# Camera internals
|
||||||
self.focal_length = self.size[1]
|
self.focal_length = self.size[1]
|
||||||
|
@ -39,7 +40,7 @@ class PoseEstimator:
|
||||||
# self.r_vec = None
|
# self.r_vec = None
|
||||||
# self.t_vec = None
|
# self.t_vec = None
|
||||||
|
|
||||||
def _get_full_model_points(self, filename='assets/model.txt'):
|
def _get_full_model_points(self, filename):
|
||||||
"""Get all 68 3D model points from file"""
|
"""Get all 68 3D model points from file"""
|
||||||
raw_value = []
|
raw_value = []
|
||||||
with open(filename) as file:
|
with open(filename) as file:
|
||||||
|
@ -175,4 +176,4 @@ class PoseEstimator:
|
||||||
pose_marks.append(marks[45]) # Right eye right corner
|
pose_marks.append(marks[45]) # Right eye right corner
|
||||||
pose_marks.append(marks[48]) # Mouth left corner
|
pose_marks.append(marks[48]) # Mouth left corner
|
||||||
pose_marks.append(marks[54]) # Mouth right corner
|
pose_marks.append(marks[54]) # Mouth right corner
|
||||||
return pose_marks
|
return pose_marks
|
||||||
|
|
Loading…
Reference in New Issue