nx_server_plugin_sdk 1.0 Server Plugin 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 std::string manifestString() const override;
32
33 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
34
35 virtual bool pushCompressedVideoFrame(
36 nx::sdk::Ptr<const nx::sdk::analytics::ICompressedVideoPacket> videoFrame) override;
37
38 private:
39 void processVideoFrame(
40 nx::sdk::Ptr<const nx::sdk::analytics::IDataPacket> videoFrame,
41 const char* func);
42
43 void processFrameMotion(
44 nx::sdk::Ptr<nx::sdk::IList<nx::sdk::analytics::IMetadataPacket>> metadataPacketList);
45
46 bool hasMotionUnderObject(
47 int objectColumn,
48 int objectRow,
49 nx::sdk::Ptr<nx::sdk::analytics::IMotionMetadataPacket> motionMetadataPacket);
50
51 private:
52 Engine* const m_engine;
53
54 int m_frameCounter = 0;
55
56 struct DeviceAgentSettings
57 {
58 std::atomic<int> objectWidthInMotionCells{8};
59 std::atomic<int> objectHeightInMotionCells{8};
60
61 std::atomic<std::chrono::milliseconds> additionalFrameProcessingDelayMs{
62 std::chrono::milliseconds::zero()};
63 };
64
65 DeviceAgentSettings m_deviceAgentSettings;
66 std::vector<nx::sdk::Uuid> m_objectTrackIdForObjectCells;
67 };
68
69 } // namespace motion_metadata
70 } // namespace stub
71 } // namespace analytics
72 } // namespace vms_server_plugins
73 } // namespace nx
nx::vms_server_plugins::analytics::stub::motion_metadata::DeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(nx::sdk::Ptr< const nx::sdk::analytics::ICompressedVideoPacket > videoFrame) override
Definition: device_agent.cpp:126
nx::vms_server_plugins::analytics::stub::motion_metadata::Engine
Definition: engine.h:18
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:36
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::sdk::Result
Definition: result.h:52
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:61
nx::sdk::IList
Definition: i_list.h:10
nx::vms_server_plugins::analytics::stub::motion_metadata::DeviceAgent
Definition: device_agent.h:24