wifi_densepose_core/lib.rs
1//! # WiFi-DensePose Core
2//!
3//! Core types, traits, and utilities for the WiFi-DensePose pose estimation system.
4//!
5//! This crate provides the foundational building blocks used throughout the
6//! WiFi-DensePose ecosystem, including:
7//!
8//! - **Core Data Types**: [`CsiFrame`], [`ProcessedSignal`], [`PoseEstimate`],
9//! [`PersonPose`], and [`Keypoint`] for representing `WiFi` CSI data and pose
10//! estimation results.
11//!
12//! - **Error Types**: Comprehensive error handling via the [`error`] module,
13//! with specific error types for different subsystems.
14//!
15//! - **Traits**: Core abstractions like [`SignalProcessor`], [`NeuralInference`],
16//! and [`DataStore`] that define the contracts for signal processing, neural
17//! network inference, and data persistence.
18//!
19//! - **Utilities**: Common helper functions and types used across the codebase.
20//!
21//! ## Feature Flags
22//!
23//! - `std` (default): Enable standard library support
24//! - `serde`: Enable serialization/deserialization via serde
25//! - `async`: Enable async trait definitions
26//!
27//! ## Example
28//!
29//! ```rust
30//! use wifi_densepose_core::{CsiFrame, Keypoint, KeypointType, Confidence};
31//!
32//! // Create a keypoint with high confidence
33//! let keypoint = Keypoint::new(
34//! KeypointType::Nose,
35//! 0.5,
36//! 0.3,
37//! Confidence::new(0.95).unwrap(),
38//! );
39//!
40//! assert!(keypoint.is_visible());
41//! ```
42
43#![cfg_attr(not(feature = "std"), no_std)]
44#![forbid(unsafe_code)]
45
46#[cfg(not(feature = "std"))]
47extern crate alloc;
48
49pub mod error;
50pub mod traits;
51pub mod types;
52pub mod utils;
53
54// Re-export commonly used types at the crate root
55pub use error::{CoreError, CoreResult, SignalError, InferenceError, StorageError};
56pub use traits::{SignalProcessor, NeuralInference, DataStore};
57pub use types::{
58 // CSI types
59 CsiFrame, CsiMetadata, AntennaConfig,
60 // Signal types
61 ProcessedSignal, SignalFeatures, FrequencyBand,
62 // Pose types
63 PoseEstimate, PersonPose, Keypoint, KeypointType,
64 // Common types
65 Confidence, Timestamp, FrameId, DeviceId,
66 // Bounding box
67 BoundingBox,
68};
69
70/// Crate version
71pub const VERSION: &str = env!("CARGO_PKG_VERSION");
72
73/// Maximum number of keypoints per person (COCO format)
74pub const MAX_KEYPOINTS: usize = 17;
75
76/// Maximum number of subcarriers typically used in `WiFi` CSI
77pub const MAX_SUBCARRIERS: usize = 256;
78
79/// Default confidence threshold for keypoint visibility
80pub const DEFAULT_CONFIDENCE_THRESHOLD: f32 = 0.5;
81
82/// Prelude module for convenient imports.
83///
84/// Convenient re-exports of commonly used types and traits.
85///
86/// ```rust
87/// use wifi_densepose_core::prelude::*;
88/// ```
89pub mod prelude {
90
91 pub use crate::error::{CoreError, CoreResult};
92 pub use crate::traits::{DataStore, NeuralInference, SignalProcessor};
93 pub use crate::types::{
94 AntennaConfig, BoundingBox, Confidence, CsiFrame, CsiMetadata, DeviceId, FrameId,
95 FrequencyBand, Keypoint, KeypointType, PersonPose, PoseEstimate, ProcessedSignal,
96 SignalFeatures, Timestamp,
97 };
98}
99
100#[cfg(test)]
101mod tests {
102 use super::*;
103
104 #[test]
105 fn test_version_is_valid() {
106 assert!(!VERSION.is_empty());
107 }
108
109 #[test]
110 fn test_constants() {
111 assert_eq!(MAX_KEYPOINTS, 17);
112 assert!(MAX_SUBCARRIERS > 0);
113 assert!(DEFAULT_CONFIDENCE_THRESHOLD > 0.0);
114 assert!(DEFAULT_CONFIDENCE_THRESHOLD < 1.0);
115 }
116}