我正在使用dlib和opencv从保存的视频中进行面部头部估计。
我能够在每帧中使用opencvsolvepnp函数获得头部旋转矩阵和欧拉角。我的问题是如何基于旋转矩阵或欧拉角矩阵获取连续两个帧之间的角度差?
std::vector<cv::Point3d> object_pts; //generic 3D world coordinate
std::vector<cv::Point2d> image_pts; //dlib landmark points
cv::Mat rotation_vec; //3 x 1
cv::Mat rotation_mat; //3 x 3 R
cv::Mat translation_vec;
//calc pose
cv::solvePnP(object_pts, image_pts, cam_matrix, dist_coeffs, rotation_vec, translation_vec);
//calc euler angle
cv::Rodrigues(rotation_vec, rotation_mat);
cv::hconcat(rotation_mat, translation_vec, pose_mat);
cv::decomposeProjectionMatrix(pose_mat, out_intrinsics, out_rotation, out_translation, cv::noArray(), cv::noArray(), cv::noArray(), euler_angle);
这是两个帧的旋转角和欧拉角矩阵的示例:
First frame :
rotation_mat: [0.9808042880813987, -0.00560492255811192, -0.194914169121329;
-0.009358357320917634, 0.9970819362297282, -0.07576300939528717;
0.1947700429465335, 0.07613276093439612, 0.9778897857545662]
Euler_angle[4.451733321076386;
-11.23129045806711;
-0.5466718623384634]
Second frame:
rotation_mat: [0.9821961040283421, -0.005362175244554571, -0.1877819488347928;
-0.01108060484669302, 0.9961985559469002, -0.08640403535450306;
0.1875314198415228, 0.0869464444699003, 0.9784029243447022]
Euler_angle[5.078288701210371;
-10.80875560893563;
-0.6463525542012101]
我的目标是找到一个姿势作为基线,并比较每个帧中的其他头部姿势,以找出偏离基线多少。
最诚挚的问候。