1#ifndef YODAU_BACKEND_STREAM_HPP
2#define YODAU_BACKEND_STREAM_HPP
9#include <unordered_map>
15
16
17
18
19
20
21
22
35
36
37
38
39
50
51
52
53
54
55
56
57
58
59
60
61
62
63
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
83 std::string path, std::string name,
const std::string& type_str = {},
93
94
95
96
97
101
102
103
104
105
106
110
111
112
113
114
115
116
117
118
119
120
124
125
126
127
128
132
133
134
135
136
140
141
145
146
150
151
155
156
157
158
162
163
164
165
166
167
168
169 void dump(std::ostream& out,
bool connections =
false)
const;
172
173
174
175
176
177
181
182
183
184
188
189
190
191
195
196
197
198
199
200
201
205
206
207
208
212
213
214
215
216
217
237
238
239
240
Simple interactive CLI (REPL) for controlling a stream_manager.
void cmd_start_stream(const std::vector< std::string > &args) const
Handler for start-stream.
void dispatch_command(const std::string &cmd, const std::vector< std::string > &args) const
Dispatch a command to its handler.
void cmd_set_line(const std::vector< std::string > &args) const
Handler for set-line.
int run() const
Run the interactive command loop.
void cmd_add_line(const std::vector< std::string > &args) const
Handler for add-line.
static cxxopts::ParseResult parse_with_cxxopts(const std::string &cmd, const std::vector< std::string > &args, cxxopts::Options &options)
Parse command arguments using cxxopts.
backend::stream_manager & stream_mgr
Stream manager controlled by this CLI.
void cmd_stop_stream(const std::vector< std::string > &args) const
Handler for stop-stream.
void cmd_list_streams(const std::vector< std::string > &args) const
Handler for list-streams.
void cmd_add_stream(const std::vector< std::string > &args) const
Handler for add-stream.
void cmd_list_lines(const std::vector< std::string > &args) const
Handler for list-lines.
cli_client(backend::stream_manager &mgr)
Construct a CLI client operating on an existing manager.
static std::vector< std::string > tokenize(const std::string &line)
Split a line into whitespace-separated tokens.
Central coordinator for streams, geometry, frame processing and events.
std::function< void(const std::string &stream_name, frame &&f)> manual_push_fn
Hook for manual frame pushing.
Represents a single video stream and its analytic connections.
std::string get_name() const
Get logical stream name.
stream & operator=(stream &&other) noexcept
Move-assign a stream.
std::string name
Logical stream name.
std::vector< line_ptr > lines_snapshot() const
Get a snapshot of all connected lines.
void activate(stream_pipeline pipeline=stream_pipeline::automatic)
Activate the stream in a pipeline.
stream(std::string path, std::string name, const std::string &type_str={}, bool loop=true)
Construct a stream description.
stream & operator=(const stream &)=delete
Non-copyable (streams manage shared connections / mutex).
stream(stream &&other) noexcept
Move-construct a stream.
bool loop
Looping behavior for file streams.
void dump(std::ostream &out, bool connections=false) const
Dump stream metadata to an output stream.
std::vector< std::string > line_names() const
Get a list of names of all connected lines.
bool is_looping() const
Whether the stream is configured to loop on exhaustion.
void connect_line(line_ptr line)
Connect a geometric line to this stream.
stream_pipeline pipeline() const
Get current pipeline activity of the stream.
stream(const stream &)=delete
Non-copyable (streams manage shared connections / mutex).
std::unordered_map< std::string, line_ptr > lines
Connected lines keyed by their logical names.
void deactivate()
Deactivate the stream.
std::string path
Path or URL to the stream source.
static std::string type_name(const stream_type type)
Convert a stream type to a canonical textual name.
static stream_type identify(const std::string &path)
Identify stream type from a path/URL.
std::string get_path() const
Get stream path or URL.
stream_type get_type() const
Get the stream transport/source type.
stream_type type
Detected or user-specified stream type.
std::mutex lines_mtx
Mutex guarding lines.
static std::string pipeline_name(const stream_pipeline pipeline)
Convert a pipeline mode to its textual name.
stream_pipeline active
Currently active pipeline mode.
static yodau::backend::tripwire_dir parse_tripwire_dir(const std::string &s)
line_ptr make_line(std::vector< point > points, std::string name, bool closed=false)
Create and normalize a line.
std::string normalize_str(std::string_view str)
Remove whitespace and parentheses from a string.
std::vector< point > parse_points(const std::string &points_str)
Parse points from a textual representation.
float parse_float(std::string_view num_str)
Parse a float from a string view.
stream_pipeline
Processing pipeline mode for a stream.
std::shared_ptr< line const > line_ptr
Shared, immutable line pointer.
event_kind
High-level classification of backend events.
tripwire_dir
Allowed crossing direction for a tripwire.
pixel_format
Pixel format of a frame buffer.
stream_type
Source/transport type of a video stream.
Generic event produced by the backend.
std::chrono::steady_clock::time_point ts
Monotonic timestamp when the event was generated.
event_kind kind
Type of the event.
std::string stream_name
Name/identifier of the stream that produced the event.
std::optional< point > pos_pct
Optional position associated with the event in percentage coordinates.
std::string line_name
Name of the line / ROI / rule responsible for this event.
std::string message
Human-readable event description or payload.
int width
Frame width in pixels.
int stride
Number of bytes per row.
int height
Frame height in pixels.
std::vector< std::uint8_t > data
Raw pixel bytes.
std::chrono::steady_clock::time_point ts
Monotonic timestamp when the frame was captured/produced.
pixel_format format
Pixel format of the buffer.
Polyline / polygon described in percentage coordinates.
std::string name
Logical name of the line (e.g., "entrance_tripwire").
tripwire_dir dir
Optional tripwire direction constraint.
bool closed
Whether the chain is closed.
void dump(std::ostream &out) const
Print a human-readable representation of the line.
std::vector< point > points
Vertex list in percentage coordinates.
void normalize()
Canonicalize point order.
bool operator==(const line &other) const
Equality check using canonical point comparison.
Point in percentage-based image coordinates.
float distance_to(const point &other) const
Compute Euclidean distance to another point.
float x
Horizontal coordinate (percentage of width).
float y
Vertical coordinate (percentage of height).
static constexpr float epsilon
Tolerance used for fuzzy point comparisons.
bool compare(const point &other) const
Compare two points with tolerance epsilon.