CommandOpticalFlow.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 
32 #ifndef COMMAND_OFLOW_H_
33 #define COMMAND_OFLOW_H_
34 
35 //#include "CommandRegistry.h"
36 //#include <drain/prog/CommandInstaller.h>
37 #include "drain/prog/Command.h"
38 #include "drain/imageops/FastOpticalFlowOp.h"
39 #include "drain/imageops/FastOpticalFlowOp2.h"
40 #include "drain/imageops/BlenderOp.h"
41 
42 
43 namespace drain {
44 
45 using namespace image;
46 
47 
48 
50 
57 class CmdOpticalFlowBase : public BeanCommand<FastOpticalFlow2Op> {
58 
59 public:
60 
61  /*
62  CmdOpticalFlowBase() {
63  //bean.parameters.link("smoothing", smoothing="doubleSmoother:coeff=0.95", "imageOp");
64  //average,gaussianAverage,distanceTransformFill
65  }
66  */
67 
68  /*
69  CmdOpticalFlowBase(const CmdOpticalFlowBase & cmd) {
70  //bean.parameters.copyStruct(cmd.getParameters(), cmd, *this);
71  }
72  */
73 
75  void exec() const;
76 
78  // void compute(const ImageTray<const Channel> & src, ImageTray<Channel> & diff, ImageTray<Channel> & motion) const;
79 
80 protected:
81 
82 
84 
88  virtual
89  const AreaGeometry & getGeometry() const = 0;
90 
91 
93  virtual
94  void getSrcData(ImageTray<const Channel> & channels) const = 0;
95 
96 
98 
107  virtual
108  void getDiff(size_t width, size_t height, double max, ImageTray<Channel> & channels) const;
109 
110 
112  virtual
113  void getMotion(size_t width, size_t height, ImageTray<Channel> & channels) const = 0;
114 
115  void debugChannels(const ImageTray<const Channel> & channels, int i=-1, int j=-1) const;
116 
117 };
118 
119 
120 } /* namespace drain */
121 
122 #endif /* DRAINLET_H_ */
123 
124 // Rack
Retrieves bean dynamically for each call.
Definition: Command.h:302
Utility for creating a Command that runs FastOpticalFlowOp operator.
Definition: CommandOpticalFlow.h:57
virtual const AreaGeometry & getGeometry() const =0
Main operation: computes differentials and produces approximation of motion.
virtual void getMotion(size_t width, size_t height, ImageTray< Channel > &channels) const =0
The result is stored in this channel pack.
virtual void getSrcData(ImageTray< const Channel > &channels) const =0
Retrieves the intensity images used as a basis of motion analysis.
Container applicable for Channels and Images, with alpha support.
Definition: ImageTray.h:267
Definition: DataSelector.cpp:1277