This project is an automated anomaly detection system using AI for hospital surveillance videos. It analyzes video footage to identify predefined abnormal conditions and alerts the user.
- Video Upload: Users can upload video files for analysis.
- Motion Detection: The system processes video frames and triggers analysis only when significant motion is detected, optimizing resource usage.
- AI-Powered Frame Analysis: Detected frames are sent to a Gemini-based AI model to identify specific abnormal situations.
- Anomaly Categories: The AI is prompted to look for:
- Overcrowding
- Cleanliness issues (garbage, spills)
- Staff inactivity when patients need attention
- Unattended patients in distress or waiting too long
- Aggressive behavior (arguments, altercations)
- PPE/mask violations
- Alert Display: Detected abnormal events are displayed with a timestamp and a description of the issue.
- Export Analysis: Users can export the list of detected alerts as a text file.
- Clear Results: Option to clear the displayed analysis results.
- The user uploads a video file through the web interface (
index.html). - The video plays, and
script.jscaptures frames at a regular interval (FRAME_CHECK_INTERVAL). - A basic motion detection algorithm compares consecutive frames.
- If motion exceeding a
MOTION_THRESHOLDis detected, the current frame is captured from a canvas element. - This frame is converted to a base64 JPEG image and sent to the Gemini API (
GEMINI_API_URL) along with a specific prompt detailing the abnormal conditions to look for. - If the API response indicates an abnormal condition (i.e., not "NORMAL"), the timestamp and the AI's analysis are displayed on the page.
- All detected alerts can be exported.
- Clone this repository.
- Open
index.htmlin a web browser. - Important: You need to configure the Gemini API endpoint. In
script.js, update theGEMINI_API_URLconstant with your valid Gemini API endpoint:The current placeholder isconst GEMINI_API_URL = 'YOUR_GEMINI_API_ENDPOINT_HERE';
https://llmfoundry.straive.com/gemini/v1beta/models/gemini-2.5-flash-preview-04-17:generateContent. Ensure this is correctly set up for API calls, including any necessary authentication or API keys if required by your specific endpoint. The script currently usescredentials: 'include'which might be relevant for your setup.
- HTML5
- CSS3 (Bootstrap 5)
- JavaScript (Vanilla)
- Gemini AI (for image analysis)