Implementation Plan
Trang Thai Hien Tai
Du an da chuyen tu prototype Taekwondo/Streamlit sang ung dung Reflex phan tich bai tap hit dat. Luong xu ly production hien tai nam trong cac module push_up/* va reflex_frontend/*.
Kien Truc Chinh
Reflex UI
-> upload video hoc vien
-> push_up.analysis_service.analyze_pushup()
-> VideoProcessor + MediaPipe Pose
-> PushUpEvaluator
-> PushUpRuleEngine
-> frame artifacts + rule-based arrows
-> optional NVIDIA VLM feedback
-> Reflex result cards
Module Chinh
reflex_frontend/state.py: quan ly upload, tien trinh xu ly, state ket qua.reflex_frontend/ui.py: giao dien trang chu, danh sach bai tap, trang phan tich hit dat, card ket qua tung rep.push_up/processor.py: doc video, phat hien huong nguoi tap, flip neu can, trich xuat landmark theo frame.push_up/engine.py: boc MediaPipe Pose, tinh cac chi so kinematics nhu elbow angle, hip angle, body line angle, depth signal.push_up/evaluator.py: segment rep, can chinh voi template bang DTW, ket hop diem rule score va DTW score.push_up/rules.py: phat hien loi ky thuat bang nguong deterministic.push_up/analysis_service.py: orchestration cua toan bo flow, tao payload cho UI, luu artifact, ve arrow.push_up/feedback_graph.py: goi text LLM/VLM qua NVIDIA OpenAI-compatible API va validate JSON feedback.scripts/run_pushup_eval_tests.py: batch test tat ca video trongdata/testsva xuat file JSON tong hop.
Luong Phan Tich Video
- UI luu video upload vao thu muc tam cua Reflex.
prepare_template_cache()dam bao video mau da duoc xu ly va cache landmark taidata/processed/pushup_template.pkl.VideoProcessordoc video hoc vien, lay mau frame, auto flip neu nguoi tap nam nguoc huong template.PoseEnginetrich xuat 33 landmark pose va tinh kinematics.PushUpEvaluatorsegment rep dua tren depth signal va elbow angle.- Moi rep duoc so sanh voi golden template bang DTW va pose similarity.
PushUpRuleEnginechay rule-based checks:not_deep_enoughhip_sagbody_not_straighthead_misalignedhip_pike
analysis_servicetao card ket qua tung rep, main error, feedback rule-based, va summary.- Khi
save_artifacts=True, app luu frame hoc vien/mau va ve arrow vao frame hoc vien. - Neu rep co rule-based error va co
NVIDIA_API_KEY, VLM duoc goi de sinh feedback chu cho rep loi.
Quyet Dinh Thiet Ke
- Rule engine la nguon quyet dinh loi chinh, diem rule, feedback rule-based va arrow target.
- VLM khong duoc dung de quyet dinh toa do arrow vi de tra sai vi tri tren nen anh.
- VLM chi sinh feedback ngan bang tieng Viet dua tren anh hoc vien, anh mau va rule context.
- Arrow label dung tieng Viet co dau va duoc render bang Pillow de tranh loi Unicode cua OpenCV.
- Ket qua test batch mac dinh tat VLM de lap lai, nhanh hon va khong ton API.
Viec Can Lam Tiep
- Them expected assertions vao batch test, vi du
hv01_mong_caophai cohip_pike. - Luu anh artifact cho test run co chon loc thay vi tat ca rep neu can giam dung luong.
- Tach
llm_*field thanhvlm_*trong payload/UI de ten bien khop voi y nghia hien tai. - Them exercise registry neu mo rong sang bai tap khac.