WSF
WsfImageProcessor.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFIMAGEPROCESSOR_HPP
13#define WSFIMAGEPROCESSOR_HPP
14
15#include "wsf_mil_export.h"
16
17class WsfFilter;
18#include "WsfImage.hpp"
20class WsfSensor;
21class WsfTrack;
22
24class WSF_MIL_EXPORT WsfImageProcessor : public WsfMessageProcessor
25{
26public:
28
39
41 ~WsfImageProcessor() override;
42
43 WsfProcessor* Clone() const override;
44
45 bool Initialize(double aSimTime) override;
46
47 bool ProcessInput(UtInput& aInput) override;
48
49 bool ProcessMessage(double aSimTime, const WsfMessage& aMessage) override;
50
51 bool ReceiveMessage(double aSimTime, const WsfMessage& aMessage) override;
52
53 void TurnOff(double aSimTime) override;
54
56 double GetCoastTime() const { return mCoastTime; }
57
59 {
60 public:
61 ObjectTest() = default;
62
63 void SetObject(const WsfImage::Object* aObjectPtr, const WsfImage* aImagePtr)
64 {
65 mObjectPtr = aObjectPtr;
66 mImagePtr = aImagePtr;
67 mReqDetected = 0.0;
68 mReqClassified = 0.0;
69 mReqIdentified = 0.0;
70 mDraw = 1.0;
71
72 mResult = "UNDETECTED";
73 mFinalResult = "UNDETECTED";
74 mPreviouslyClassified = false;
75 mPreviouslyIdentified = false;
76 }
77
78 std::string GetResult() const { return mResult; }
79 void SetResult(const std::string& aResult) { mResult = aResult; }
80 std::string GetFinalResult() const { return mFinalResult; }
81 void SetFinalResult(const std::string& aResult) { mFinalResult = aResult; }
82 std::string GetPerceivedType() const { return mPerceivedType; }
83 void SetPerceivedType(const std::string& aPerceivedType) { mPerceivedType = aPerceivedType; }
84
85 double GetDraw() const { return mDraw; }
86 double GetRequiredDetected() const { return mReqDetected; }
87 double GetRequiredClassified() const { return mReqClassified; }
88 double GetRequiredIdentified() const { return mReqIdentified; }
89
90 void SetDraw(double aDraw) { mDraw = aDraw; }
91 void SetRequiredDetected(double aReqDetected) { mReqDetected = aReqDetected; }
92 void SetRequiredClassified(double aReqClassified) { mReqClassified = aReqClassified; }
93 void SetRequiredIdentified(double aReqIdentified) { mReqIdentified = aReqIdentified; }
94
95 bool GetPreviouslyClassified() const { return mPreviouslyClassified; }
96 bool GetPreviouslyIdentified() const { return mPreviouslyIdentified; }
97 void SetPreviouslyClassified(bool aPreviouslyClassified) { mPreviouslyClassified = aPreviouslyClassified; }
98 void SetPreviouslyIdentified(bool aPreviouslyIdentified) { mPreviouslyIdentified = aPreviouslyIdentified; }
99
101 const WsfImage* mImagePtr{nullptr};
102
103 private:
104 std::string mResult;
105 std::string mFinalResult;
106 std::string mPerceivedType;
107 double mReqDetected{0.0};
108 double mReqClassified{0.0};
109 double mReqIdentified{0.0};
110 double mDraw{0.0};
111
112 bool mPreviouslyClassified{false};
113 bool mPreviouslyIdentified{false};
114 };
115
116 class State
117 {
118 public:
121 unsigned int mStreamNumber{0};
122 };
123
124 class Status
125 {
126 public:
128 : mStateEntryTime(-1.0E+30)
130 , mLastGoodUpdateTime(-1.0E+30)
132 , mCoastingStartTime(-1.0E+30)
134 , mTruthName(aTruthName)
135 , mIsStale(false)
136 {
137 }
138
139 WsfStringId TruthName() const { return mTruthName; }
140
141 void EnterState(TargetRecognitionState aNewState, double aStateEntryTime, double aMinimumTimeInState)
142 {
143 mCurrentState = aNewState;
144 mStateEntryTime = aStateEntryTime;
145 mMinimumTimeInState = aMinimumTimeInState;
146 }
147
148 void SetLastGoodUpdateTime(double aSimTime)
149 {
150 mLastGoodUpdateTime = aSimTime;
151 mCoastingStartTime = -1.0E-30;
152 mIsStale = false;
153 }
154
155 void SetStale() { mIsStale = true; }
156 bool IsStale() const { return mIsStale; }
157
160 bool CoastTimeExceeded(double aSimTime, TargetRecognitionState aState, double aCoastTime);
161
163
165 double StateEntryTime() const { return mStateEntryTime; }
166
168
170 double mStateEntryTime{-1.0E+30};
174 double mLastGoodUpdateTime{-1.0E+30};
178 double mCoastingStartTime{-1.0E+30};
184 bool mIsStale{false};
185 };
186
187protected:
190
191 virtual void ImageProcessingCompleted(double aSimTime, const WsfImage& aImage);
192
193 virtual void ImageProcessingInitiated(double aSimTime, const WsfImage& aImage);
194
195 virtual bool IsDetectable(double aSimTime, const WsfImage& aImage, const WsfImage::Object& aObject);
196
197 virtual void TrackDropped(double aSimTime, const WsfTrack& aTrack);
198
199 virtual void UpdateTrack(double aSimTime, WsfTrack& aTrack, const WsfImage& aImage, const WsfImage::Object& aObject);
200
201private:
202 void ClearStateList();
203
204 void ProcessImage(double aSimTime, WsfImage& aImage);
205
206 void PurgeOldTracks(double aSimTime, double aImageTime, WsfSensor* aSensorPtr);
207
208 double ComputeProbabilityOfDetection(double aObjectSize) const;
209 double ComputeProbabilityOfClassification(double aObjectSize) const;
210 double ComputeProbabilityOfIdentification(double aObjectSize) const;
211
212 void EvaluateObjectState(double aSimTime, const WsfImage& aImage, const WsfImage::Object& aObject);
213
215 WsfFilter* mFilterPtr{nullptr};
216
218 double mCoastTime{0.0};
219
221 int mMessageLength{0};
222
224 int mMessagePriority{0};
225
226 bool mReportsVelocity{true}; // TODO for now
227 bool mReportsSide{false};
228 bool mReportsType{false};
229 bool mReportsBearingElevation{false};
230 bool mTargetRecognitionEnabled{false};
231
235
236 bool mIncludeUnstableCovariance{false};
237 bool mIncludeUnstableResidualCovariance{false};
239
242 using StateList = std::map<size_t, State*>;
243 StateList mStateList;
244
246
247 WsfVariable<double> mMinDetectPixelCount{0.0};
248 WsfVariable<double> mMinClassPixelCount{0.0};
249 WsfVariable<double> mMinIdentPixelCount{0.0};
251
254 WsfVariable<double> mAverageAspectRatio{4.0};
255
257
258 WsfVariable<double> mDetectionSAF{1.0};
259 WsfVariable<double> mClassificationSAF{4.0};
260 WsfVariable<double> mIdentificationSAF{6.4};
262
264
265 WsfVariable<double> mDetectionDelayTime{0.0};
266 WsfVariable<double> mClassificationDelayTime{0.0};
267 WsfVariable<double> mIdentificationDelayTime{0.0};
269
271
272 WsfVariable<double> mTransitionCoastTime{0.0};
273 WsfVariable<double> mDetectionCoastTime{0.0};
274 WsfVariable<double> mClassificationCoastTime{0.0};
275 WsfVariable<double> mIdentificationCoastTime{0.0};
277
278 bool mShowStateTransitions{false};
279
280 using StatusList = std::map<size_t, Status>;
281 StatusList mStatusList;
282
283 // The 'ObjectTest' instance must be a member variable because it must persist between the
284 // calls to IsDetectable() and UpdateTrack() from the base class.
285 ObjectTest mObjectTest;
286};
287
288#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Implement a filter as an adapter.
Definition WsfFilter.hpp:24
bool GetPreviouslyClassified() const
Definition WsfImageProcessor.hpp:95
void SetPreviouslyClassified(bool aPreviouslyClassified)
Definition WsfImageProcessor.hpp:97
void SetPreviouslyIdentified(bool aPreviouslyIdentified)
Definition WsfImageProcessor.hpp:98
double GetRequiredClassified() const
Definition WsfImageProcessor.hpp:87
bool GetPreviouslyIdentified() const
Definition WsfImageProcessor.hpp:96
void SetObject(const WsfImage::Object *aObjectPtr, const WsfImage *aImagePtr)
Definition WsfImageProcessor.hpp:63
void SetResult(const std::string &aResult)
Definition WsfImageProcessor.hpp:79
void SetPerceivedType(const std::string &aPerceivedType)
Definition WsfImageProcessor.hpp:83
void SetRequiredIdentified(double aReqIdentified)
Definition WsfImageProcessor.hpp:93
void SetFinalResult(const std::string &aResult)
Definition WsfImageProcessor.hpp:81
std::string GetResult() const
Definition WsfImageProcessor.hpp:78
void SetDraw(double aDraw)
Definition WsfImageProcessor.hpp:90
void SetRequiredDetected(double aReqDetected)
Definition WsfImageProcessor.hpp:91
std::string GetFinalResult() const
Definition WsfImageProcessor.hpp:80
const WsfImage::Object * mObjectPtr
Definition WsfImageProcessor.hpp:100
const WsfImage * mImagePtr
Definition WsfImageProcessor.hpp:101
double GetRequiredDetected() const
Definition WsfImageProcessor.hpp:86
double GetRequiredIdentified() const
Definition WsfImageProcessor.hpp:88
double GetDraw() const
Definition WsfImageProcessor.hpp:85
void SetRequiredClassified(double aReqClassified)
Definition WsfImageProcessor.hpp:92
std::string GetPerceivedType() const
Definition WsfImageProcessor.hpp:82
Definition WsfImageProcessor.hpp:117
WsfTrack * mTrackPtr
Definition WsfImageProcessor.hpp:119
unsigned int mStreamNumber
Definition WsfImageProcessor.hpp:121
WsfFilter * mFilterPtr
Definition WsfImageProcessor.hpp:120
double mMinimumTimeInState
The minimum time that must be spent in the current state before a transition to a higher state can oc...
Definition WsfImageProcessor.hpp:172
WsfStringId TruthName() const
Definition WsfImageProcessor.hpp:139
void SetStale()
Definition WsfImageProcessor.hpp:155
TargetRecognitionState CurrentState() const
Definition WsfImageProcessor.hpp:164
TargetRecognitionState CoastingState() const
Definition WsfImageProcessor.hpp:162
double mLastGoodUpdateTime
The last time when a detection was registered that met the criteria for the current state.
Definition WsfImageProcessor.hpp:174
TargetRecognitionState mCurrentState
The current state.
Definition WsfImageProcessor.hpp:176
Status(WsfStringId aTruthName=WsfStringId())
Definition WsfImageProcessor.hpp:127
double EarliestStateExitTime() const
Definition WsfImageProcessor.hpp:167
double mCoastingStartTime
The time when coasting started.
Definition WsfImageProcessor.hpp:178
void SetLastGoodUpdateTime(double aSimTime)
Definition WsfImageProcessor.hpp:148
void EnterState(TargetRecognitionState aNewState, double aStateEntryTime, double aMinimumTimeInState)
Definition WsfImageProcessor.hpp:141
bool mIsStale
True if the object is stale (didn't exist in the last image).
Definition WsfImageProcessor.hpp:184
double mStateEntryTime
The time when the transition occurred into the current state.
Definition WsfImageProcessor.hpp:170
double StateEntryTime() const
Definition WsfImageProcessor.hpp:165
TargetRecognitionState mCoastingState
The state (quality) of the update associated with mLastFailedUpdateTime;.
Definition WsfImageProcessor.hpp:180
bool IsStale() const
Definition WsfImageProcessor.hpp:156
WsfStringId mTruthName
The name id of the underlying platform represented by the object.
Definition WsfImageProcessor.hpp:182
A specialization of WsfMessageProcessor that implements an example image processor.
Definition WsfImageProcessor.hpp:25
virtual void ImageProcessingInitiated(double aSimTime, const WsfImage &aImage)
Definition WsfImageProcessor.cpp:434
virtual bool IsDetectable(double aSimTime, const WsfImage &aImage, const WsfImage::Object &aObject)
Definition WsfImageProcessor.cpp:459
WsfImageProcessor(WsfScenario &aScenario)
Constructor.
Definition WsfImageProcessor.cpp:50
virtual void ImageProcessingCompleted(double aSimTime, const WsfImage &aImage)
Definition WsfImageProcessor.cpp:381
double GetCoastTime() const
Return the value of 'coast_time'.
Definition WsfImageProcessor.hpp:56
TargetRecognitionState
Definition WsfImageProcessor.hpp:30
@ cST_WAITING_DETECTION
Definition WsfImageProcessor.hpp:32
@ cST_IDENTIFIED
Definition WsfImageProcessor.hpp:37
@ cST_DETECTED
Definition WsfImageProcessor.hpp:33
@ cST_WAITING_CLASSIFICATION
Definition WsfImageProcessor.hpp:34
@ cST_CLASSIFIED
Definition WsfImageProcessor.hpp:35
@ cST_WAITING_IDENTIFICATION
Definition WsfImageProcessor.hpp:36
@ cST_UNDETECTED
Definition WsfImageProcessor.hpp:31
virtual void TrackDropped(double aSimTime, const WsfTrack &aTrack)
Definition WsfImageProcessor.cpp:485
virtual void UpdateTrack(double aSimTime, WsfTrack &aTrack, const WsfImage &aImage, const WsfImage::Object &aObject)
Definition WsfImageProcessor.cpp:509
WsfImageProcessor & operator=(const WsfImageProcessor &)=delete
A nested class that represents the appearance of a single object (platform) in the image.
Definition WsfImage.hpp:40
Definition WsfImage.hpp:36
WsfProcessor * Clone() const override
Definition WsfMessageProcessor.cpp:70
bool Initialize(double aSimTime) override
Definition WsfMessageProcessor.cpp:77
bool ProcessMessage(double aSimTime, const WsfMessage &aMessage) override
Definition WsfMessageProcessor.cpp:198
bool ReceiveMessage(double aSimTime, const WsfMessage &aMessage) override
Definition WsfMessageProcessor.cpp:231
WsfMessageProcessor(WsfScenario &aScenario)
Definition WsfMessageProcessor.cpp:31
bool ProcessInput(UtInput &aInput) override
Definition WsfMessageProcessor.cpp:103
void TurnOff(double aSimTime) override
Definition WsfMessageProcessor.cpp:323
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
Definition WsfProcessor.hpp:39
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfSensor.hpp:92
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
Copyrights Multiple, All Rights Reserved