【Eigen开源库】linux系统如何安装使用Eigen库
code
/*
* File : haedPose.cpp
* Coder:
* Date : 20181126
* Refer: https://www.learnopencv.com/head-pose-estimation-using-opencv-and-dlib/
*/ #include <opencv2/opencv.hpp>
#include <Eigen/Eigen> using namespace std;
using namespace cv; int main(int argc, char **argv)
{ // Read input image
cv::Mat im = cv::imread("headPose.jpg"); // 2D image points. If you change the image, you need to change vector
std::vector<cv::Point2d> image_points;
image_points.push_back( cv::Point2d(, ) ); // Nose tip
image_points.push_back( cv::Point2d(, ) ); // Chin
image_points.push_back( cv::Point2d(, ) ); // Left eye left corner
image_points.push_back( cv::Point2d(, ) ); // Right eye right corner
image_points.push_back( cv::Point2d(, ) ); // Left Mouth corner
image_points.push_back( cv::Point2d(, ) ); // Right mouth corner // 3D model points.
std::vector<cv::Point3d> model_points;
model_points.push_back(cv::Point3d(0.0f, 0.0f, 0.0f)); // Nose tip
model_points.push_back(cv::Point3d(0.0f, -330.0f, -65.0f)); // Chin
model_points.push_back(cv::Point3d(-225.0f, 170.0f, -135.0f)); // Left eye left corner
model_points.push_back(cv::Point3d(225.0f, 170.0f, -135.0f)); // Right eye right corner
model_points.push_back(cv::Point3d(-150.0f, -150.0f, -125.0f)); // Left Mouth corner
model_points.push_back(cv::Point3d(150.0f, -150.0f, -125.0f)); // Right mouth corner // Camera internals
double focal_length = im.cols; // Approximate focal length.
Point2d center = cv::Point2d(im.cols/,im.rows/);
cv::Mat camera_matrix = (cv::Mat_<double>(,) << focal_length, , center.x, , focal_length, center.y, , , );
cv::Mat dist_coeffs = cv::Mat::zeros(,,cv::DataType<double>::type); // Assuming no lens distortion cout << "Camera Matrix " << endl << camera_matrix << endl ;
// Output rotation and translation
cv::Mat rotation_vector; // Rotation in axis-angle form
cv::Mat translation_vector; // Solve for pose
cv::solvePnP(model_points, image_points, camera_matrix, dist_coeffs, rotation_vector, translation_vector); // Project a 3D point (0, 0, 1000.0) onto the image plane.
// We use this to draw a line sticking out of the nose vector<Point3d> nose_end_point3D;
vector<Point2d> nose_end_point2D;
nose_end_point3D.push_back(Point3d(,,1000.0)); projectPoints(nose_end_point3D, rotation_vector, translation_vector, camera_matrix, dist_coeffs, nose_end_point2D); for(int i=; i < image_points.size(); i++)
{
circle(im, image_points[i], , Scalar(,,), -);
} cv::line(im,image_points[], nose_end_point2D[], cv::Scalar(,,), ); cout << "Rotation Vector " << endl << rotation_vector << endl;
cout << "Translation Vector" << endl << translation_vector << endl; cout << nose_end_point2D << endl; //Eigen.
cv::Mat rMatrix = cv::Mat(, , CV_64F);
cv::Rodrigues(rotation_vector, rMatrix);
Eigen::Matrix3d R;
R << rMatrix.at<double>(, ), rMatrix.at<double>(, ), rMatrix.at<double>(, ),
rMatrix.at<double>(, ), rMatrix.at<double>(, ), rMatrix.at<double>(, ),
rMatrix.at<double>(, ), rMatrix.at<double>(, ), rMatrix.at<double>(, );
Eigen::Vector3d eular_radian = R.eulerAngles(, , );//radian.
Eigen::Vector3d eular_angle = R.eulerAngles(, , )*.f/M_PI;//angle.
// Display image.
std::stringstream ss;
ss << eular_angle[];
std::string txt = "Pitch: " + ss.str();
cv::putText(im, txt, cv::Point(, ), 0.5,0.5, cv::Scalar(,,));
std::stringstream ss1;
ss1 << eular_angle[];
std::string txt1 = "Yaw: " + ss1.str();
cv::putText(im, txt1, cv::Point(, ), 0.5,0.5, cv::Scalar(,,));
std::stringstream ss2;
ss2 << eular_angle[];
std::string txt2 = "Roll: " + ss2.str();
cv::putText(im, txt2, cv::Point(, ), 0.5,0.5, cv::Scalar(,,));
cv::imshow("Output", im);
cv::waitKey(); }
参考
1. https://blog.csdn.net/ttomchy/article/details/56859841
2. https://blog.csdn.net/qq_31806429/article/details/78844305
3. https://www.learnopencv.com/head-pose-estimation-using-opencv-and-dlib/
完
【Eigen开源库】linux系统如何安装使用Eigen库的更多相关文章
- Linux系统下安装Gitlab
Linux系统下安装Gitlab 一.简介 GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目.它拥有与 ...
- 在Linux系统下安装大于mysql5.5版本的数据库
linux下mysql 5.5的安装方法: 1.安装所需要系统库相关库文件 gcc等开发包,在安装linux系统的时候安装. 2.创建mysql安装目录 # mkdir -p /usr/lo ...
- 在 Linux 系统中安装Load Generator ,并在windows 调用方法
在 Linux 系统中安装Load Generator ,并在windows 调用 由于公司需要测试系统的最大用户承受能力,所以需要学习使用loadrunner.在安装的时候碰到了不少问题,所以写下此 ...
- Redis学习之一VMWare Pro虚拟机安装和Linux系统的安装
一.引言 设计模式写完了,相当于重新学了一遍,每次学习都会有不同的感受,对设计模式的理解又加深了,理解的更加透彻了.还差一篇关于设计模式的总结的文章了,写完这篇总结性的文章,设计模式的文章就暂时要告一 ...
- Redis进阶实践之一VMWare Pro虚拟机安装和Linux系统的安装(转载)(1)
Redis进阶实践之一VMWare Pro虚拟机安装和Linux系统的安装 一.引言 设计模式写完了,相当于重新学了一遍,每次学习都会有不同的感受,对设计模式的理解又加深了,理解的更加透彻了.还差一篇 ...
- 在Linux系统中安装caffe
学习深度学习已经很久了,但一直没有自己动手安装过caffe,因为工作需要,需要在linux系统中安装caffe,因此,在这里对安装过程进行记录. caffe配置起来比tensorflow更麻烦一些,我 ...
- Redis进阶实践之一VMWare Pro虚拟机安装和Linux系统的安装
一.引言 设计模式写完了,相当于重新学了一遍,每次学习都会有不同的感受,对设计模式的理解又加深了,理解的更加透彻了.还差一篇关于设计模式的总结的文章了,写完这篇总结性的文章,设计模式的文章就暂时要告一 ...
- linux linux系统的安装及使用
linux linux系统的安装及使用 一.linux系统中安装vm-tools工具: 步骤: 1.在vmware workstation软件中:虚拟机-安装vmware-tools-状态栏会提示- ...
- 2.0 Linux系统的安装之Fedora安装单系统(2)
2.0 Linux系统的安装之Fedora安装单系统(2) *Linux系统的安装之Fedora安装单系统 恐怕最好装的系统就是Linux系统了,或者与Windows并列.此篇教程为Fedora的单系 ...
随机推荐
- 把旧系统迁移到.Net Core 2.0 日记 (12) --发布遇到的问题
1. 开发时是在Mac+MySql, 尝试发布时是在SQL2005+Win 2008 (第一版) 在Startup.cs里,数据库连接要改,分页时netcore默认是用offset关键字分页, 如果用 ...
- CAD绘制室外平台步骤5.3
1.在平面上用直线划出台阶范围. “工具”“曲线工具”“线变复线”选择这几条线,它们就变成了一条线. “三维建模”“造型对象”“平板”选择这条封闭的线,回车,选择相邻门窗柱子等,回车输入平台厚度如“- ...
- 网卡驱动-BD详解(缓存描述符 Buffer Description)
DMA介绍(BD的引入) 网络设备的核心处理模块是一个被称作 DMA(Direct Memory Access)的控制器,DMA 模块能够协助处理器处理数据收发.对于数据发送来说,它能够将组织好的数据 ...
- CCF关于对NOIP2018复赛违规处罚的公告
NOIP2018复赛于11月10-11日在全国31个赛区同时举行,现已结束.总体有序,但也有赛区出现违规现象.现将复赛中违规情况进行通报. 一.数据提交情况 CCF要求NOI各省组织单位在考试结束后在 ...
- sqlalchemy tree 树形分类 无限极分类的管理。预排序树,左右值树。sqlalchemy-mptt
简介: 无限极分类是一种比较常见的数据格式,生成组织结构,生成商品分类信息,权限管理当中的细节权限设置,都离不开无限极分类的管理. 常见的有链表式,即有一个Pid指向上级的ID,以此来设置结构.写的时 ...
- vue-12-渲染函数 & JSX
render() Vue.component('anchored-heading', { render: function (createElement) { return createElement ...
- 顺便谈谈对于Java程序猿学习当中各个阶段的建议
引言 其实本来真的没打算写这篇文章,主要是LZ得记忆力不是很好,不像一些记忆力强的人,面试完以后,几乎能把自己和面试官的对话都给记下来.LZ自己当初面试完以后,除了记住一些聊过的知识点以外,具体的内容 ...
- Cracking The Coding Interview 9.6
//原文: // // Given a matrix in which each row and each column is sorted, write a method to find an el ...
- Linux7 下重新安装YUM
所有操作均在ROOT用户下,系统版本是Linux7.0 X86_64: 一.删除原有YUM # rpm -aq|grep yum|xargs rpm -e --nodeps 二.下载yum,注意自己的 ...
- SQL-31 获取select * from employees对应的执行计划
题目描述 获取select * from employees对应的执行计划 explain select * from employees explain 用于获得表的所有细节