nx_metadata_sdk 1.0 Metadata SDK

device_agent.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <atomic>
6 #include <chrono>
7
8 #include <nx/sdk/analytics/helpers/consuming_device_agent.h>
9 #include <nx/sdk/analytics/i_motion_metadata_packet.h>
10
11 #include "engine.h"
12
13 namespace nx {
14 namespace vms_server_plugins {
15 namespace analytics {
16 namespace stub {
17 namespace motion_metadata {
18
19 const std::string kMotionVisualizationObjectType{"nx.stub.motionVisualization"};
20 const std::string kAdditionalFrameProcessingDelayMsSetting{"additionalFrameProcessingDelayMs"};
21 const std::string kObjectWidthInMotionCellsSetting{"objectWidthInMotionCells"};
22 const std::string kObjectHeightInMotionCellsSetting{"objectHeightInMotionCells"};
23
24 class DeviceAgent: public nx::sdk::analytics::ConsumingDeviceAgent
25 {
26 public:
27 DeviceAgent(Engine* engine, const nx::sdk::IDeviceInfo* deviceInfo);
28 virtual ~DeviceAgent() override;
29
30 protected:
31 virtual void doSetNeededMetadataTypes(
32 nx::sdk::Result<void>* outValue,
33 const nx::sdk::analytics::IMetadataTypes* neededMetadataTypes) override;
34
35 virtual std::string manifestString() const override;
36
37 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
38
39 virtual bool pushCompressedVideoFrame(
40 const nx::sdk::analytics::ICompressedVideoPacket* videoFrame) override;
41
42 private:
43 void processVideoFrame(const nx::sdk::analytics::IDataPacket* videoFrame, const char* func);
44
45 void processFrameMotion(
46 nx::sdk::Ptr<nx::sdk::IList<nx::sdk::analytics::IMetadataPacket>> metadataPacketList);
47
48 bool hasMotionUnderObject(
49 int objectColumn,
50 int objectRow,
51 nx::sdk::Ptr<nx::sdk::analytics::IMotionMetadataPacket> motionMetadataPacket);
52
53 private:
54 Engine* const m_engine;
55
56 int m_frameCounter = 0;
57
58 struct DeviceAgentSettings
59 {
60 std::atomic<int> objectWidthInMotionCells{8};
61 std::atomic<int> objectHeightInMotionCells{8};
62
63 std::atomic<std::chrono::milliseconds> additionalFrameProcessingDelayMs{
64 std::chrono::milliseconds::zero()};
65 };
66
67 DeviceAgentSettings m_deviceAgentSettings;
68 std::vector<nx::sdk::Uuid> m_objectTrackIdForObjectCells;
69 };
70
71 } // namespace motion_metadata
72 } // namespace stub
73 } // namespace analytics
74 } // namespace vms_server_plugins
75 } // namespace nx
nx::vms_server_plugins::analytics::stub::motion_metadata::Engine
Definition: engine.h:18
nx::sdk::analytics::ICompressedVideoPacket
Definition: i_compressed_video_packet.h:34
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:38
nx::sdk::analytics::IMetadataTypes
Definition: i_metadata_types.h:13
nx::sdk::Result< void >
Definition: result.h:81
nx::sdk::IDeviceInfo
Definition: i_device_info.h:14
nx::sdk::Result
Definition: result.h:47
nx
Definition: apple_utils.h:6
nx::vms_server_plugins::analytics::stub::motion_metadata::DeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived() override
Definition: device_agent.cpp:60
nx::sdk::analytics::IDataPacket
Definition: i_data_packet.h:17
nx::vms_server_plugins::analytics::stub::motion_metadata::DeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(const nx::sdk::analytics::ICompressedVideoPacket *videoFrame) override
Definition: device_agent.cpp:125
nx::sdk::IList
Definition: i_list.h:9
nx::vms_server_plugins::analytics::stub::motion_metadata::DeviceAgent
Definition: device_agent.h:24