feat(app): add new preset video and refine comparison flow

This commit is contained in:
game-loader
2025-06-22 11:36:55 +08:00
parent 9d42c8c0eb
commit 899c85ab8f
2 changed files with 33 additions and 21 deletions

View File

@@ -42,6 +42,7 @@ def main():
# Define preset video mapping (display name -> filename)
preset_videos = {
"六字诀": "liuzi.mp4",
"六字诀精简": "liuzi-short.mp4",
# Add more preset videos here:
# "太极拳": "taiji.mp4",
# "八段锦": "baduanjin.mp4",
@@ -160,26 +161,36 @@ def main():
st.session_state.show_preview = False
else:
# 主控制按钮(大按钮)
main_btn_col1, main_btn_col2, main_btn_col3 = st.columns(3)
with main_btn_col1:
if st.button("📷 预览摄像头", use_container_width=True, help="先预览摄像头调整位置"):
if app.body_detector is None:
st.error("⚠️ 请先在侧边栏初始化系统")
else:
st.session_state.show_preview = True
st.rerun()
with main_btn_col2:
if st.button("🚀 直接开始比较", use_container_width=True, help="直接开始动作比较"):
if app.body_detector is None:
st.error("⚠️ 请先在侧边栏初始化系统")
else:
app.start_comparison(video_path)
with main_btn_col3:
st.markdown("") # 占位
if 'start_main_comparison' not in st.session_state:
st.session_state.start_main_comparison = False
# 如果不处于比较状态,则显示主控制按钮
if not st.session_state.start_main_comparison:
main_btn_col1, main_btn_col2, main_btn_col3 = st.columns(3)
with main_btn_col1:
if st.button("📷 预览摄像头", use_container_width=True, help="先预览摄像头调整位置"):
if app.body_detector is None:
st.error("⚠️ 请先在侧边栏初始化系统")
else:
st.session_state.show_preview = True
st.rerun()
with main_btn_col2:
if st.button("🚀 直接开始比较", use_container_width=True, help="直接开始动作比较"):
if app.body_detector is None:
st.error("⚠️ 请先在侧边栏初始化系统")
else:
st.session_state.start_main_comparison = True
st.rerun()
with main_btn_col3:
st.markdown("") # 占位
if st.session_state.start_main_comparison:
app.start_comparison(video_path)
# 比较结束后,重置状态,以便下次可以重新显示主按钮
st.session_state.start_main_comparison = False
st.rerun() # 强制重跑以显示主按钮界面
except Exception as e:
st.error(f"❌ 处理视频时出现错误: {str(e)}")