JeVoisBase  1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Loading...
Searching...
No Matches
FastOpticalFlow.H
Go to the documentation of this file.
1// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3// JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 by Laurent Itti, the University of Southern
4// California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5//
6// This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7// redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8// Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10// License for more details. You should have received a copy of the GNU General Public License along with this program;
11// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12//
13// Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14// Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16/*! \file */
17
18#pragma once
19
22#include <opencv2/core/core.hpp>
23
25{
26 static jevois::ParameterCategory const ParamCateg("Fast Optical Flow Options");
27
28 //! Parameter \relates FastOpticalFlow
29 JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(opoint, int, "Algorithm operating point",
30 1, jevois::Range<int>(1, 4), ParamCateg);
31
32 //! Parameter \relates FastOpticalFlow
33 JEVOIS_DECLARE_PARAMETER(factor, float, "Factor to use when converting float velocities to byte",
34 25.0F, ParamCateg);
35
36 //! Parameter \relates FastOpticalFlow
37 JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(thetasf, int, "Finest scale in the pyramid, or -1 for auto",
38 -1, ParamCateg);
39
40 //! Parameter \relates FastOpticalFlow
41 JEVOIS_DECLARE_PARAMETER(thetait, int, "Number of gradient descent iterations, or -1 for auto",
42 5, ParamCateg);
43
44 //! Parameter \relates FastOpticalFlow
45 JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(thetaps, int, "Patch size in pixels, or -1 for auto",
46 -1, ParamCateg);
47
48 //! Parameter \relates FastOpticalFlow
49 JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(thetaov, float, "Patch overlap on each scale, or -1 for auto",
50 0.1F, ParamCateg);
51
52 //! Parameter \relates FastOpticalFlow
53 JEVOIS_DECLARE_PARAMETER(usevref, bool, "Use variational refinement when true",
54 false, ParamCateg);
55}
56
57//! Fast optical flow computation using dense inverse search
58/*! This algorithm computes what moved between two images (optical flow). It is based on the paper "Fast Optical Flow
59 using Dense Inverse Search" by Till Kroeger, Radu Timofte, Dengxin Dai and Luc Van Gool, Proc ECCV, 2016. Also see
60 here: http://www.vision.ee.ethz.ch/~kroegert/OFlow/ \ingroup components */
62 public jevois::Parameter<fastopticalflow::opoint, fastopticalflow::factor,
63 fastopticalflow::thetasf, fastopticalflow::thetait,
64 fastopticalflow::thetaps, fastopticalflow::thetaov,
65 fastopticalflow::usevref>
66{
67 public:
68 //! Constructor
69 FastOpticalFlow(std::string const & instance);
70
71 //! Destructor
72 virtual ~FastOpticalFlow();
73
74 //! Process a greyscale image and return flow in a pre-allocated greyscale image of same with and 2x height
75 /*! The results are the concatenation of 2 images: vx on top of vy, both converted to byte. */
76 void process(cv::Mat const & src, cv::Mat & dst);
77
78 protected:
79 void onParamChange(fastopticalflow::opoint const & param, int const & val) override;
80 void onParamChange(fastopticalflow::thetasf const & param, int const & val) override;
81 void onParamChange(fastopticalflow::thetaps const & param, int const & val) override;
82 void onParamChange(fastopticalflow::thetaov const & param, float const & val) override;
83
85 std::mutex itsMtx;
86
87 bool itsNuke; // nuke all caches when some sizes or params change
88
89 const float ** img_bo_pyr; // those are just shallow pointers to the cv::Mat versions, no memory alloc
90 const float ** img_bo_dx_pyr;
91 const float ** img_bo_dy_pyr;
92
93 cv::Mat * img_bo_fmat_pyr;
96
97 cv::Mat img_bo_mat;
98 cv::Mat img_bo_fmat;
99
102};
Fast optical flow computation using dense inverse search.
JEVOIS_DECLARE_PARAMETER(thetait, int, "Number of gradient descent iterations, or -1 for auto", 5, ParamCateg)
Parameter.
void onParamChange(fastopticalflow::thetasf const &param, int const &val) override
jevois::Profiler itsProfiler
virtual ~FastOpticalFlow()
Destructor.
const float ** img_bo_pyr
const float ** img_bo_dx_pyr
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(thetaps, int, "Patch size in pixels, or -1 for auto", -1, ParamCateg)
Parameter.
const float ** img_bo_dy_pyr
void onParamChange(fastopticalflow::thetaov const &param, float const &val) override
JEVOIS_DECLARE_PARAMETER(usevref, bool, "Use variational refinement when true", false, ParamCateg)
Parameter.
cv::Mat * img_bo_dx_fmat_pyr
void onParamChange(fastopticalflow::opoint const &param, int const &val) override
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(thetasf, int, "Finest scale in the pyramid, or -1 for auto", -1, ParamCateg)
Parameter.
cv::Mat * img_bo_fmat_pyr
void onParamChange(fastopticalflow::thetaps const &param, int const &val) override
cv::Mat * img_bo_dy_fmat_pyr
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(thetaov, float, "Patch overlap on each scale, or -1 for auto", 0.1F, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(opoint, int, "Algorithm operating point", 1, jevois::Range< int >(1, 4), ParamCateg)
Parameter.
void process(cv::Mat const &src, cv::Mat &dst)
Process a greyscale image and return flow in a pre-allocated greyscale image of same with and 2x heig...
JEVOIS_DECLARE_PARAMETER(factor, float, "Factor to use when converting float velocities to byte", 25.0F, ParamCateg)
Parameter.