DFX Extraction library v4.14.5
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 
116  virtual bool prepareMeasurement(const std::vector<uint8_t>& createMeasurementPayload) = 0;
117 
130  virtual CollectorState getCollectorState() = 0;
131 
140  virtual std::string getMode() const = 0;
141 
162  virtual bool setTargetFPS(float targetFPS) = 0;
163 
176  virtual bool setChunkDurationSeconds(float chunkDurationSeconds) = 0;
177 
183  virtual float getChunkDurationSeconds() = 0;
184 
193  virtual bool setNumberChunks(uint32_t numberChunks) = 0;
194 
201  virtual uint32_t getNumberChunks() = 0;
202 
216  virtual bool enableConstraint(const std::string &constraintID) = 0;
217 
228  virtual bool disableConstraint(const std::string &constraintID) = 0;
229 
235  virtual std::vector<std::string> getEnabledConstraints() = 0;
236 
245  virtual std::vector<std::string> getAvailableConstraints() const = 0;
246 
259  virtual ConstraintResult checkConstraints(std::shared_ptr<dfx::Frame> &frame, std::vector<std::pair<std::string,dfx::ConstraintResult>> &results) = 0;
260 
271  virtual std::string getConstraintErrorMessage(const std::string &violationID) = 0;
272 
284  virtual bool setConstraintsConfig(const std::string& key, const std::string &propertyValue) = 0;
285 
296  virtual std::string getConstraintsConfig(const std::string& key) = 0;
297 
307  virtual std::vector<std::string> getRequiredPosePointIDs() const = 0;
308 
321  virtual CollectorState defineRegions(std::shared_ptr<dfx::Frame> &frame) = 0;
322 
334  virtual CollectorState extractChannels(std::shared_ptr<dfx::Frame> &frame) = 0;
335 
342  virtual bool isChunkReady() const = 0;
343 
362  virtual int32_t numberFramesNeeded() const = 0;
363 
377  virtual std::shared_ptr<dfx::ChunkData> getChunkData() = 0;
378 
389  virtual std::shared_ptr<dfx::MeasurementResult> decodeMeasurementResult(const std::vector<uint8_t>& measurementResponse) = 0;
390 
406  virtual bool setProperty(const std::string &key, const std::string &value) = 0;
407 
417  virtual std::string getProperty(const std::string& key) = 0;
418 
422  virtual void removeProperty(const std::string& key) = 0;
423 
433  virtual std::map<std::string, std::string> getProperties() = 0;
434 
441  virtual std::string getLastErrorMessage() = 0;
442 
451  virtual void cancelCollection() = 0;
452 
466  virtual void stopCollection() = 0;
467 
478  virtual void forceComplete() = 0;
479 
489  virtual void resetCollection() = 0;
490 
499  virtual bool setFaceAttribute(const std::string& faceID, FaceAttribute key, FaceAttributeValue value) = 0;
500 
509  virtual bool setFaceAttribute(const std::string& faceID, FaceAttribute key, double value) = 0;
510 
520  virtual bool setCloudResultsFeedback(const std::string& jsonCloudResults) = 0;
521 
529  virtual bool initializeModel(int8_t modelType, const std::vector<unsigned char> &data) = 0;
530 };
531 } // namespace dfx
532 
533 #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