Gunnar Farnebak的算法计算稠密光流
来源:互联网 发布:数据流程图画法 编辑:程序博客网 时间:2024/04/28 15:44
Gunnar Farnebak的算法计算稠密光流
Computes a dense optical flow using the Gunnar Farneback’s algorithm.
用Gunnar Farnebak的算法计算稠密光流
- C++: void calcOpticalFlowFarneback(InputArray prev, InputArray next, InputOutputArray flow, double pyr_scale, int levels, int winsize, int iterations, int poly_n, double poly_sigma, int flags)
#include "opencv2/video/tracking.hpp"#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/highgui/highgui.hpp"#include <iostream>using namespace cv;using namespace std;
static void help(){cout <<"\nThis program demonstrates dense optical flow algorithm by Gunnar Farneback\n""Mainly the function: calcOpticalFlowFarneback()\n""Call:\n"
"./fback\n""This reads from video camera 0\n" << endl;}
static void drawOptFlowMap(const Mat& flow, Mat& cflowmap, int step,double, const Scalar& color){for(int y = 0; y < cflowmap.rows; y += step)for(int x = 0; x < cflowmap.cols; x += step){const Point2f& fxy = flow.at<Point2f>(y, x);line(cflowmap, Point(x,y), Point(cvRound(x+fxy.x), cvRound(y+fxy.y)),color);circle(cflowmap, Point(x,y), 2, color, -1);}}int main(int, char**){//VideoCapture cap(0);VideoCapture cap("E:\\图片\\视频材料\\Megamind.avi");help();if( !cap.isOpened() )return -1;Mat prevgray, gray, flow, cflow, frame;namedWindow("flow", 1);for(;;){cap >> frame;cvtColor(frame, gray, COLOR_BGR2GRAY);if( prevgray.data ){calcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);cvtColor(prevgray, cflow, COLOR_GRAY2BGR);drawOptFlowMap(flow, cflow, 16, 1.5, Scalar(0, 255, 0));imshow("flow", cflow);}if(waitKey(30)>=0)break;std::swap(prevgray, gray);}return 0;}
运行结果
0 0
- Gunnar Farnebak的算法计算稠密光流
- Opencv Python版学习笔记(四)光流跟踪之Gunnar Farneback’s 算法
- 计算两幅图片的farneback 稠密光流,并将结果图显示出来的程序
- opencv 稀疏光流 稠密光流
- 稠密特征的光流opencv3.2+VS
- Farneback 稠密光流--求两幅图像之间的光流--代码(本人略有修改)
- 光流(五)--HS光流及稠密光流
- 稠密矩阵特征值和特征向量的计算
- LK光流算法的三个假设
- 关于光流算法的一点思考
- LK光流算法
- 光流算法
- 光流算法
- LK光流算法
- 合并使用gpu::FarnebackOpticalFlow计算的水平光流flowx 和垂直光流flowy
- 光流(二)--光流算法
- GPU计算光流:gpu_flow
- 实现Lucas-Kanade光流计算的Delphi类
- 一个团队需要知道什么?
- ubuntu 安装 boost 库
- POJ1011 经典DFS+剪枝
- SPOJ375 QTREE - Query on a tree
- [Python标准库]re——正则表达式[六]
- Gunnar Farnebak的算法计算稠密光流
- 18-1
- eclipse#1
- 从农夫砍大白菜到解决约瑟夫环的问题!
- c或c++中int转float中在printf中的问题
- 借此博客发布敲代码过程中遇到的问题。
- HDU 1078 FatMouse and Cheese 记忆化搜索
- jquery 数值比较大小时注意事项
- BZOJ-1087 互不侵犯King 状压DP+DFS预处理