opencv光流例程_OpenCV LK光流法测试(示例代码)

这是一个OpenCV LK光流法的演示程序,用于图像序列的特征点跟踪。通过读取图像文件和时间戳,利用goodFeaturesToTrack初始化特征点,然后用calcOpticalFlowPyrLK计算光流,实现特征点在连续帧间的平滑移动。用户可以通过点击图像添加或移除特征点,按'r'键重新初始化跟踪,'c'键清除所有点,'n'键切换夜间模式。
摘要由CSDN通过智能技术生成

1 #include "opencv2/video/tracking.hpp"

2 #include "opencv2/imgproc.hpp"

3 #include "opencv2/videoio.hpp"

4 #include "opencv2/highgui.hpp"

5

6 #include

7 #include

8 #include

9 #include

10 using namespacestd;11

12

13 using namespacecv;14 void LoadImages(const string &strImagePath, const string &strPathTimes,15 vector &vstrImages, vector &vTimeStamps)16 {17 ifstream fTimes;18 fTimes.open(strPathTimes.c_str());19 vTimeStamps.reserve(5000);20 vstrImages.reserve(5000);21 while(!fTimes.eof())22 {23 strings;24 getline(fTimes,s);25 if(!s.empty())26 {27 stringstream ss;28 ss <>t;32 vTimeStamps.push_back(t/1e9);33

34 }35 }36 }37 static voidhelp()38 {39 //print a welcome message, and the OpenCV version

40 cout << "\nThis is a demo of Lukas-Kanade optical flow lkdemo(),\n

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值