Skip to content

Add GMM adaptive background subtractor #8

Description

@aasehaa

Why Are They Implemented Differently?

BugSpot uses OpenCV because:

Python environment, OpenCV is a standard dependency
MOG2 is battle-tested, handles edge cases well
No performance constraints (desktop/server)

Trapjaw uses custom C/Metal because:

iOS deployment — cannot bundle OpenCV (massive binary, licensing)
Zero-dependency mandate — must build on Apple frameworks only
Real-time performance — Metal GPU shaders need a custom implementation
Memory control — fixed K=3 is deterministic memory usage per pixel

Options:

  1. Add Adaptive Component Selection to TrapjawChanges:- Implement fitness sorting (weight / variance) for BG classification- Add component creation/destruction logic (or at least "disable" unused components)
  • Change BG classification from weight > 0.10 to cumulative weight > threshold
    Pros: Closer to MOG2 semantics
    Cons: Significant code changes to C + Metal shaders. Risks breaking GPU path.
  1. Port OpenCV's MOG2 Algorithm to C/Metal
    Changes:
  • Literally reimplement OpenCV's MOG2 in C and Metal
  • Match every detail: fitness sorting, adaptive K, bootstrap, etc.
    Pros: True 1:1 parity
    Cons: Massive engineering effort. ~1000+ lines of C/Metal. Needs extensive validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions