forked from by-sabbir/HeadPoseEstimation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reference_world.py
27 lines (22 loc) · 939 Bytes
/
reference_world.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
def ref3DModel():
modelPoints = [[0.0, 0.0, 0.0],
[0.0, -330.0, -65.0],
[-225.0, 170.0, -135.0],
[225.0, 170.0, -135.0],
[-150.0, -150.0, -125.0],
[150.0, -150.0, -125.0]]
return np.array(modelPoints, dtype=np.float64)
def ref2dImagePoints(shape):
imagePoints = [[shape.part(30).x, shape.part(30).y],
[shape.part(8).x, shape.part(8).y],
[shape.part(36).x, shape.part(36).y],
[shape.part(45).x, shape.part(45).y],
[shape.part(48).x, shape.part(48).y],
[shape.part(54).x, shape.part(54).y]]
return np.array(imagePoints, dtype=np.float64)
def cameraMatrix(fl, center):
mat = [[fl, 1, center[0]],
[0, fl, center[1]],
[0, 0, 1]]
return np.array(mat, dtype=np.float)