Done features 2 vehicle detect and store image to redis
This commit is contained in:
parent
a1d358aead
commit
18c62a2370
2 changed files with 262 additions and 65 deletions
23
app.py
23
app.py
|
@ -239,7 +239,20 @@ async def detect(websocket: WebSocket):
|
|||
|
||||
logger.debug(f"Processing frame for camera {camera_id} with model {stream['modelId']}")
|
||||
start_time = time.time()
|
||||
detection_result = run_pipeline(cropped_frame, model_tree)
|
||||
|
||||
# Extract display identifier for session ID lookup
|
||||
subscription_parts = stream["subscriptionIdentifier"].split(';')
|
||||
display_identifier = subscription_parts[0] if subscription_parts else None
|
||||
session_id = session_ids.get(display_identifier) if display_identifier else None
|
||||
|
||||
# Create context for pipeline execution
|
||||
pipeline_context = {
|
||||
"camera_id": camera_id,
|
||||
"display_id": display_identifier,
|
||||
"session_id": session_id
|
||||
}
|
||||
|
||||
detection_result = run_pipeline(cropped_frame, model_tree, context=pipeline_context)
|
||||
process_time = (time.time() - start_time) * 1000
|
||||
logger.debug(f"Detection for camera {camera_id} completed in {process_time:.2f}ms")
|
||||
|
||||
|
@ -298,11 +311,6 @@ async def detect(websocket: WebSocket):
|
|||
if key not in ["box", "id"]: # Skip internal fields
|
||||
detection_dict[key] = value
|
||||
|
||||
# Extract display identifier for session ID lookup
|
||||
subscription_parts = stream["subscriptionIdentifier"].split(';')
|
||||
display_identifier = subscription_parts[0] if subscription_parts else None
|
||||
session_id = session_ids.get(display_identifier) if display_identifier else None
|
||||
|
||||
detection_data = {
|
||||
"type": "imageDetection",
|
||||
"subscriptionIdentifier": stream["subscriptionIdentifier"],
|
||||
|
@ -322,9 +330,6 @@ async def detect(websocket: WebSocket):
|
|||
logger.info(f"Camera {camera_id}: Detected {highest_confidence_detection['class']} with confidence {highest_confidence_detection['confidence']:.2f} using model {stream['modelName']}")
|
||||
|
||||
# Log session ID if available
|
||||
subscription_parts = stream["subscriptionIdentifier"].split(';')
|
||||
display_identifier = subscription_parts[0] if subscription_parts else None
|
||||
session_id = session_ids.get(display_identifier) if display_identifier else None
|
||||
if session_id:
|
||||
logger.debug(f"Detection associated with session ID: {session_id}")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue