A.R.G.U.S 2.1.0
Adaptive Real-Time Guardian for Unsafe Situations
Loading...
Searching...
No Matches
Public Member Functions | List of all members
VisionProcessor Class Reference

#include <VisionProcessor.hpp>

Public Member Functions

 VisionProcessor (const VisionConfig &config)
 Constructs a VisionProcessor with the given safety configuration.
 
SafetyResult process (const cv::Mat &frame, std::chrono::steady_clock::time_point captureTimestamp)
 Processes a single camera frame and evaluates tool safety.
 
void updateConfig (const VisionConfig &newConfig)
 Updates the safety configuration at runtime.
 

Detailed Description

Definition at line 36 of file VisionProcessor.hpp.

Constructor & Destructor Documentation

◆ VisionProcessor()

VisionProcessor::VisionProcessor ( const VisionConfig config)
explicit

Constructs the VisionProcessor and initialises all detection resources.

Initialises internal resources once at construction so that process() stays fast and latency remains predictable and bounded on every call.

The config is stored by value so this class owns its own copy and is not affected by any external changes after construction — satisfying the Dependency Inversion Principle (depends on VisionConfig abstraction, not hardcoded values).

Parameters
configSafety thresholds and zone boundaries injected at construction. Stored by value to prevent external modifications from affecting in-flight decisions.

Initialises internal resources once so process() stays fast and latency remains bounded on every call.

Parameters
configSafety thresholds and zone boundaries injected at construction to satisfy the Dependency Inversion principle. Stored by value so external changes cannot affect in-flight safety decisions.

Definition at line 29 of file VisionProcessor.cpp.

Member Function Documentation

◆ process()

SafetyResult VisionProcessor::process ( const cv::Mat &  frame,
std::chrono::steady_clock::time_point  captureTimestamp 
)

Runs the full vision safety pipeline on a single camera frame.

Executes a depth-colour safety pipeline per frame:

  1. Crop frame to the configured safe-zone ROI.
  2. Convert ROI to HSV colour space.
  3. Apply configured hue/saturation/value thresholds.
  4. Trigger DEPTH_EXCEEDED when matching pixels exceed threshold.

Must complete within the latency budget (less than one frame period). At 30 FPS the budget is ~33 ms; target completion under 20 ms to leave headroom for FSM transition and interlock signalling.

Parameters
frameThe raw camera frame to analyse. Must not be empty.
captureTimestampThe time at which this frame was captured. Used to compute the actual inter-frame elapsed time for the speed check — prevents false SAFE results caused by dropped frames under load.
Returns
SafetyResult containing:
  • The safety state (SAFE or DEPTH_EXCEEDED on this branch).
  • The timestamp at which the result was produced.
  • The processing duration for latency budget analysis.

Executes the depth-colour pipeline:

  1. Crop to safe-zone ROI.
  2. Convert ROI to HSV.
  3. Threshold HSV against configured forbidden colour bands.
  4. Trigger DEPTH_EXCEEDED when matching pixels exceed threshold.

Processing time is measured at each return point and included in the result to support latency budget analysis.

Parameters
frameThe camera frame to analyse. Must be non-empty.
captureTimestampThe time at which this frame was captured. Used to compute actual inter-frame elapsed time for the speed check, ensuring correctness under variable frame delivery rates on a loaded RPi.
Returns
SafetyResult containing the safety state, timestamp, and processing time for this frame.

Helper lambda: builds a SafetyResult with correct timestamps and processing_time without duplicating this logic at every return point.

Definition at line 75 of file VisionProcessor.cpp.

References DEPTH_EXCEEDED, VisionConfig::depthCheckEnabled, VisionConfig::depthHueLower1, VisionConfig::depthHueLower2, VisionConfig::depthHueUpper1, VisionConfig::depthHueUpper2, VisionConfig::depthPixelThreshold, VisionConfig::depthSatMax, VisionConfig::depthSatMin, VisionConfig::depthValMax, VisionConfig::depthValMin, SAFE, VisionConfig::safeZoneXMax, VisionConfig::safeZoneXMin, VisionConfig::safeZoneYMax, and VisionConfig::safeZoneYMin.

Referenced by AppController::runLiveMarkerTest().

◆ updateConfig()

void VisionProcessor::updateConfig ( const VisionConfig newConfig)

Allows dynamic adjustment of thresholds (e.g., via UI sliders) without reconstructing the VisionProcessor. Useful for calibration and testing under varying lighting conditions.

Parameters
newConfigThe updated configuration to apply.

Definition at line 49 of file VisionProcessor.cpp.

Referenced by AppController::runLiveMarkerTest().


The documentation for this class was generated from the following files: