Loading...
Searching...
No Matches
DetectorOp.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#ifndef ANDRE_DETECTOR2_H_
33#define ANDRE_DETECTOR2_H_
34
35
36#include <main/palette-manager.h>
37#include "AndreOp.h"
38
39
40namespace rack {
41
42using namespace drain::image;
43
44
46
49class DetectorOp : public AndreOp {
50
51public:
52
55 /*
56 DetectorOp(const std::string & name = __FUNCTION__, const std::string &description = "", unsigned short code = 0) : AndreOp(name,description), classCode(code ? code : 128+(++_count)) {
57 // dataSelector.path = ". * /da ta[0-9]+/?$";
58 // dataSelector.quantity = "DBZ.*";
59 dataSelector.setQuantity("^DBZH$");
60 // cumulateDetections = MAX;
61 REQUIRE_STANDARD_DATA = true;
62 UNIVERSAL = false;
63 }
64 */
65
66 DetectorOp(const std::string & name = __FUNCTION__, const std::string & description = "", const std::string & echoClass = "") :
67 AndreOp(name,description), classEntry(PaletteManager::getPalette("CLASS").getEntryByCode(echoClass)) {
68 // classCode(PaletteManager::getPalette("CLASS").getValueByCode(echoClass)) {
69 // classCode(getClassCode(echoClass)) {
70
71 // dataSelector.path = ". * /da ta[0-9]+/?$";
72 //dataSelector.quantity = "DBZ.*";
73 //dataSelector.setQuantityRegExp("^DBZH$");
74 dataSelector.setQuantities("DBZH:DBZ");
75 //cumulateDetections = MAX;
77 UNIVERSAL = false;
78
79 //PaletteManager::getPalette("CLASS").getEntryByCode(code, lenient);
80 // std::cout << __FUNCTION__ << ':' << name << ':' << echoClass << '\n';
81 }
82
83 // inline
84 // DetectorOp(const DetectorOp & op) : AndreOp(op), classCode(op.classCode), REQUIRE_STANDARD_DATA(op.REQUIRE_STANDARD_DATA), UNIVERSAL(op.UNIVERSAL) {}
85 inline
86// DetectorOp(const DetectorOp & op) : AndreOp(op), classCode(op.classCode), UNIVERSAL(op.UNIVERSAL), REQUIRE_STANDARD_DATA(op.REQUIRE_STANDARD_DATA) {};
88
89 virtual
90 ~DetectorOp(){};
91
93
96 virtual
97 const std::string & getOutputQuantity(const std::string & inputQuantity = "") const;
98
99 static bool SUPPORT_UNIVERSAL;
100
102 //const unsigned short int classCode;
103
105 const drain::image::Palette::value_type & classEntry;
106
107
108 // NEW
112 //virtual
113 //void processProduct(DataSetList<PolarDst> & srcVolume, DataSetList<PolarDst> & dstVolume) const;
114
115
116 virtual inline
117 void computeProducts(const DataSetMap<PolarSrc> & srcVolume, DataSetMap<PolarDst> & dstVolume) const {
118 drain::Logger mout(__FILE__, __FUNCTION__);
119 mout.unimplemented<LOG_INFO>("TODO... redirecting...");
120 runDetection(srcVolume, dstVolume);
121 }
122
123
124 // NEW
128 virtual
129 void runDetection(const DataSetMap<PolarSrc> & srcVolume, DataSetMap<PolarDst> & dstVolume) const;
130
132 //virtual
133 //void processDataSets(const DataSetMap<PolarSrc> & srcVolume, DataSetMap<PolarDst> & dstVolume) const;
134
136
141 virtual
142 void runDetection(const DataSet<PolarSrc> & srcDataSet, PlainData<PolarDst> & dstProb, DataSet<PolarDst> & aux) const;
143
145
150 //virtual
151 //void processDataSet(const DataSet<PolarSrc> & srcDataSet, PlainData<PolarDst> & dstProb, DataSet<PolarDst> & aux) const;
152
154
158 virtual inline
159 void runDetector(const PlainData<PolarSrc> & srcData, PlainData<PolarDst> & dstProb) const {
160 drain::Logger mout(__FILE__, __FUNCTION__);
161 mout.unimplemented("function ", __FUNCTION__," not implemented for ", getName());
162 mout.error("stopping");
163 }
164 /*
165 {
166 drain::Logger mout(__FILE__, __FUNCTION__);
167 mout.unimplemented("function ", __FUNCTION__," not implemented for ", getName());
168 }*
169 */
170
171 virtual
172 void processData(const Data<src_t > & srcData, Data<dst_t > & dstData) const {
173 drain::Logger mout(__FILE__, __FUNCTION__);
174 mout.special(__FUNCTION__, " now, here!");
175 //runDetector((const PlainData<PolarSrc> &) srcData, (PlainData<PolarDst> &)dstData);
176 // Default implementation is simple, creates no (2nd order) quality field of the detection
177 runDetector(srcData, dstData);
178 };
179
181 bool UNIVERSAL = false;
182
183protected:
184
185 virtual
186 void initDataDst(const PlainData<PolarSrc> & srcData, PlainData<PolarDst> & dstData, const std::string & quantity = "") const;
187
188 // This is difficult...
189 //const Hi5Tree & getNormalizedData(const DataSet<> & srcDataSet, DataSet<> & dstDataSet, const std::string & quantity) const;
190
191 // Consider raise to VolumeOp ?
192 void storeDebugData(int debugLevel, const ImageFrame & srcImage, const std::string & label) const;
193
194 // Consider raise
195 void storeDebugData(const ImageFrame & srcImage, PlainData<PolarDst> & dstData, const std::string & quantityLabel) const;
196
197
199 virtual
200 void writeHow(PlainData<PolarDst> & dstData) const;
201
202 // Detector classCode. Obsolete...
203 static
204 unsigned short int _count;
205
206 mutable std::string upperCaseName;
207
209
217
218
220
225 void _enhanceDirectionally(Image & data, float medianPos, int windowWidth) const;
226
227 void _infect(Image & data, int windowWidth, int windowHeight, double enhancement) const;
228
229
230};
231
232
233} // rack::
234
235#endif /* ANDRE_OP_H_ */
virtual const std::string & getName() const
Return the name of an instance.
Definition BeanLike.h:82
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & error(const TT &... args)
Echoes.
Definition Log.h:416
Logger & unimplemented(const TT &... args)
Feature to be done. Special type of Logger::note().
Definition Log.h:511
Image with static geometry.
Definition ImageFrame.h:67
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:184
The base class for detector and removal operators.
Definition AndreOp.h:55
void setQuantities(const std::string &s)
Sets basic quantities and quality quantities. These sets are separated by '/'.
Definition DataSelector.cpp:282
Definition Data.h:1370
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1215
Data structure consisting of plain data and an optional quality data.
Definition Data.h:1146
Base class for anomaly detectors.
Definition DetectorOp.h:49
virtual void writeHow(PlainData< PolarDst > &dstData) const
After running a cmd, write execution details.
Definition DetectorOp.cpp:311
const drain::image::Palette::value_type & classEntry
Index applied in the legend of the classification results.
Definition DetectorOp.h:105
virtual void computeProducts(const DataSetMap< PolarSrc > &srcVolume, DataSetMap< PolarDst > &dstVolume) const
Definition DetectorOp.h:117
DetectorOp(const std::string &name=__FUNCTION__, const std::string &description="", const std::string &echoClass="")
Definition DetectorOp.h:66
virtual void initDataDst(const PlainData< PolarSrc > &srcData, PlainData< PolarDst > &dstData, const std::string &quantity="") const
If raised, make template? Cf. Volume::initDst ?
Definition DetectorOp.cpp:235
virtual void runDetection(const DataSetMap< PolarSrc > &srcVolume, DataSetMap< PolarDst > &dstVolume) const
Definition DetectorOp.cpp:82
virtual const std::string & getOutputQuantity(const std::string &inputQuantity="") const
Returns the quantity name, by default the name of the class in upper case letters.
Definition DetectorOp.cpp:262
virtual void runDetector(const PlainData< PolarSrc > &srcData, PlainData< PolarDst > &dstProb) const
Process as sweep (data in one elevation angle)
Definition DetectorOp.h:159
bool REQUIRE_STANDARD_DATA
Set to true if operator expects fixed background intensities instead of "nodata" defined by the Polar...
Definition DetectorOp.h:216
bool UNIVERSAL
If true, applies also to quantities str than the one used in detection. The detection and the accumul...
Definition DetectorOp.h:181
void _enhanceDirectionally(Image &data, float medianPos, int windowWidth) const
Enhances the detection result by reinforcing sectors of strong response, attenuating others....
Definition DetectorOp.cpp:324
Essential class for storing radar data.
Definition Data.h:300
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition DataSelector.cpp:44
Definition palette-manager.h:41