DFX Extraction library v4.12.0
enabling applications to perform DFX blood flow analysis
Collector.h
1 /*
2  * Copyright (c) 2016-2019, Nuralogix Corp.
3  * All Rights reserved
4  *
5  * THIS SOFTWARE IS LICENSED BY AND IS THE CONFIDENTIAL AND
6  * PROPRIETARY PROPERTY OF NURALOGIX CORP. IT IS
7  * PROTECTED UNDER THE COPYRIGHT LAWS OF THE USA, CANADA
8  * AND OTHER FOREIGN COUNTRIES. THIS SOFTWARE OR ANY
9  * PART THEREOF, SHALL NOT, WITHOUT THE PRIOR WRITTEN CONSENT
10  * OF NURALOGIX CORP, BE USED, COPIED, DISCLOSED,
11  * DECOMPILED, DISASSEMBLED, MODIFIED OR OTHERWISE TRANSFERRED
12  * EXCEPT IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF A
13  * NURALOGIX CORP SOFTWARE LICENSE AGREEMENT.
14  */
15 #pragma once
16 #ifndef LIBDFX_COLLECTOR_H
17 #define LIBDFX_COLLECTOR_H
18 
19 #include "dfx/ChunkData.h"
20 #include "dfx/Face.h"
21 #include "dfx/Frame.h"
22 #include "dfx/MeasurementResult.h"
23 
24 #include <functional>
25 #include <map>
26 #include <memory>
27 #include <string>
28 #include <vector>
29 
34 namespace dfx {
35 
36 class Frame;
37 
41 enum class ConstraintResult : char {
42  Good = 0,
43  Warn = 1,
44  Error = 2
45 };
46 
53 enum class CollectorState : char {
54  Waiting = 0,
55  Collecting = 1,
56  ChunkReady = 2,
57  Completed = 3,
58  Error = 4,
59 };
60 
70 class Collector {
71  public:
75  virtual ~Collector() {
76  // Empty but necessary for vtable
77  }
78 
86  virtual std::shared_ptr<dfx::Frame> createFrame(const dfx::VideoFrame &videoFrame) = 0;
87 
103  virtual CollectorState startCollection() = 0;
104 
113  virtual bool prepareMeasurement(const std::vector<uint8_t>& createMeasurementPayload) = 0;
114 
127  virtual CollectorState getCollectorState() = 0;
128 
137  virtual std::string getMode() const = 0;
138 
159  virtual bool setTargetFPS(float targetFPS) = 0;
160 
173  virtual bool setChunkDurationSeconds(float chunkDurationSeconds) = 0;
174 
180  virtual float getChunkDurationSeconds() = 0;
181 
190  virtual bool setNumberChunks(uint32_t numberChunks) = 0;
191 
198  virtual uint32_t getNumberChunks() = 0;
199 
213  virtual bool enableConstraint(const std::string &constraintID) = 0;
214 
225  virtual bool disableConstraint(const std::string &constraintID) = 0;
226 
232  virtual std::vector<std::string> getEnabledConstraints() = 0;
233 
242  virtual std::vector<std::string> getAvailableConstraints() const = 0;
243 
256  virtual ConstraintResult checkConstraints(std::shared_ptr<dfx::Frame> &frame, std::vector<std::pair<std::string,dfx::ConstraintResult>> &results) = 0;
257 
268  virtual std::string getConstraintErrorMessage(const std::string &violationID) = 0;
269 
281  virtual bool setConstraintsConfig(const std::string& key, const std::string &propertyValue) = 0;
282 
293  virtual std::string getConstraintsConfig(const std::string& key) = 0;
294 
304  virtual std::vector<std::string> getRequiredPosePointIDs() const = 0;
305 
318  virtual CollectorState defineRegions(std::shared_ptr<dfx::Frame> &frame) = 0;
319 
331  virtual CollectorState extractChannels(std::shared_ptr<dfx::Frame> &frame) = 0;
332 
339  virtual bool isChunkReady() const = 0;
340 
359  virtual int32_t numberFramesNeeded() const = 0;
360 
374  virtual std::shared_ptr<dfx::ChunkData> getChunkData() = 0;
375 
383  virtual std::shared_ptr<dfx::MeasurementResult> decodeMeasurementResult(const std::vector<uint8_t>& measurementResponse) = 0;
384 
400  virtual bool setProperty(const std::string &key, const std::string &value) = 0;
401 
411  virtual std::string getProperty(const std::string& key) = 0;
412 
416  virtual void removeProperty(const std::string& key) = 0;
417 
427  virtual std::map<std::string, std::string> getProperties() = 0;
428 
435  virtual std::string getLastErrorMessage() = 0;
436 
445  virtual void cancelCollection() = 0;
446 
460  virtual void stopCollection() = 0;
461 
472  virtual void forceComplete() = 0;
473 
483  virtual void resetCollection() = 0;
484 
493  virtual bool setFaceAttribute(const std::string& faceID, FaceAttribute key, FaceAttributeValue value) = 0;
494 
503  virtual bool setFaceAttribute(const std::string& faceID, FaceAttribute key, double value) = 0;
504 
514  virtual bool setCloudResultsFeedback(const std::string& jsonCloudResults) = 0;
515 
523  virtual bool initializeModel(int8_t modelType, const std::vector<unsigned char> &data) = 0;
524 };
525 } // namespace dfx
526 
527 #endif // LIBDFX_COLLECTOR_H
dfx::CollectorState::Completed
@ Completed
dfx::Collector::defineRegions
virtual CollectorState defineRegions(std::shared_ptr< dfx::Frame > &frame)=0
Define the regions of interest based upon the MPEG-4 Facial Data Points.
dfx::ConstraintResult::Good
@ Good
dfx::Collector::isChunkReady
virtual bool isChunkReady() const =0
Identifies when a measurement has collected sufficient information to make a server request.
dfx::Collector::setConstraintsConfig
virtual bool setConstraintsConfig(const std::string &key, const std::string &propertyValue)=0
Configures the constraint system properties.
dfx::Collector::resetCollection
virtual void resetCollection()=0
Resets the measurement state to construct a new chunk.
dfx::Collector::getLastErrorMessage
virtual std::string getLastErrorMessage()=0
If there was an error getLastErrorMessage may contain more information about why the error occurred.
dfx::Collector::setNumberChunks
virtual bool setNumberChunks(uint32_t numberChunks)=0
Sets number of chunks before the measurement is complete.
dfx::Collector::initializeModel
virtual bool initializeModel(int8_t modelType, const std::vector< unsigned char > &data)=0
Configures a model within the Collector.
dfx::Collector
Collector extracts region channel information from video frames for server signal processing.
Definition: Collector.h:70
dfx::CollectorState::ChunkReady
@ ChunkReady
dfx::Collector::cancelCollection
virtual void cancelCollection()=0
Cancels the current collection.
dfx::CollectorState::Collecting
@ Collecting
dfx::Collector::getProperty
virtual std::string getProperty(const std::string &key)=0
Returns a metadata property by key name if it exists.
dfx::Collector::setTargetFPS
virtual bool setTargetFPS(float targetFPS)=0
Identifies what the anticipated FPS is suppose to be.
dfx::Collector::getAvailableConstraints
virtual std::vector< std::string > getAvailableConstraints() const =0
Obtain all available constraint IDs.
dfx::Collector::getConstraintsConfig
virtual std::string getConstraintsConfig(const std::string &key)=0
Obtains a constraint system property.
dfx::Collector::getEnabledConstraints
virtual std::vector< std::string > getEnabledConstraints()=0
Returns the currently enabled constraints.
dfx::Collector::enableConstraint
virtual bool enableConstraint(const std::string &constraintID)=0
Enable constraint handling for the identified constraint.
dfx::Collector::getNumberChunks
virtual uint32_t getNumberChunks()=0
Returns the total number of chunks the collector will process for this measurement.
dfx::Collector::extractChannels
virtual CollectorState extractChannels(std::shared_ptr< dfx::Frame > &frame)=0
Extracts the channels of interest from the video frame and regions of interest.
dfx::Collector::disableConstraint
virtual bool disableConstraint(const std::string &constraintID)=0
Disable a constraint for the identified constraint.
dfx::Collector::removeProperty
virtual void removeProperty(const std::string &key)=0
Removes a metadata property by key name if it exists.
dfx::Collector::decodeMeasurementResult
virtual std::shared_ptr< dfx::MeasurementResult > decodeMeasurementResult(const std::vector< uint8_t > &measurementResponse)=0
Decodes the binary measurement response payload from the server into a MeasurementResult.
dfx::CollectorState
CollectorState
A Collector state indicates whether a Collector is in error or ready to collect data.
Definition: Collector.h:53
dfx::Collector::startCollection
virtual CollectorState startCollection()=0
When the client is ready to start a measurement they will notify the collector to start collecting da...
dfx::Collector::forceComplete
virtual void forceComplete()=0
Forces the completion of a collection.
dfx::VideoFrame
Represents the internal structure for how image frames are passed to the DFX Engine since there is li...
Definition: VideoFrame.h:35
dfx::ConstraintResult
ConstraintResult
The possible constraint return values.
Definition: Collector.h:41
dfx::Error
Definition: DFXErrors.h:34
dfx::Collector::getChunkData
virtual std::shared_ptr< dfx::ChunkData > getChunkData()=0
The measurement chunk data which has been collected up for the current chunk until this point.
dfx::Collector::getChunkDurationSeconds
virtual float getChunkDurationSeconds()=0
Returns the desired collected chunk duration in seconds.
dfx::Collector::createFrame
virtual std::shared_ptr< dfx::Frame > createFrame(const dfx::VideoFrame &videoFrame)=0
Creates a Frame from a user supplied video frame.
dfx::Collector::setProperty
virtual bool setProperty(const std::string &key, const std::string &value)=0
Client applications wishing to associate their own metadata properties can associate key=value string...
dfx::Collector::setFaceAttribute
virtual bool setFaceAttribute(const std::string &faceID, FaceAttribute key, FaceAttributeValue value)=0
Add user data information to a payload using FaceAttribute key and values.
dfx::Collector::getProperties
virtual std::map< std::string, std::string > getProperties()=0
Obtains the Chunk metadata for this measurement request.
dfx::Collector::~Collector
virtual ~Collector()
Collector destructor.
Definition: Collector.h:75
dfx::CollectorState::Waiting
@ Waiting
dfx
Definition: ChunkData.h:21
dfx::Collector::getConstraintErrorMessage
virtual std::string getConstraintErrorMessage(const std::string &violationID)=0
Obtain a message which represents the violation ID.
dfx::Collector::checkConstraints
virtual ConstraintResult checkConstraints(std::shared_ptr< dfx::Frame > &frame, std::vector< std::pair< std::string, dfx::ConstraintResult >> &results)=0
Check for constraint violations.
dfx::Collector::getRequiredPosePointIDs
virtual std::vector< std::string > getRequiredPosePointIDs() const =0
Return the set of pose points for the configured study.
dfx::Collector::getMode
virtual std::string getMode() const =0
Returns the operating mode of the Collector.
dfx::Collector::setCloudResultsFeedback
virtual bool setCloudResultsFeedback(const std::string &jsonCloudResults)=0
Provide the cloud results to the Collector to potentially improve the result.
dfx::Collector::setChunkDurationSeconds
virtual bool setChunkDurationSeconds(float chunkDurationSeconds)=0
Sets the desired collected chunk duration in seconds.
dfx::Collector::getCollectorState
virtual CollectorState getCollectorState()=0
The current internal state of this measurement collector.
dfx::Collector::numberFramesNeeded
virtual int32_t numberFramesNeeded() const =0
The approximate number of additional video frames required before sufficient information has been col...
dfx::Collector::prepareMeasurement
virtual bool prepareMeasurement(const std::vector< uint8_t > &createMeasurementPayload)=0
When the client creates a new Measurement with the API, the Collector should be prepared with the API...
dfx::Collector::stopCollection
virtual void stopCollection()=0
Stop the current collection.
dfx::ConstraintResult::Warn
@ Warn