Loading...
Searching...
No Matches
cartesian-motion.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31
32//#pragma once
33
34
35
36#ifndef RACK_MOTION
37#define RACK_MOTION
38
39
40#include <drain/prog/CommandOpticalFlow.h>
41#include <drain/util/Time.h>
42
43#include "resources.h"
44
45
46namespace rack {
47
49
50public:
51
52 virtual
54
55 virtual inline
56 const AreaGeometry & getGeometry() const {
57 return areaGeometry;
58 };
59
60protected:
61
62 mutable AreaGeometry areaGeometry;
63
65 mutable drain::Time t1;
66
68 mutable drain::Time t2;
69
70 virtual
71 void getSrcData(ImageTray<const Channel> & src) const;
72
74
83 virtual
84 void getDiff(size_t width, size_t height, double max, ImageTray<Channel> & channels) const;
85
86 void getMotion(size_t width, size_t height, ImageTray<Channel> & channels) const;
87
88
89};
90
91
92// NOTE: could be under general ProductAdapter (see RackLetAdapter and AndreAdapter), if (currentH5 == cartesian)
93/*
94class CmdMotionFill : public drain::BasicCommand {
95
96public:
97
98 CmdMotionFill() : drain::BasicCommand(__FUNCTION__, "Fills vectors to open areas."){
99 this->getParameters().link("width", this->conf.width = 5, "pixels");
100 this->getParameters().link("height", this->conf.height = 5, "pixels");
101 this->getParameters().link("qualitySensitive", this->qualitySensitive = true, "0,1");
102 };
103
104
105 drain::image::FlowAverageWindow::conf_t conf;
106 bool qualitySensitive;
107
108 inline // cf. CmdCompleteODIM
109 void exec() const { // Suits to general base class?
110
111 drain::Logger mout(__FUNCTION__, getName());
112
113 RackResources & resources = getResources();
114 Hi5Tree *h5 = ctx.currentHi5;
115 if (h5 == ctx.currentPolarHi5){
116 mout.warn("not implemented for polar coord data" );
117 //MotionFillOp<PolarODIM> op;
118 }
119 else if (h5 == &ctx.cartesianHi5){
120 mout.note("dst: cartesianHi5" );
121 MotionFillOp<CartesianODIM> op;
122 op.conf.width = this->conf.width;
123 op.conf.height = this->conf.height;
124 op.qualitySensitive = this->qualitySensitive;
125 op.processH5(ctx.cartesianHi5);
126 }
127 else {
128 mout.warn("no class found for currentHi5" );
129 }
130
131 };
132
133};
134*/
135
136}
137
138#endif
139
140// Rack
Utility for creating a Command that runs FastOpticalFlowOp operator.
Definition CommandOpticalFlow.h:57
Utility for handling time. Internally, uses tm (C time structure).
Definition Time.h:54
Container applicable for Channels and Images, with alpha support.
Definition ImageTray.h:267
Definition cartesian-motion.h:48
virtual void getDiff(size_t width, size_t height, double max, ImageTray< Channel > &channels) const
Retrieves the difference image needed as a temporary storage. Maybe viewed for debugging.
Definition cartesian-motion.cpp:259
virtual const AreaGeometry & getGeometry() const
Main operation: computes differentials and produces approximation of motion.
Definition cartesian-motion.h:56
drain::Time t1
For storing 1 st input timestamp.
Definition cartesian-motion.h:65
void getMotion(size_t width, size_t height, ImageTray< Channel > &channels) const
The result is stored in this channel pack.
Definition cartesian-motion.cpp:314
drain::Time t2
For storing 2nd input timestamp.
Definition cartesian-motion.h:68
virtual void getSrcData(ImageTray< const Channel > &src) const
Retrieves the intensity images used as a basis of motion analysis.
Definition cartesian-motion.cpp:49
Definition DataSelector.cpp:44