fix: car detection use wrong image source
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 6s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 3m34s
Build Worker Base and Application Images / deploy-stack (push) Successful in 15s
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 6s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 3m34s
Build Worker Base and Application Images / deploy-stack (push) Successful in 15s
This commit is contained in:
parent
5e59e00c55
commit
a4cfb264b9
3 changed files with 98 additions and 34 deletions
|
|
@ -350,10 +350,21 @@ class TrackingPipelineIntegration:
|
|||
'session_id': session_id
|
||||
}
|
||||
|
||||
# Fetch high-quality 2K snapshot for detection phase (not RTSP frame)
|
||||
# This ensures bbox coordinates match the frame used in processing phase
|
||||
logger.info(f"[DETECTION PHASE] Fetching 2K snapshot for vehicle {vehicle.track_id}")
|
||||
snapshot_frame = self._fetch_snapshot()
|
||||
|
||||
if snapshot_frame is None:
|
||||
logger.warning(f"[DETECTION PHASE] Failed to fetch snapshot, falling back to RTSP frame")
|
||||
snapshot_frame = frame # Fallback to RTSP if snapshot fails
|
||||
else:
|
||||
logger.info(f"[DETECTION PHASE] Using {snapshot_frame.shape[1]}x{snapshot_frame.shape[0]} snapshot for detection")
|
||||
|
||||
# Execute only the detection phase (first phase)
|
||||
# This will run detection and send imageDetection message to backend
|
||||
detection_result = await self.detection_pipeline.execute_detection_phase(
|
||||
frame=frame,
|
||||
frame=snapshot_frame, # Use 2K snapshot instead of RTSP frame
|
||||
display_id=display_id,
|
||||
subscription_id=subscription_id
|
||||
)
|
||||
|
|
@ -373,13 +384,13 @@ class TrackingPipelineIntegration:
|
|||
if detection_result['message_sent']:
|
||||
# Store for later processing when sessionId is received
|
||||
self.pending_processing_data[display_id] = {
|
||||
'frame': frame.copy(), # Store copy of frame for processing phase
|
||||
'frame': snapshot_frame.copy(), # Store copy of 2K snapshot (not RTSP frame!)
|
||||
'vehicle': vehicle,
|
||||
'subscription_id': subscription_id,
|
||||
'detection_result': detection_result,
|
||||
'timestamp': time.time()
|
||||
}
|
||||
logger.info(f"Stored processing data for {display_id}, waiting for sessionId from backend")
|
||||
logger.info(f"Stored processing data ({snapshot_frame.shape[1]}x{snapshot_frame.shape[0]} frame) for {display_id}, waiting for sessionId from backend")
|
||||
|
||||
return detection_result
|
||||
|
||||
|
|
@ -413,14 +424,27 @@ class TrackingPipelineIntegration:
|
|||
|
||||
logger.info(f"Executing processing phase for session {session_id}, vehicle {vehicle.track_id}")
|
||||
|
||||
# Capture high-quality snapshot for pipeline processing
|
||||
logger.info(f"[PROCESSING PHASE] Fetching 2K snapshot for session {session_id}")
|
||||
frame = self._fetch_snapshot()
|
||||
# Reuse the snapshot from detection phase OR fetch fresh one if detection used RTSP fallback
|
||||
detection_frame = processing_data['frame']
|
||||
frame_height = detection_frame.shape[0]
|
||||
|
||||
if frame is None:
|
||||
logger.warning(f"[PROCESSING PHASE] Failed to capture snapshot, falling back to RTSP frame")
|
||||
# Fall back to RTSP frame if snapshot fails
|
||||
frame = processing_data['frame']
|
||||
# Check if detection phase used 2K snapshot (height > 1000) or RTSP fallback (height = 720)
|
||||
if frame_height >= 1000:
|
||||
# Detection used 2K snapshot - reuse it for consistent coordinates
|
||||
logger.info(f"[PROCESSING PHASE] Reusing 2K snapshot from detection phase ({detection_frame.shape[1]}x{detection_frame.shape[0]})")
|
||||
frame = detection_frame
|
||||
else:
|
||||
# Detection used RTSP fallback - need to fetch fresh 2K snapshot
|
||||
logger.warning(f"[PROCESSING PHASE] Detection used RTSP fallback ({detection_frame.shape[1]}x{detection_frame.shape[0]}), fetching fresh 2K snapshot")
|
||||
frame = self._fetch_snapshot()
|
||||
|
||||
if frame is None:
|
||||
logger.error(f"[PROCESSING PHASE] Failed to fetch snapshot and detection used RTSP - coordinate mismatch will occur!")
|
||||
logger.error(f"[PROCESSING PHASE] Cannot proceed with mismatched coordinates. Aborting processing phase.")
|
||||
return # Cannot process safely - bbox coordinates won't match frame resolution
|
||||
else:
|
||||
logger.warning(f"[PROCESSING PHASE] Fetched fresh 2K snapshot ({frame.shape[1]}x{frame.shape[0]}), but coordinates may not match exactly")
|
||||
logger.warning(f"[PROCESSING PHASE] Re-running detection on fresh snapshot is recommended but not implemented yet")
|
||||
|
||||
# Extract detected regions from detection phase result if available
|
||||
detected_regions = detection_result.get('detected_regions', {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue