Skip to content

Latest commit

 

History

History
299 lines (204 loc) · 6.07 KB

File metadata and controls

299 lines (204 loc) · 6.07 KB

VisionForge AI - API Reference

Face Detection Module

FaceDetector

from src.face_detection import FaceDetector

detector = FaceDetector(
    face_cascade_path: Optional[str] = None,
    eye_cascade_path: Optional[str] = None
)

Methods

detect_faces(image, scale_factor=None, min_neighbors=None, min_size=None)

  • Detect faces in an image
  • Returns: List of bounding boxes as (x, y, w, h)

detect_eyes(image, face_region=None)

  • Detect eyes in an image or face region
  • Returns: List of eye bounding boxes

detect_faces_with_eyes(image)

  • Detect faces and eyes simultaneously
  • Returns: Dictionary with faces, eyes, counts, and processing time

draw_detections(image, faces, eyes=None, show_confidence=False)

  • Draw face and eye detections on image
  • Returns: Image with drawn detections

get_face_statistics(faces)

  • Calculate statistics about detected faces
  • Returns: Dictionary with count, averages, areas

Object Tracking Module

HSVTracker

from src.object_tracking import HSVTracker

tracker = HSVTracker(
    lower_bound: Tuple[int, int, int],
    upper_bound: Tuple[int, int, int]
)

Methods

track(frame)

  • Track objects based on HSV color range
  • Returns: Tuple of (mask, list of bounding boxes)

update_bounds(lower_bound, upper_bound)

  • Update HSV color bounds

CentroidTracker

from src.object_tracking import CentroidTracker

tracker = CentroidTracker(
    max_distance: int = 100,
    max_disappeared: int = 30
)

Methods

update(bounding_boxes)

  • Update tracker with new bounding boxes
  • Returns: Dictionary of object_id -> centroid

get_tracking_history(object_id)

  • Get tracking history for an object
  • Returns: List of centroids

get_object_count()

  • Get current number of tracked objects
  • Returns: Integer count

draw_tracks(frame, show_history=True)

  • Draw tracking information on frame
  • Returns: Frame with tracking visualization

Lane Detection Module

LaneDetector

from src.lane_detection import LaneDetector

detector = LaneDetector()

Methods

process_frame(frame)

  • Process a frame for lane detection
  • Returns: Dictionary with lane data, curvature, deviation

draw_lanes(frame, results)

  • Draw detected lanes on frame
  • Returns: Frame with drawn lanes

Traffic Analytics Module

TrafficAnalytics

from src.traffic_analysis import TrafficAnalytics

analytics = TrafficAnalytics(fps: float = 30.0)

Methods

process_frame(frame, tracked_vehicles=None)

  • Process frame for traffic analytics
  • Returns: Dictionary with vehicle count, density, congestion

generate_report()

  • Generate comprehensive traffic analytics report
  • Returns: Dictionary with traffic statistics

draw_analytics(frame, results)

  • Draw analytics overlay on frame
  • Returns: Frame with analytics overlay

Analytics Engine

AnalyticsEngine

from src.analytics import AnalyticsEngine

engine = AnalyticsEngine(output_dir: str = "results")

Methods

record_face_detection(results)

  • Record face detection results

record_object_detection(results)

  • Record object detection results

record_lane_detection(results)

  • Record lane detection results

record_traffic_analysis(results)

  • Record traffic analysis results

generate_detection_summary()

  • Generate comprehensive detection summary
  • Returns: Dictionary with all detection statistics

save_report(report=None, filename=None)

  • Save analytics report to JSON file
  • Returns: Path to saved report

save_raw_data(data_type='all')

  • Save raw detection data to JSON file
  • Returns: Path to saved data

Benchmark Engine

BenchmarkEngine

from src.benchmarking import BenchmarkEngine

engine = BenchmarkEngine(output_dir: str = "results")

Methods

measure_fps(process_func, test_duration=10.0)

  • Measure FPS of a processing function
  • Returns: FPS metrics dictionary

measure_latency(process_func, iterations=100)

  • Measure latency of a processing function
  • Returns: Latency metrics dictionary

measure_cpu_memory(process_func, duration=10.0)

  • Measure CPU and memory usage during processing
  • Returns: CPU and memory metrics dictionary

benchmark_video_processing(video_path, process_func)

  • Benchmark video processing pipeline
  • Returns: Video processing metrics

run_comprehensive_benchmark(benchmark_config)

  • Run comprehensive benchmark suite
  • Returns: Comprehensive benchmark results

Visualization Module

DetectionVisualizer

from src.visualization import DetectionVisualizer

Methods

create_detection_chart(detection_counts, timestamps)

  • Create detection count over time chart
  • Returns: Plotly figure

create_face_detection_chart(face_data)

  • Create face detection statistics chart
  • Returns: Plotly figure

TrafficVisualizer

from src.visualization import TrafficVisualizer

Methods

create_traffic_density_chart(traffic_data)

  • Create traffic density chart
  • Returns: Plotly figure

create_congestion_chart(traffic_data)

  • Create congestion level chart
  • Returns: Plotly figure

create_speed_chart(traffic_data)

  • Create vehicle speed chart
  • Returns: Plotly figure

PerformanceVisualizer

from src.visualization import PerformanceVisualizer

Methods

create_fps_chart(fps_data)

  • Create FPS chart
  • Returns: Plotly figure

create_latency_chart(latency_data)

  • Create latency chart
  • Returns: Plotly figure

create_cpu_memory_chart(cpu_data, memory_data)

  • Create CPU and memory usage chart
  • Returns: Plotly figure

Utility Functions

from src.utils import (
    calculate_iou,
    calculate_distance,
    calculate_centroid
)

calculate_iou(bbox1, bbox2)

  • Calculate Intersection over Union for two bounding boxes
  • Returns: Float value between 0 and 1

calculate_distance(point1, point2)

  • Calculate Euclidean distance between two points
  • Returns: Float distance value

calculate_centroid(bbox)

  • Calculate centroid of a bounding box
  • Returns: Tuple of (x, y) coordinates