YODAU 1.0
YEAR OF THE DEPEND ADULT UNDERGARMENT
Loading...
Searching...
No Matches
frame.hpp
Go to the documentation of this file.
1#ifndef YODAU_BACKEND_FRAME_HPP
2#define YODAU_BACKEND_FRAME_HPP
3
4#include <chrono>
5#include <cstdint>
6#include <vector>
7
8namespace yodau::backend {
9
10/**
11 * @brief Pixel format of a @ref frame buffer.
12 *
13 * The enumerators describe the byte layout of pixels in @ref frame::data.
14 * All formats are tightly packed without per-pixel padding.
15 */
16enum class pixel_format {
17 /** 8-bit grayscale, 1 byte per pixel. */
19 /** RGB, 8-bit per channel, 3 bytes per pixel. */
21 /** BGR, 8-bit per channel, 3 bytes per pixel. */
23 /** RGBA, 8-bit per channel, 4 bytes per pixel. */
25 /** BGRA, 8-bit per channel, 4 bytes per pixel. */
27};
28
29/**
30 * @brief Video frame container.
31 *
32 * A frame holds raw pixel data and basic metadata. The buffer is stored in
33 * row-major order in @ref data.
34 *
35 * Typical size relation:
36 * @code
37 * data.size() >= stride * height
38 * @endcode
39 *
40 * where @ref stride is the number of bytes between two consecutive rows.
41 *
42 * @note The timestamp uses std::chrono::steady_clock and is monotonic.
43 */
44struct frame {
45 /**
46 * @brief Frame width in pixels.
47 */
48 int width { 0 };
49
50 /**
51 * @brief Frame height in pixels.
52 */
53 int height { 0 };
54
55 /**
56 * @brief Number of bytes per row.
57 *
58 * This may be wider than width * bytes_per_pixel due to alignment/padding.
59 */
60 int stride { 0 };
61
62 /**
63 * @brief Pixel format of the buffer.
64 *
65 * Defaults to @ref pixel_format::bgr24.
66 */
68
69 /**
70 * @brief Raw pixel bytes.
71 *
72 * Layout is determined by @ref format and @ref stride.
73 */
75
76 /**
77 * @brief Monotonic timestamp when the frame was captured/produced.
78 */
79 std::chrono::steady_clock::time_point ts;
80};
81
82} // namespace yodau::backend
83
84#endif // YODAU_BACKEND_FRAME_HPP
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.
Definition cli_client.cpp:5
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.
Definition stream.hpp:64
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.
Definition geometry.cpp:82
std::string normalize_str(std::string_view str)
Remove whitespace and parentheses from a string.
Definition geometry.cpp:133
std::vector< point > parse_points(const std::string &points_str)
Parse points from a textual representation.
Definition geometry.cpp:94
float parse_float(std::string_view num_str)
Parse a float from a string view.
Definition geometry.cpp:145
std::shared_ptr< line const > line_ptr
Shared, immutable line pointer.
Definition geometry.hpp:146
event_kind
High-level classification of backend events.
Definition event.hpp:19
tripwire_dir
Allowed crossing direction for a tripwire.
Definition geometry.hpp:62
pixel_format
Pixel format of a frame buffer.
Definition frame.hpp:16
Generic event produced by the backend.
Definition event.hpp:44
std::chrono::steady_clock::time_point ts
Monotonic timestamp when the event was generated.
Definition event.hpp:70
event_kind kind
Type of the event.
Definition event.hpp:50
std::string stream_name
Name/identifier of the stream that produced the event.
Definition event.hpp:57
std::optional< point > pos_pct
Optional position associated with the event in percentage coordinates.
Definition event.hpp:79
std::string line_name
Name of the line / ROI / rule responsible for this event.
Definition event.hpp:86
std::string message
Human-readable event description or payload.
Definition event.hpp:65
Video frame container.
Definition frame.hpp:44
int width
Frame width in pixels.
Definition frame.hpp:48
int stride
Number of bytes per row.
Definition frame.hpp:60
int height
Frame height in pixels.
Definition frame.hpp:53
std::vector< std::uint8_t > data
Raw pixel bytes.
Definition frame.hpp:74
std::chrono::steady_clock::time_point ts
Monotonic timestamp when the frame was captured/produced.
Definition frame.hpp:79
pixel_format format
Pixel format of the buffer.
Definition frame.hpp:67
Polyline / polygon described in percentage coordinates.
Definition geometry.hpp:81
std::string name
Logical name of the line (e.g., "entrance_tripwire").
Definition geometry.hpp:85
tripwire_dir dir
Optional tripwire direction constraint.
Definition geometry.hpp:104
bool closed
Whether the chain is closed.
Definition geometry.hpp:97
void dump(std::ostream &out) const
Print a human-readable representation of the line.
Definition geometry.cpp:17
std::vector< point > points
Vertex list in percentage coordinates.
Definition geometry.hpp:90
void normalize()
Canonicalize point order.
Definition geometry.cpp:29
bool operator==(const line &other) const
Equality check using canonical point comparison.
Definition geometry.cpp:70
Point in percentage-based image coordinates.
Definition geometry.hpp:19
float distance_to(const point &other) const
Compute Euclidean distance to another point.
Definition geometry.cpp:7
float x
Horizontal coordinate (percentage of width).
Definition geometry.hpp:23
float y
Vertical coordinate (percentage of height).
Definition geometry.hpp:28
static constexpr float epsilon
Tolerance used for fuzzy point comparisons.
Definition geometry.hpp:33
bool compare(const point &other) const
Compare two points with tolerance epsilon.
Definition geometry.cpp:13