we cool bruh
Browse files- api_server.py +14 -14
- hybrid_search.py +2 -2
- lucid2-react/src/api.jsx +2 -2
- users.json +1 -1
api_server.py
CHANGED
|
@@ -321,7 +321,7 @@ def generate_frames(camera_id: str) -> Generator[bytes, None, None]:
|
|
| 321 |
async def root():
|
| 322 |
return {"message": "Lucid 2.0 Surveillance System API", "status": "online"}
|
| 323 |
|
| 324 |
-
@app.get("/cameras")
|
| 325 |
async def get_cameras():
|
| 326 |
"""Get list of all cameras"""
|
| 327 |
if camera_manager is None:
|
|
@@ -342,7 +342,7 @@ async def get_cameras():
|
|
| 342 |
]
|
| 343 |
}
|
| 344 |
|
| 345 |
-
@app.post("/cameras")
|
| 346 |
async def add_camera(camera_id: str, source: str):
|
| 347 |
"""Add a new camera"""
|
| 348 |
if camera_manager is None:
|
|
@@ -354,7 +354,7 @@ async def add_camera(camera_id: str, source: str):
|
|
| 354 |
else:
|
| 355 |
raise HTTPException(status_code=400, detail=f"Failed to add camera {camera_id}")
|
| 356 |
|
| 357 |
-
@app.delete("/cameras/{camera_id}")
|
| 358 |
async def remove_camera(camera_id: str):
|
| 359 |
"""Remove a camera"""
|
| 360 |
if camera_manager is None:
|
|
@@ -364,7 +364,7 @@ async def remove_camera(camera_id: str):
|
|
| 364 |
camera_manager.remove_camera(camera_id)
|
| 365 |
return {"message": f"Camera {camera_id} removed", "status": "success"}
|
| 366 |
|
| 367 |
-
@app.get("/video_feed/{camera_id}")
|
| 368 |
async def video_feed(camera_id: str):
|
| 369 |
"""Stream video feed from a camera as MJPEG"""
|
| 370 |
if camera_manager is None:
|
|
@@ -381,7 +381,7 @@ async def video_feed(camera_id: str):
|
|
| 381 |
media_type="multipart/x-mixed-replace; boundary=frame"
|
| 382 |
)
|
| 383 |
|
| 384 |
-
@app.get("/stats")
|
| 385 |
async def get_system_stats():
|
| 386 |
"""Get system statistics"""
|
| 387 |
if tracking_system is None or matcher is None:
|
|
@@ -399,7 +399,7 @@ async def get_system_stats():
|
|
| 399 |
"global_identities": global_identity_count
|
| 400 |
}
|
| 401 |
|
| 402 |
-
@app.get("/identities")
|
| 403 |
async def get_identities():
|
| 404 |
"""Get all global identities with enhanced data"""
|
| 405 |
if tracking_system is None:
|
|
@@ -456,7 +456,7 @@ async def get_identities():
|
|
| 456 |
"identities": enhanced_identities
|
| 457 |
}
|
| 458 |
|
| 459 |
-
@app.post("/find_person")
|
| 460 |
async def find_person(image: UploadFile = File(...)):
|
| 461 |
"""Find a person across all cameras using Re-ID with improved accuracy"""
|
| 462 |
if tracking_system is None:
|
|
@@ -545,7 +545,7 @@ async def find_person(image: UploadFile = File(...)):
|
|
| 545 |
traceback.print_exc()
|
| 546 |
raise HTTPException(status_code=500, detail=f"Error processing image: {str(e)}")
|
| 547 |
|
| 548 |
-
@app.post("/profiles/{global_id}")
|
| 549 |
async def create_profile(global_id: str, name: str, metadata: Optional[str] = None):
|
| 550 |
"""Create or update a person profile"""
|
| 551 |
global person_profiles
|
|
@@ -563,7 +563,7 @@ async def create_profile(global_id: str, name: str, metadata: Optional[str] = No
|
|
| 563 |
"profile": profile
|
| 564 |
}
|
| 565 |
|
| 566 |
-
@app.get("/profiles/{global_id}")
|
| 567 |
async def get_profile(global_id: str):
|
| 568 |
"""Get a person's profile"""
|
| 569 |
if global_id in person_profiles:
|
|
@@ -571,7 +571,7 @@ async def get_profile(global_id: str):
|
|
| 571 |
else:
|
| 572 |
raise HTTPException(status_code=404, detail="Profile not found")
|
| 573 |
|
| 574 |
-
@app.post("/alerts/rules")
|
| 575 |
async def create_alert_rule(rule: dict):
|
| 576 |
"""Create a new alert rule"""
|
| 577 |
global alert_rules
|
|
@@ -579,12 +579,12 @@ async def create_alert_rule(rule: dict):
|
|
| 579 |
alert_rules.append(rule)
|
| 580 |
return {"message": "Alert rule created", "rule": rule}
|
| 581 |
|
| 582 |
-
@app.get("/alerts/rules")
|
| 583 |
async def get_alert_rules():
|
| 584 |
"""Get all alert rules"""
|
| 585 |
return {"rules": alert_rules}
|
| 586 |
|
| 587 |
-
@app.get("/snapshots/{filename}")
|
| 588 |
async def get_snapshot(filename: str):
|
| 589 |
"""Serve snapshot images"""
|
| 590 |
if tracking_system is None:
|
|
@@ -597,7 +597,7 @@ async def get_snapshot(filename: str):
|
|
| 597 |
|
| 598 |
return FileResponse(snapshot_path, media_type="image/jpeg")
|
| 599 |
|
| 600 |
-
@app.get("/analytics")
|
| 601 |
async def get_analytics():
|
| 602 |
"""Get comprehensive system analytics"""
|
| 603 |
if tracking_system is None:
|
|
@@ -683,7 +683,7 @@ async def get_analytics():
|
|
| 683 |
"timestamp": current_time
|
| 684 |
}
|
| 685 |
|
| 686 |
-
@app.websocket("/ws")
|
| 687 |
async def websocket_endpoint(websocket: WebSocket):
|
| 688 |
"""WebSocket endpoint for real-time alerts and updates"""
|
| 689 |
await websocket.accept()
|
|
|
|
| 321 |
async def root():
|
| 322 |
return {"message": "Lucid 2.0 Surveillance System API", "status": "online"}
|
| 323 |
|
| 324 |
+
@app.get("/api/cameras")
|
| 325 |
async def get_cameras():
|
| 326 |
"""Get list of all cameras"""
|
| 327 |
if camera_manager is None:
|
|
|
|
| 342 |
]
|
| 343 |
}
|
| 344 |
|
| 345 |
+
@app.post("/api/cameras")
|
| 346 |
async def add_camera(camera_id: str, source: str):
|
| 347 |
"""Add a new camera"""
|
| 348 |
if camera_manager is None:
|
|
|
|
| 354 |
else:
|
| 355 |
raise HTTPException(status_code=400, detail=f"Failed to add camera {camera_id}")
|
| 356 |
|
| 357 |
+
@app.delete("/api/cameras/{camera_id}")
|
| 358 |
async def remove_camera(camera_id: str):
|
| 359 |
"""Remove a camera"""
|
| 360 |
if camera_manager is None:
|
|
|
|
| 364 |
camera_manager.remove_camera(camera_id)
|
| 365 |
return {"message": f"Camera {camera_id} removed", "status": "success"}
|
| 366 |
|
| 367 |
+
@app.get("/api/video_feed/{camera_id}")
|
| 368 |
async def video_feed(camera_id: str):
|
| 369 |
"""Stream video feed from a camera as MJPEG"""
|
| 370 |
if camera_manager is None:
|
|
|
|
| 381 |
media_type="multipart/x-mixed-replace; boundary=frame"
|
| 382 |
)
|
| 383 |
|
| 384 |
+
@app.get("/api/stats")
|
| 385 |
async def get_system_stats():
|
| 386 |
"""Get system statistics"""
|
| 387 |
if tracking_system is None or matcher is None:
|
|
|
|
| 399 |
"global_identities": global_identity_count
|
| 400 |
}
|
| 401 |
|
| 402 |
+
@app.get("/api/identities")
|
| 403 |
async def get_identities():
|
| 404 |
"""Get all global identities with enhanced data"""
|
| 405 |
if tracking_system is None:
|
|
|
|
| 456 |
"identities": enhanced_identities
|
| 457 |
}
|
| 458 |
|
| 459 |
+
@app.post("/api/find_person")
|
| 460 |
async def find_person(image: UploadFile = File(...)):
|
| 461 |
"""Find a person across all cameras using Re-ID with improved accuracy"""
|
| 462 |
if tracking_system is None:
|
|
|
|
| 545 |
traceback.print_exc()
|
| 546 |
raise HTTPException(status_code=500, detail=f"Error processing image: {str(e)}")
|
| 547 |
|
| 548 |
+
@app.post("/api/profiles/{global_id}")
|
| 549 |
async def create_profile(global_id: str, name: str, metadata: Optional[str] = None):
|
| 550 |
"""Create or update a person profile"""
|
| 551 |
global person_profiles
|
|
|
|
| 563 |
"profile": profile
|
| 564 |
}
|
| 565 |
|
| 566 |
+
@app.get("/api/profiles/{global_id}")
|
| 567 |
async def get_profile(global_id: str):
|
| 568 |
"""Get a person's profile"""
|
| 569 |
if global_id in person_profiles:
|
|
|
|
| 571 |
else:
|
| 572 |
raise HTTPException(status_code=404, detail="Profile not found")
|
| 573 |
|
| 574 |
+
@app.post("/api/alerts/rules")
|
| 575 |
async def create_alert_rule(rule: dict):
|
| 576 |
"""Create a new alert rule"""
|
| 577 |
global alert_rules
|
|
|
|
| 579 |
alert_rules.append(rule)
|
| 580 |
return {"message": "Alert rule created", "rule": rule}
|
| 581 |
|
| 582 |
+
@app.get("/api/alerts/rules")
|
| 583 |
async def get_alert_rules():
|
| 584 |
"""Get all alert rules"""
|
| 585 |
return {"rules": alert_rules}
|
| 586 |
|
| 587 |
+
@app.get("/api/snapshots/{filename}")
|
| 588 |
async def get_snapshot(filename: str):
|
| 589 |
"""Serve snapshot images"""
|
| 590 |
if tracking_system is None:
|
|
|
|
| 597 |
|
| 598 |
return FileResponse(snapshot_path, media_type="image/jpeg")
|
| 599 |
|
| 600 |
+
@app.get("/api/analytics")
|
| 601 |
async def get_analytics():
|
| 602 |
"""Get comprehensive system analytics"""
|
| 603 |
if tracking_system is None:
|
|
|
|
| 683 |
"timestamp": current_time
|
| 684 |
}
|
| 685 |
|
| 686 |
+
@app.websocket("/api/ws")
|
| 687 |
async def websocket_endpoint(websocket: WebSocket):
|
| 688 |
"""WebSocket endpoint for real-time alerts and updates"""
|
| 689 |
await websocket.accept()
|
hybrid_search.py
CHANGED
|
@@ -83,8 +83,8 @@ class HybridSearchConfig:
|
|
| 83 |
|
| 84 |
# Thresholds - Balanced to reduce false positives while maintaining detection
|
| 85 |
FACE_THRESHOLD = 0.65 # Moderately increased face similarity threshold
|
| 86 |
-
BODY_THRESHOLD = 0.
|
| 87 |
-
HYBRID_THRESHOLD = 0.
|
| 88 |
|
| 89 |
# Additional strictness options
|
| 90 |
REQUIRE_FACE = True # Only match if face is detected
|
|
|
|
| 83 |
|
| 84 |
# Thresholds - Balanced to reduce false positives while maintaining detection
|
| 85 |
FACE_THRESHOLD = 0.65 # Moderately increased face similarity threshold
|
| 86 |
+
BODY_THRESHOLD = 0.75 # Moderately increased body-only threshold
|
| 87 |
+
HYBRID_THRESHOLD = 0.8 # Increased combined threshold to 0.8
|
| 88 |
|
| 89 |
# Additional strictness options
|
| 90 |
REQUIRE_FACE = True # Only match if face is detected
|
lucid2-react/src/api.jsx
CHANGED
|
@@ -24,7 +24,7 @@ const apiService = {
|
|
| 24 |
|
| 25 |
removeCamera: (cameraId) => apiClient.delete(`/cameras/${cameraId}`),
|
| 26 |
|
| 27 |
-
getVideoFeed: (cameraId) => `/video_feed/${cameraId}`,
|
| 28 |
|
| 29 |
// Identity endpoints
|
| 30 |
getIdentities: () => apiClient.get('/identities'),
|
|
@@ -58,7 +58,7 @@ const apiService = {
|
|
| 58 |
// WebSocket endpoint
|
| 59 |
connectWebSocket: () => {
|
| 60 |
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
| 61 |
-
const ws = new WebSocket(`${protocol}://${window.location.host}/ws`);
|
| 62 |
return ws;
|
| 63 |
},
|
| 64 |
};
|
|
|
|
| 24 |
|
| 25 |
removeCamera: (cameraId) => apiClient.delete(`/cameras/${cameraId}`),
|
| 26 |
|
| 27 |
+
getVideoFeed: (cameraId) => `/api/video_feed/${cameraId}`,
|
| 28 |
|
| 29 |
// Identity endpoints
|
| 30 |
getIdentities: () => apiClient.get('/identities'),
|
|
|
|
| 58 |
// WebSocket endpoint
|
| 59 |
connectWebSocket: () => {
|
| 60 |
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
| 61 |
+
const ws = new WebSocket(`${protocol}://${window.location.host}/api/ws`);
|
| 62 |
return ws;
|
| 63 |
},
|
| 64 |
};
|
users.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
"email": "elujulooyinlola@gmail.com",
|
| 6 |
"full_name": "Elujulo Oyinlola",
|
| 7 |
"created_at": "2025-10-24T01:29:16.036146",
|
| 8 |
-
"last_login": "2025-
|
| 9 |
"is_active": true
|
| 10 |
}
|
| 11 |
}
|
|
|
|
| 5 |
"email": "elujulooyinlola@gmail.com",
|
| 6 |
"full_name": "Elujulo Oyinlola",
|
| 7 |
"created_at": "2025-10-24T01:29:16.036146",
|
| 8 |
+
"last_login": "2025-11-12T08:17:48.988777",
|
| 9 |
"is_active": true
|
| 10 |
}
|
| 11 |
}
|