2.4 KiB
2.4 KiB
People Flow Design
Goal
Build a standalone project under Documents/人流检测/people_flow_project that analyzes street videos and produces:
- unique people-flow counts
- one mutually exclusive age bucket per counted person
- one mutually exclusive gender bucket per counted person
- annotated videos plus machine-readable summaries
Approved Decisions
- Runtime target: Linux with NVIDIA GPU
- Entry points: both single-video mode and batch-directory mode
- Count logic: one
track_idis counted once when it crosses a configured line - Age buckets:
minor: age< 18adult: age18-59senior: age>= 60
- Gender buckets:
malefemale
- Unknown face attributes:
- If a counted person does not yield a reliable face result, count that person only in
total_people - Also increment
unknown_attributes
- If a counted person does not yield a reliable face result, count that person only in
Architecture
The pipeline uses Ultralytics YOLO for person detection and tracking, then DeepFace for face attribute analysis. Person tracking and counting stay separate from attribute inference so the demographic model can be replaced later without touching the counting core.
The application stores votes per track_id. When the video finishes, each counted track is resolved to at most one final age bucket and one final gender bucket by majority voting.
Modules
main.py: CLI parsing and mode dispatchsrc/people_flow/config.py: config loading and overridessrc/people_flow/tracking.py: track extraction from YOLO resultssrc/people_flow/counting.py: line-crossing logic and unique countingsrc/people_flow/attributes.py: DeepFace integration and votingsrc/people_flow/io_utils.py: video, JSON, and CSV output helperssrc/people_flow/pipeline.py: process orchestration
Outputs
For each video:
- annotated MP4
- JSON summary
For batch runs:
- one CSV summary with one row per video
Error Handling
- Missing dependencies should raise clear installation guidance.
- If a video cannot be opened, fail that video with a readable error.
- If face inference fails for a sample, continue processing and treat that sample as unavailable.
- If no video files are found in batch mode, fail fast with a clear message.
Limitations
- Age and gender quality depend on clear, sufficiently large faces.
- Street scenes with strong occlusion, side views, masks, or low light will increase
unknown_attributesand lower reliability. - The default line is a placeholder and should be adjusted per camera view.