feat: surgery pipeline API, video inference, voice confirm, and tests
- Add FastAPI routes for surgery start/end, results, pending confirmation (WAV upload), and health checks.
- Implement RTSP/Hikvision capture, consumable classification, session manager, MinIO/Baidu voice resolution, and DB persistence.
- Add documentation (client API, video backends, staging checklist) and sample camera/RTSP config.
- Add pytest suite (API contract, session manager, voice, repositories, pipeline persistence) and httpx dev dependency.
- Replace deprecated HTTP_422_UNPROCESSABLE_ENTITY with HTTP_422_UNPROCESSABLE_CONTENT.
- Fix SurgeryPipeline DB reads to use an explicit transaction with autobegin disabled.
Made-with: Cursor
2026-04-21 18:33:54 +08:00
|
|
|
from loguru import logger
|
|
|
|
|
|
|
|
|
|
from app.config import settings
|
|
|
|
|
from app.repositories.surgery_results import SurgeryResultRepository
|
|
|
|
|
from app.repositories.voice_audits import VoiceAuditRepository
|
|
|
|
|
from app.services.baidu_speech import BaiduSpeechService
|
2026-04-22 16:31:12 +08:00
|
|
|
from app.services.consumable_vision_algorithm import ConsumableVisionAlgorithmService
|
feat: surgery pipeline API, video inference, voice confirm, and tests
- Add FastAPI routes for surgery start/end, results, pending confirmation (WAV upload), and health checks.
- Implement RTSP/Hikvision capture, consumable classification, session manager, MinIO/Baidu voice resolution, and DB persistence.
- Add documentation (client API, video backends, staging checklist) and sample camera/RTSP config.
- Add pytest suite (API contract, session manager, voice, repositories, pipeline persistence) and httpx dev dependency.
- Replace deprecated HTTP_422_UNPROCESSABLE_ENTITY with HTTP_422_UNPROCESSABLE_CONTENT.
- Fix SurgeryPipeline DB reads to use an explicit transaction with autobegin disabled.
Made-with: Cursor
2026-04-21 18:33:54 +08:00
|
|
|
from app.services.minio_audio_storage import MinioAudioStorageService
|
|
|
|
|
from app.services.surgery_pipeline import SurgeryPipeline
|
|
|
|
|
from app.services.voice_resolution import VoiceConfirmationService
|
|
|
|
|
from app.services.video.hikvision_runtime import HikvisionRuntime
|
|
|
|
|
from app.services.video.session_manager import CameraSessionManager
|
|
|
|
|
|
2026-04-22 16:31:12 +08:00
|
|
|
consumable_vision_algorithm_service = ConsumableVisionAlgorithmService()
|
feat: surgery pipeline API, video inference, voice confirm, and tests
- Add FastAPI routes for surgery start/end, results, pending confirmation (WAV upload), and health checks.
- Implement RTSP/Hikvision capture, consumable classification, session manager, MinIO/Baidu voice resolution, and DB persistence.
- Add documentation (client API, video backends, staging checklist) and sample camera/RTSP config.
- Add pytest suite (API contract, session manager, voice, repositories, pipeline persistence) and httpx dev dependency.
- Replace deprecated HTTP_422_UNPROCESSABLE_ENTITY with HTTP_422_UNPROCESSABLE_CONTENT.
- Fix SurgeryPipeline DB reads to use an explicit transaction with autobegin disabled.
Made-with: Cursor
2026-04-21 18:33:54 +08:00
|
|
|
|
|
|
|
|
hikvision_runtime = HikvisionRuntime.try_load(settings.hikvision_lib_dir)
|
|
|
|
|
if settings.hikvision_sdk_enabled and hikvision_runtime is None:
|
|
|
|
|
logger.warning(
|
|
|
|
|
"HIKVISION_SDK_ENABLED=true but no HCNetSDK library loaded "
|
|
|
|
|
"(check HIKVISION_LIB_DIR / mount /opt/hikvision/lib)"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
surgery_result_repository = SurgeryResultRepository()
|
|
|
|
|
voice_audit_repository = VoiceAuditRepository()
|
|
|
|
|
baidu_speech_service = BaiduSpeechService()
|
|
|
|
|
minio_audio_storage_service = MinioAudioStorageService(settings)
|
|
|
|
|
camera_session_manager = CameraSessionManager(
|
|
|
|
|
settings=settings,
|
2026-04-22 16:31:12 +08:00
|
|
|
vision_algorithm=consumable_vision_algorithm_service,
|
feat: surgery pipeline API, video inference, voice confirm, and tests
- Add FastAPI routes for surgery start/end, results, pending confirmation (WAV upload), and health checks.
- Implement RTSP/Hikvision capture, consumable classification, session manager, MinIO/Baidu voice resolution, and DB persistence.
- Add documentation (client API, video backends, staging checklist) and sample camera/RTSP config.
- Add pytest suite (API contract, session manager, voice, repositories, pipeline persistence) and httpx dev dependency.
- Replace deprecated HTTP_422_UNPROCESSABLE_ENTITY with HTTP_422_UNPROCESSABLE_CONTENT.
- Fix SurgeryPipeline DB reads to use an explicit transaction with autobegin disabled.
Made-with: Cursor
2026-04-21 18:33:54 +08:00
|
|
|
hikvision_runtime=hikvision_runtime,
|
|
|
|
|
result_repository=surgery_result_repository,
|
|
|
|
|
)
|
|
|
|
|
voice_confirmation_service = VoiceConfirmationService(
|
|
|
|
|
settings=settings,
|
|
|
|
|
sessions=camera_session_manager,
|
|
|
|
|
baidu=baidu_speech_service,
|
|
|
|
|
minio=minio_audio_storage_service,
|
|
|
|
|
audits=voice_audit_repository,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
surgery_pipeline = SurgeryPipeline(
|
|
|
|
|
camera_session_manager,
|
|
|
|
|
result_repository=surgery_result_repository,
|
|
|
|
|
voice_confirmation=voice_confirmation_service,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 16:31:12 +08:00
|
|
|
def get_consumable_vision_algorithm_service() -> ConsumableVisionAlgorithmService:
|
|
|
|
|
return consumable_vision_algorithm_service
|
feat: surgery pipeline API, video inference, voice confirm, and tests
- Add FastAPI routes for surgery start/end, results, pending confirmation (WAV upload), and health checks.
- Implement RTSP/Hikvision capture, consumable classification, session manager, MinIO/Baidu voice resolution, and DB persistence.
- Add documentation (client API, video backends, staging checklist) and sample camera/RTSP config.
- Add pytest suite (API contract, session manager, voice, repositories, pipeline persistence) and httpx dev dependency.
- Replace deprecated HTTP_422_UNPROCESSABLE_ENTITY with HTTP_422_UNPROCESSABLE_CONTENT.
- Fix SurgeryPipeline DB reads to use an explicit transaction with autobegin disabled.
Made-with: Cursor
2026-04-21 18:33:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_surgery_pipeline() -> SurgeryPipeline:
|
|
|
|
|
return surgery_pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_camera_session_manager() -> CameraSessionManager:
|
|
|
|
|
return camera_session_manager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_surgery_result_repository() -> SurgeryResultRepository:
|
|
|
|
|
return surgery_result_repository
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_voice_confirmation_service() -> VoiceConfirmationService:
|
|
|
|
|
return voice_confirmation_service
|