GithubHelp home page GithubHelp logo

px4 / px4-opticalflow Goto Github PK

View Code? Open in Web Editor NEW
158.0 15.0 120.0 45 KB

This repository contains different algorithms to calculate the optical flow. It can be used as input for a position estimator

CMake 8.95% C++ 91.05%

px4-opticalflow's Introduction

PX4 Optical Flow repository

This package provides different algorithms to calculate the optical flow. Currently, there is the PX4Flow algorithm (SAD-block-matching) and an OpenCV based (KLT) version.

Please feel free to improve the current algorithms or add new versions.

Usage

PX4Flow version

The constructor OpticalFlowPX4() needs the following parameters (in this order):

  • Focal length in X-Direction [pixels]
  • Focal length in Y-Direction [pixels]
  • Output rate [Hz] (Optional, default = 15Hz) If smaller than frame rate, flow gets integrated. set to -1 to use the image frame rate
  • Image width [pixels] (Optional, default = 64)
  • Image height [pixels] (Optional, default = 64)
  • Search size [pixels] (Optional, default = 6)
  • Flow feature threshold (Optional, default = 30)
  • Flow value threshold (Optional, default = 3000)

For the actual flow calculation the function calcFlow() has to be used. It is the same for both versions and needs the following arguments:

Input:

  • Image array [* uint8_t]
  • Image time stamp [us, uint32_t]

Output:

  • Delta time [us, int]
  • Angular flow in X-Direction [rad/s, float]
  • Angular flow in Y-Direction [rad/s, float]

Return:

  • Flow quality [int], 0-255, -1 if it should not be used yet (output rate)

OpenCV version

The constructor OpticalFlowOpenCV() needs the following parameters (in this order):

  • Focal length in X-Direction [pixels]
  • Focal length in Y-Direction [pixels]
  • Output rate [Hz] (Optional, default = 15Hz) If smaller than frame rate, flow gets integrated. set to -1 to use the image frame rate
  • Image width [pixels] (Optional, default = 64)
  • Image height [pixels] (Optional, default = 64)
  • Number of tracked features (Optional, default = 20)
  • Confidence multiplier for outlier rejection (Optional, default = 1.645, 90% confidence interval)

For the actual flow calculation the function calcFlow() has to be used. It is the same for both versions and needs the following arguments:

Input:

  • Image array [* uint8_t]
  • Image time stamp [us, uint32_t]

Output:

  • Delta time [us, int]
  • Angular flow in X-Direction [rad/s, float]
  • Angular flow in Y-Direction [rad/s, float]

Return:

  • Flow quality [int], 0-255, -1 if it should not be used yet (output rate)

If you have a camera calibration, you can undistort the tracked features (only for OpenCV version). To use that functionality you have to set the camera matrix setCameraMatrix() AND distortion parameters setCameraDistortion() after calling the constructor.

setCameraMatrix() needs the following arguments:

  • Focal length in X-Direction [pixels]
  • Focal length in Y-Direction [pixels]
  • Principal point in X-Direction [pixels]
  • Principal point in Y-Direction [pixels]

setCameraDistortion() needs the following arguments (see here):

  • Radial coefficient k1
  • Radial coefficient k2
  • Radial coefficient k3
  • Tangential coefficient p1
  • Tangential coefficient p2

An example can be found here.

Code style

For code formatting astyle should be used with the .astylerc options file.

astyle <file> --options=.astylerc

px4-opticalflow's People

Contributors

christophtobler avatar gbmhunter avatar julianoes avatar koby08 avatar lorenzmeier avatar mikaelarguedas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

px4-opticalflow's Issues

cmake dev warnings

Just annoying when building in catkin and we should clean this up.

CMake Warning (dev) at external/OpticalFlow/CMakeLists.txt:2 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
    PROJECT_VERSION_PATCH

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.