Skip to content

Commit 8f6f48a

Browse files
Wovchenaeaidova
authored andcommitted
Roll - clockwise
It looks Roll angle is trained to predict clockwise rotation, while two other angles predict counterclockwise rotation. This assumption fixes old '-' signs, but introduces difference in '-' sign in another place. I couldn’t notice the difference in results drawn, so I just aligned this sign in implementation with rotation matrix.
1 parent 5b65935 commit 8f6f48a

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

demos/gaze_estimation_demo/cpp/src/results_marker.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ void ResultsMarker::mark(cv::Mat& image, const FaceInferenceResults& faceInferen
6565
// OZ points from face center to up
6666

6767
// Rotation matrix:
68-
// Yaw Pitch Roll
69-
// [cosY -sinY 0] [ cosP 0 sinP] [1 0 0 ]
70-
// [sinY cosY 0] * [ 0 1 0 ] * [0 cosR -sinR] =
71-
// [ 0 0 1] [-sinP 0 cosP] [0 sinR cosR]
68+
// Yaw - counterclockwise Pitch - counterclockwise Roll - clockwise
69+
// [cosY -sinY 0] [ cosP 0 sinP] [1 0 0 ]
70+
// [sinY cosY 0] * [ 0 1 0 ] * [0 cosR sinR] =
71+
// [ 0 0 1] [-sinP 0 cosP] [0 -sinR cosR]
7272

7373
// [cosY*cosP cosY*sinP*sinR-sinY*cosR cosY*sinP*cosR+sinY*sinR]
74-
// = [sinY*cosP sinY*sinP*sinR+cosY*cosR sinY*sinP*cosR-cosY*sinR]
75-
// [ -cosP cosP*sinR cosP*cosR ]
74+
// = [sinY*cosP cosY*cosR-sinY*sinP*sinR sinY*sinP*cosR+cosY*sinR]
75+
// [ -sinP -cosP*sinR cosP*cosR ]
7676

7777
// Multiply third row by -1 because screen drawing axis points down
7878
// Drop first row to project to a screen plane
7979

8080
// OY: center to right
8181
cv::line(image, cv::Point(xCenter, yCenter),
82-
cv::Point(static_cast<int>(xCenter + axisLength * (sinY * sinP * sinR + cosY * cosR)),
83-
static_cast<int>(yCenter - axisLength * cosP * sinR)),
82+
cv::Point(static_cast<int>(xCenter + axisLength * (cosR * cosY - sinY * sinP * sinR)),
83+
static_cast<int>(yCenter + axisLength * cosP * sinR)),
8484
cv::Scalar(0, 0, 255), 2);
8585
// OZ: center to top
8686
cv::line(image, cv::Point(xCenter, yCenter),
87-
cv::Point(static_cast<int>(xCenter + axisLength * (cosR * sinY * sinP - cosY * sinR)),
87+
cv::Point(static_cast<int>(xCenter + axisLength * (cosR * sinY * sinP + cosY * sinR)),
8888
static_cast<int>(yCenter - axisLength * cosP * cosR)),
8989
cv::Scalar(0, 255, 0), 2);
9090
// OX: center to camera

demos/gaze_estimation_demo/cpp_gapi/src/results_marker.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,26 @@ void ResultsMarker::mark(cv::Mat& image, const FaceInferenceResults& faceInferen
7171
// OZ points from face center to up
7272

7373
// Rotation matrix:
74-
// Yaw Pitch Roll
75-
// [cosY -sinY 0] [ cosP 0 sinP] [1 0 0 ]
76-
// [sinY cosY 0] * [ 0 1 0 ] * [0 cosR -sinR] =
77-
// [ 0 0 1] [-sinP 0 cosP] [0 sinR cosR]
74+
// Yaw - counterclockwise Pitch - counterclockwise Roll - clockwise
75+
// [cosY -sinY 0] [ cosP 0 sinP] [1 0 0 ]
76+
// [sinY cosY 0] * [ 0 1 0 ] * [0 cosR sinR] =
77+
// [ 0 0 1] [-sinP 0 cosP] [0 -sinR cosR]
7878

7979
// [cosY*cosP cosY*sinP*sinR-sinY*cosR cosY*sinP*cosR+sinY*sinR]
80-
// = [sinY*cosP sinY*sinP*sinR+cosY*cosR sinY*sinP*cosR-cosY*sinR]
81-
// [ -cosP cosP*sinR cosP*cosR ]
80+
// = [sinY*cosP cosY*cosR-sinY*sinP*sinR sinY*sinP*cosR+cosY*sinR]
81+
// [ -sinP -cosP*sinR cosP*cosR ]
8282

8383
// Multiply third row by -1 because screen drawing axis points down
8484
// Drop first row to project to a screen plane
8585

8686
// OY: center to right
8787
cv::line(image, cv::Point(xCenter, yCenter),
88-
cv::Point(static_cast<int>(xCenter + axisLength * (sinY * sinP * sinR + cosY * cosR)),
89-
static_cast<int>(yCenter - axisLength * cosP * sinR)),
88+
cv::Point(static_cast<int>(xCenter + axisLength * (cosR * cosY - sinY * sinP * sinR)),
89+
static_cast<int>(yCenter + axisLength * cosP * sinR)),
9090
cv::Scalar(0, 0, 255), 2);
9191
// OZ: center to top
9292
cv::line(image, cv::Point(xCenter, yCenter),
93-
cv::Point(static_cast<int>(xCenter + axisLength * (cosR * sinY * sinP - cosY * sinR)),
93+
cv::Point(static_cast<int>(xCenter + axisLength * (cosR * sinY * sinP + cosY * sinR)),
9494
static_cast<int>(yCenter - axisLength * cosP * cosR)),
9595
cv::Scalar(0, 255, 0), 2);
9696
// OX: center to camera

models/intel/head-pose-estimation-adas-0001/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ The estimator outputs yaw pitch and roll angles measured in degrees. Suppose the
1313

1414
The predicted angles show how the face is rotated according to a rotation matrix:
1515
```
16-
Yaw Pitch Roll
17-
[cosY -sinY 0] [ cosP 0 sinP] [1 0 0 ] [cosY*cosP cosY*sinP*sinR-sinY*cosR cosY*sinP*cosR+sinY*sinR]
18-
[sinY cosY 0] * [ 0 1 0 ] * [0 cosR -sinR] = [sinY*cosP sinY*sinP*sinR+cosY*cosR sinY*sinP*cosR-cosY*sinR]
19-
[ 0 0 1] [-sinP 0 cosP] [0 sinR cosR] [ -cosP cosP*sinR cosP*cosR ]
16+
Yaw - counterclockwise Pitch - counterclockwise Roll - clockwise
17+
[cosY -sinY 0] [ cosP 0 sinP] [1 0 0 ] [cosY*cosP cosY*sinP*sinR-sinY*cosR cosY*sinP*cosR+sinY*sinR]
18+
[sinY cosY 0] * [ 0 1 0 ] * [0 cosR sinR] = [sinY*cosP cosY*cosR-sinY*sinP*sinR sinY*sinP*cosR+cosY*sinR]
19+
[ 0 0 1] [-sinP 0 cosP] [0 -sinR cosR] [ -sinP -cosP*sinR cosP*cosR ]
2020
```
2121

2222
## Validation Dataset

0 commit comments

Comments
 (0)