资源简介
使用OpenCV中的solvePnP函数计算相机姿态(旋转与平移)
代码片段和文件信息
#include “opencv2/core/core.hpp“
#include “opencv2/video/tracking.hpp“
#include “opencv2/imgproc/imgproc.hpp“
#include “opencv2/highgui/highgui.hpp“
#include
#include “opencv2/features2d/features2d.hpp“
#include
#include
using namespace cv;
using namespace std;
double camD[9] = {618.526381968738 0 310.8963715614199
0 619.4548980786033 248.6374860176724
0 0 1};
double distCoeffD[5] = {0.09367405350511771 -0.08731677320554751 0.002823563134787144 -1.246739177460954e-005 -0.0469061739387372};
Mat camera_matrix = Mat(33CV_64FC1camD);
Mat distortion_coefficients = Mat(51CV_64FC1distCoeffD);
vector objP;
Mat objPM;
vector rv(3) tv(3);
Mat rvec(rv)tvec(tv);
double rm[9];
Mat rotM(33CV_64FC1rm);
Mat gray prevGray image frame;
vector points[2];
vector initPoints;
vector recoveryPoints;
vector projectedPoints;
vector goodfeatures;
bool initflag = false;
bool needToGetgf = false;
bool needtomap = false;
bool needtokeeptime = false;
const int MAX_COUNT = 500;
size_t trackingpoints = 0;
BriefDescriptorExtractor brief;
Mat initdescriptors;
string msg;
int baseLine;
Size textSize;
DWORD t1t2;
int framenum = 0;
TermCriteria termcrit(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS 30 0.01);
Size subPixWinSize(1010)winSize(3131);
VideoCapture cap(0);
static void help()
{
// print a welcome message and the OpenCV version
cout << “\nThis is the cPTAM .\n“
“Using OpenCV version “ << CV_VERSION << endl;
cout << “\nHot keys: \n“
“\tESC - quit the program\n“
“\tg - get the good corners\n“
“\tc - delete all the points\n“
“\tm - choose four points to track and update camera pose then\n“
“\t\t(To add a tracking point please click it and press SPACE)\n“
“\tt - keep the time to get FPS\n“ << endl;
}
void on_mouse(int eventint xint yint flag void *param)
{
if(event==CV_EVENT_LBUTTONDOWN)
{
if(needtomap && points[1].size()<4)
{
for(size_t i = 0;i {
if(abs(goodfeatures[i].x-x)+abs(goodfeatures[i].y-y)<3)
{
points[1].push_back(goodfeatures[i]);
trackingpoints++;
break;
}
}
}
}
}
bool init()
{
cap.set(CV_CAP_PROP_frame_WIDTH640);
cap.set(CV_CAP_PROP_frame_HEIGHT480);
if( !cap.isOpened() )
{
cout << “Could not initialize capturing...\n“;
return false;
}
namedWindow( “PTAM_cc_LK_Tracking“ 1 );
cvSetMouseCallback( “PTAM_cc_LK_Tracking“on_mouseNULL );
objP.push_back(Point3f(000)); //三维坐标的单位是毫米
objP.push_back(Point3f(500));
objP.push_back(Point3f(550));
objP.push_back(Point3f(050));
Mat(objP).convertTo(objPMCV_32F);
return true;
}
void getPlanarSurface(vector& imgP){
Rodrigues(rotMrvec);
solvePnP(objPM Mat(imgP) camera_matrix distortion_coefficients rvec tvec);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 182272 2015-10-05 22:16 ptam_lk_tracking\Debug\ptam_lk_tracking.exe
文件 823424 2015-10-05 22:16 ptam_lk_tracking\Debug\ptam_lk_tracking.ilk
文件 2288640 2015-10-05 22:16 ptam_lk_tracking\Debug\ptam_lk_tracking.pdb
文件 776 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\cl.command.1.tlog
文件 32320 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\CL.read.1.tlog
文件 576 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\CL.write.1.tlog
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
文件 2 2015-10-05 22:16 ptam_lk_tracking\ptam_lk_tracking\Debug\li
............此处省略37个文件信息
相关资源
- vc opencv 条形码 识别
- opencv jpeg 编解码
- opencv2.0中的lib和dll,跑别人程序时可
- 颜色直方图匹配算法opencv实现
- opencv控制多摄像头
- 基于opencv的圆心坐标提取
- 基于标识的AR的OpenCV实现
- Opencv2.4.9参考手册
- 基于opencv2.4.3、VS2010的背景差分法目标
- 车道线检测代码OpenCv以及理论算法说
- cocos热更新demo
- 行人跟踪OPENCV代码
- 基于opencv的人脸检测
- 多目标跟踪
- opencv 求二值化图像的形心
- opencv 学习笔记,个人整理的
- 车牌识别代码arm-Linux,opencv
- Windows2012内网更新服务器部署
- OPENCV函数手册(带目录)+OpenCV中文参
- 史上最全的iOS各种设备信息获取总结
- ACM模板-f_zyj 更新内含 v 1.1 和 v 2.1 的
- opencv实现行人检测
- VC +opencv识别图像中图形显示于界面
- opencv运动物体检测
- 2019最新暴雨强度公式 Ver1.02 2019/02/1
- 基于opencv 的图像局部放大
- Opencv静态手势识别
- 双边滤波opencv实现
- 图像的平均亮度
- Opencv绘制物体轮廓,定位主要物件坐
评论
共有 条评论