资源简介
利用LK光流法跟踪ORB特征点,利用solvePnP计算相机姿态,并控制opengl里的相机,在特征点处画AR物体。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace cv;
using namespace std;
VideoCapture cap(0);
static int resolution_width = 640;
static int resolution_height = 480;
static int num_track = 4;
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 rvecm(rv)tvecm(tv);
Mat gray prevGray image frame;
vector points[2];
vector keypoints;
vector initPoints;
vector recoveryPoints;
vector projectedPoints;
vector goodfeatures;
bool initflag = true;
bool needToGetgf = false;
bool needtomap = false;
bool needtokeeptime = false;
const int MAX_COUNT = 500;
size_t trackingpoints = 0;
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(2121);
static void help()
{
// print a welcome message and the OpenCV version
cout << “\n\n“
“\nUser: cc.\n“
“\nUsing OpenCV version “ << CV_VERSION << endl;
cout << “\nHot keys: \n“
“ Tracking: \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 that point)\n“
“ Generation: \n“
“\tESC - quit the program\n“
“\te - change the view mode\n“<< endl;
}
void on_mouse(int eventint xint yint flag void *param)
{
if(event==CV_EVENT_LBUTTONDOWN)
{
if(needtomap && points[1].size() {
for(size_t i = 0;i {
if(abs(goodfeatures[i].x-x)+abs(goodfeatures[i].y-y)<5)
{
points[1].push_back(goodfeatures[i]);
initPoints.push_back(keypoints[i]);
trackingpoints++;
break;
}
}
Mat temp;
image.copyTo(temp);
for(size_t i = 0; i < points[1].size(); i++ )
{
circle( temp points[1][i] 3 Scalar(00255) -1 8);
}
msg = format( “Resolution: %d * %d. Corner number: %d. Tracked points: %d“(int)cap.get(CV_CAP_PROP_frame_WIDTH)(int)cap.get(CV_CAP_PROP_frame_HEIGHT)goodfeatures.size()trackingpoints);
baseLine = 0;
textSize =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4756 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\cPTAM_2.0.vcxproj
文件 941 2015-09-18 16:35 cPTAM_2.0\cPTAM_2.0\cPTAM_2.0.vcxproj.filters
文件 164 2015-11-02 16:48 cPTAM_2.0\cPTAM_2.0\cPTAM_2.0.vcxproj.user
文件 720 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\cl.command.1.tlog
文件 33262 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\CL.read.1.tlog
文件 492 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\CL.write.1.tlog
文件 94 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.lastbuildstate
文件 2447 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.log
文件 720 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.tlog\cl.command.1.tlog
文件 33554 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.tlog\CL.read.1.tlog
文件 664 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.tlog\CL.write.1.tlog
文件 194 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.tlog\cPTAM_2.0.lastbuildstate
文件 2244 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.tlog\li
文件 5640 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.tlog\li
文件 648 2015-11-02 17:28 cPTAM_2.0\cPTAM_2.0\Debug\cPTAM_2.0.tlog\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
文件 2 2015-11-02 16:36 cPTAM_2.0\cPTAM_2.0\Debug\li
............此处省略108个文件信息
相关资源
- variogramtutorial变异函数教程 surfer
- 《Software Testing》 Second Edition By Ron P
- LinuxCNC_Getting_Started.pdf
- 基于Arcgis Engine10.1实现的SDE数据库连接
- 基于马尔科夫随机场的SAR图像处理
- 小区物业管理系统(源码 论文).ra
- PC游戏编程_人机博弈(PDF)+光盘(
- maven-springboot-bootstrap-angularjs学生数据
- 史上最详细的触摸屏tslib库移植和Qt的
- 思科AP AIR-1142N 2018年4月胖AP OS c1140-
- 微信扫码支付ssm.rar
- DevComponents.DotNetBar2.dll
- P5WE0121UNLOCK.part01.rar
- SketchUp和ArcGIS
- 自己动手制作51单片机+CPLD实验板包含
- 基于FPGA的UART设计
- Hi3531A添加串口uart1、uart2、uart3
- 组态王6.53工程密码.rar
- google地球专业版
- 别踩白块 毕业论文
- 破解SIM卡.rar
- STM8程序,时钟配置,串口,定时器等
- 基于QT的绘图软件.rar
- Charles-Proxy-4.2.5-中文版-补丁神器
- OV5640寄存器设置中文版
- 触摸按键与触摸屏设计指导.rar
- SCADE Architect模块介绍中文
- 新华字典词典
- 9S12XS128(CodeWarrior for HCS12 使用说明
- Smaart-v8中文手册
评论
共有 条评论