Dish_Recognition/start_usb.bat

63 lines
1.5 KiB
Batchfile

@echo off
chcp 65001 >nul
setlocal EnableExtensions
rem Re-launch in a console that never auto-closes (fixes double-click flash-close)
if /I not "%~1"=="--run" (
start "DishRecognition" cmd /k call "%~f0" --run
exit /b 0
)
rem === paths ===
set "ENV_DIR=D:\miniconda3\envs\classify"
set "APP_DIR=D:\Dish_Recognition"
set "APP_PY=%APP_DIR%\usb_camera_app.py"
set "CRASH_LOG=%APP_DIR%\crash.log"
set "PY=%ENV_DIR%\python.exe"
cd /d "%APP_DIR%"
if not exist "%PY%" (
echo [ERR] python not found: %PY%
goto :hold
)
if not exist "%APP_PY%" (
echo [ERR] app not found: %APP_PY%
goto :hold
)
set "PATH=%ENV_DIR%;%ENV_DIR%\Scripts;%ENV_DIR%\Library\bin;%ENV_DIR%\DLLs;%PATH%"
set "CONDA_PREFIX=%ENV_DIR%"
set "PYTHONHOME="
set "PYTHONPATH="
set "PYTHONUNBUFFERED=1"
set "PYTHONIOENCODING=utf-8"
set "PYTHONFAULTHANDLER=1"
set "KMP_DUPLICATE_LIB_OK=TRUE"
set "OMP_NUM_THREADS=1"
set "MKL_NUM_THREADS=1"
echo ========================================
echo Dish Recognition USB launcher
echo PY=%PY%
echo APP=%APP_PY%
echo CRASH_LOG=%CRASH_LOG%
echo ========================================
echo.
"%PY%" -u "%APP_PY%"
set "EC=%ERRORLEVEL%"
echo.
echo ========================================
echo Python exited, exit code = %EC%
if exist "%CRASH_LOG%" (
echo ---- crash.log tail ----
powershell -NoProfile -Command "Get-Content -Path '%CRASH_LOG%' -Tail 50 -ErrorAction SilentlyContinue"
)
echo ========================================
echo This window will stay open. Close it manually when done.
:hold
echo.
pause