1 Star 5 Fork 1

cubone/learnopencv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
Loading...
README

Optical Flow demo

This contains the code for Optical Flow in OpenCV (C++/Python) post For more information - visit Optical Flow in OpenCV (C++/Python)

Python

Installation

Before you start the demo of Optical Flow calculation, you need to create a virtual environment in your working directory and install the required libraries:

virtualenv -p python3.7 venv
source venv/bin/activate
pip install -r reqirements.txt

Sparse Optical Flow

There is a demo lucas_kanade.py script of Lucas-Kanade algorithm which can be run with this command:

python3 demo.py --algorithm lucaskanade --video_path videos/car.mp4

Dense Optical Flow

The wrapper of Dense Optical Flow algorithms dense_optical_flow.py can run a couple of OpenCV's algorithm implementations:

  • To start the Dense Lucas-Kanade algorithm:
    python3 demo.py --algorithm lucaskanade_dense --video_path videos/people.mp4
    
  • To start the Farneback algorithm:
    python3 demo.py --algorithm farneback --video_path videos/people.mp4
    
  • To start the RLOF algorithm:
    python3 demo.py --algorithm rlof --video_path videos/people.mp4
    

C++

Installation

Before you start the demo of Optical Flow calculation, you need to build the project:

cd algorithms
cmake .
make

Sparse Optical Flow

There is a demo lucas_kanade.cpp script of Lucas-Kanade algorithm which can be run with this command:

./OpticalFlow ../videos/car.mp4 lucaskanade

Dense Optical Flow

The wrapper of Dense Optical Flow algorithms dense_optical_flow.py can run a couple of OpenCV's algorithm implementations:

  • To start the Dense Lucas-Kanade algorithm:
    ./OpticalFlow ../videos/car.mp4 lucaskanade_dense
    
  • To start the Farneback algorithm:
    ./OpticalFlow ../videos/car.mp4 farneback
    
  • To start the RLOF algorithm:
    ./OpticalFlow ../videos/car.mp4 rlof
    

AI Courses by OpenCV

Want to become an expert in AI? AI Courses by OpenCV is a great place to start.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cubone/learnopencv.git
git@gitee.com:cubone/learnopencv.git
cubone
learnopencv
learnopencv
master

搜索帮助