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TF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Scene Exam - Weapon Detection</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 10 |
+
max-width: 800px;
|
| 11 |
+
margin: 0 auto;
|
| 12 |
+
padding: 20px;
|
| 13 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 14 |
+
color: white;
|
| 15 |
+
min-height: 100vh;
|
| 16 |
+
}
|
| 17 |
+
.container {
|
| 18 |
+
background: rgba(255, 255, 255, 0.1);
|
| 19 |
+
backdrop-filter: blur(10px);
|
| 20 |
+
border-radius: 20px;
|
| 21 |
+
padding: 30px;
|
| 22 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 23 |
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 24 |
+
}
|
| 25 |
+
h1 {
|
| 26 |
+
text-align: center;
|
| 27 |
+
margin-bottom: 30px;
|
| 28 |
+
font-size: 2.5em;
|
| 29 |
+
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
| 30 |
+
}
|
| 31 |
+
.upload-area {
|
| 32 |
+
border: 3px dashed rgba(255, 255, 255, 0.5);
|
| 33 |
+
border-radius: 15px;
|
| 34 |
+
padding: 40px;
|
| 35 |
+
text-align: center;
|
| 36 |
+
margin-bottom: 30px;
|
| 37 |
+
transition: all 0.3s ease;
|
| 38 |
+
cursor: pointer;
|
| 39 |
+
}
|
| 40 |
+
.upload-area:hover {
|
| 41 |
+
border-color: rgba(255, 255, 255, 0.8);
|
| 42 |
+
background: rgba(255, 255, 255, 0.05);
|
| 43 |
+
}
|
| 44 |
+
.upload-area.dragover {
|
| 45 |
+
border-color: #4CAF50;
|
| 46 |
+
background: rgba(76, 175, 80, 0.1);
|
| 47 |
+
}
|
| 48 |
+
input[type="file"] {
|
| 49 |
+
display: none;
|
| 50 |
+
}
|
| 51 |
+
.btn {
|
| 52 |
+
background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
|
| 53 |
+
border: none;
|
| 54 |
+
padding: 12px 30px;
|
| 55 |
+
border-radius: 25px;
|
| 56 |
+
color: white;
|
| 57 |
+
font-size: 16px;
|
| 58 |
+
cursor: pointer;
|
| 59 |
+
transition: all 0.3s ease;
|
| 60 |
+
margin: 10px;
|
| 61 |
+
}
|
| 62 |
+
.btn:hover {
|
| 63 |
+
transform: translateY(-2px);
|
| 64 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
|
| 65 |
+
}
|
| 66 |
+
.result-area {
|
| 67 |
+
margin-top: 30px;
|
| 68 |
+
padding: 20px;
|
| 69 |
+
background: rgba(255, 255, 255, 0.1);
|
| 70 |
+
border-radius: 15px;
|
| 71 |
+
display: none;
|
| 72 |
+
}
|
| 73 |
+
.preview-image {
|
| 74 |
+
max-width: 100%;
|
| 75 |
+
border-radius: 10px;
|
| 76 |
+
margin: 20px 0;
|
| 77 |
+
}
|
| 78 |
+
.status {
|
| 79 |
+
font-size: 1.2em;
|
| 80 |
+
font-weight: bold;
|
| 81 |
+
padding: 10px;
|
| 82 |
+
border-radius: 10px;
|
| 83 |
+
margin: 10px 0;
|
| 84 |
+
}
|
| 85 |
+
.safe { background: rgba(76, 175, 80, 0.3); }
|
| 86 |
+
.warning { background: rgba(255, 152, 0, 0.3); }
|
| 87 |
+
.danger { background: rgba(244, 67, 54, 0.3); }
|
| 88 |
+
</style>
|
| 89 |
+
</head>
|
| 90 |
+
<body>
|
| 91 |
+
<div class="container">
|
| 92 |
+
<h1>🔍 Scene Exam</h1>
|
| 93 |
+
<p style="text-align: center; font-size: 1.2em; margin-bottom: 30px;">
|
| 94 |
+
AI-Powered Weapon Detection System<br>
|
| 95 |
+
<small>Upload an image to analyze for potential threats</small>
|
| 96 |
+
</p>
|
| 97 |
+
|
| 98 |
+
<div class="upload-area" onclick="document.getElementById('fileInput').click()">
|
| 99 |
+
<div id="uploadText">
|
| 100 |
+
<h3>📷 Click to Upload Image</h3>
|
| 101 |
+
<p>Or drag and drop an image here</p>
|
| 102 |
+
<p><small>Supports: JPG, PNG, GIF</small></p>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
<input type="file" id="fileInput" accept="image/*">
|
| 107 |
+
|
| 108 |
+
<div style="text-align: center;">
|
| 109 |
+
<button class="btn" onclick="startCamera()">📹 Use Camera</button>
|
| 110 |
+
<button class="btn" onclick="clearResults()">🗑️ Clear</button>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<div class="result-area" id="resultArea">
|
| 114 |
+
<h3>Analysis Results:</h3>
|
| 115 |
+
<div id="statusDiv" class="status safe">
|
| 116 |
+
✅ System Ready - No threats detected
|
| 117 |
+
</div>
|
| 118 |
+
<div id="detailsDiv">
|
| 119 |
+
Upload an image to begin analysis...
|
| 120 |
+
</div>
|
| 121 |
+
<canvas id="analysisCanvas" style="display: none;"></canvas>
|
| 122 |
+
</div>
|
| 123 |
+
</div>
|
| 124 |
+
|
| 125 |
+
<script>
|
| 126 |
+
const fileInput = document.getElementById('fileInput');
|
| 127 |
+
const uploadArea = document.querySelector('.upload-area');
|
| 128 |
+
const resultArea = document.getElementById('resultArea');
|
| 129 |
+
const statusDiv = document.getElementById('statusDiv');
|
| 130 |
+
const detailsDiv = document.getElementById('detailsDiv');
|
| 131 |
+
const canvas = document.getElementById('analysisCanvas');
|
| 132 |
+
const ctx = canvas.getContext('2d');
|
| 133 |
+
|
| 134 |
+
// Simple mock detection (since we can't run YOLO in browser)
|
| 135 |
+
const weaponKeywords = ['knife', 'gun', 'weapon', 'blade', 'rifle', 'pistol'];
|
| 136 |
+
const personKeywords = ['person', 'people', 'human', 'man', 'woman', 'face'];
|
| 137 |
+
|
| 138 |
+
fileInput.addEventListener('change', handleFile);
|
| 139 |
+
|
| 140 |
+
// Drag and drop functionality
|
| 141 |
+
uploadArea.addEventListener('dragover', (e) => {
|
| 142 |
+
e.preventDefault();
|
| 143 |
+
uploadArea.classList.add('dragover');
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
+
uploadArea.addEventListener('dragleave', () => {
|
| 147 |
+
uploadArea.classList.remove('dragover');
|
| 148 |
+
});
|
| 149 |
+
|
| 150 |
+
uploadArea.addEventListener('drop', (e) => {
|
| 151 |
+
e.preventDefault();
|
| 152 |
+
uploadArea.classList.remove('dragover');
|
| 153 |
+
const files = e.dataTransfer.files;
|
| 154 |
+
if (files.length > 0) {
|
| 155 |
+
handleFile({ target: { files } });
|
| 156 |
+
}
|
| 157 |
+
});
|
| 158 |
+
|
| 159 |
+
function handleFile(event) {
|
| 160 |
+
const file = event.target.files[0];
|
| 161 |
+
if (!file) return;
|
| 162 |
+
|
| 163 |
+
const reader = new FileReader();
|
| 164 |
+
reader.onload = function(e) {
|
| 165 |
+
displayImage(e.target.result, file.name);
|
| 166 |
+
analyzeImage(file.name.toLowerCase());
|
| 167 |
+
};
|
| 168 |
+
reader.readAsDataURL(file);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
function displayImage(src, filename) {
|
| 172 |
+
canvas.style.display = 'block';
|
| 173 |
+
const img = new Image();
|
| 174 |
+
img.onload = function() {
|
| 175 |
+
canvas.width = Math.min(img.width, 600);
|
| 176 |
+
canvas.height = (img.height * canvas.width) / img.width;
|
| 177 |
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
| 178 |
+
|
| 179 |
+
// Add mock detection boxes
|
| 180 |
+
addMockDetections();
|
| 181 |
+
};
|
| 182 |
+
img.src = src;
|
| 183 |
+
resultArea.style.display = 'block';
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
function addMockDetections() {
|
| 187 |
+
// Add some mock detection boxes for demo
|
| 188 |
+
ctx.strokeStyle = '#FF4444';
|
| 189 |
+
ctx.lineWidth = 3;
|
| 190 |
+
ctx.font = '16px Arial';
|
| 191 |
+
ctx.fillStyle = '#FF4444';
|
| 192 |
+
|
| 193 |
+
// Mock detection box (you'd replace this with real AI results)
|
| 194 |
+
if (Math.random() > 0.7) {
|
| 195 |
+
const x = Math.random() * (canvas.width - 100);
|
| 196 |
+
const y = Math.random() * (canvas.height - 100);
|
| 197 |
+
ctx.strokeRect(x, y, 80, 60);
|
| 198 |
+
ctx.fillText('Person', x, y - 5);
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
function analyzeImage(filename) {
|
| 203 |
+
// Mock analysis based on filename
|
| 204 |
+
let threatLevel = 'safe';
|
| 205 |
+
let details = 'No suspicious objects detected.';
|
| 206 |
+
|
| 207 |
+
// Simple keyword detection (mock)
|
| 208 |
+
const hasWeapon = weaponKeywords.some(keyword => filename.includes(keyword));
|
| 209 |
+
const hasPerson = personKeywords.some(keyword => filename.includes(keyword));
|
| 210 |
+
|
| 211 |
+
if (hasWeapon) {
|
| 212 |
+
threatLevel = 'danger';
|
| 213 |
+
details = '⚠️ POTENTIAL WEAPON DETECTED!\nRecommend immediate review.';
|
| 214 |
+
} else if (hasPerson) {
|
| 215 |
+
threatLevel = 'warning';
|
| 216 |
+
details = '👤 Person detected in scene.\nNo obvious threats identified.';
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
updateStatus(threatLevel, details);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
function updateStatus(level, details) {
|
| 223 |
+
statusDiv.className = `status ${level}`;
|
| 224 |
+
|
| 225 |
+
switch(level) {
|
| 226 |
+
case 'safe':
|
| 227 |
+
statusDiv.innerHTML = '✅ SCENE SAFE - No threats detected';
|
| 228 |
+
break;
|
| 229 |
+
case 'warning':
|
| 230 |
+
statusDiv.innerHTML = '⚠️ CAUTION - Review recommended';
|
| 231 |
+
break;
|
| 232 |
+
case 'danger':
|
| 233 |
+
statusDiv.innerHTML = '🚨 ALERT - Potential threat detected';
|
| 234 |
+
break;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
detailsDiv.innerHTML = details;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
function startCamera() {
|
| 241 |
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
| 242 |
+
navigator.mediaDevices.getUserMedia({ video: true })
|
| 243 |
+
.then(function(stream) {
|
| 244 |
+
// Create video element for camera
|
| 245 |
+
const video = document.createElement('video');
|
| 246 |
+
video.srcObject = stream;
|
| 247 |
+
video.play();
|
| 248 |
+
|
| 249 |
+
// Replace upload area with video
|
| 250 |
+
uploadArea.innerHTML = '';
|
| 251 |
+
uploadArea.appendChild(video);
|
| 252 |
+
video.style.width = '100%';
|
| 253 |
+
video.style.borderRadius = '10px';
|
| 254 |
+
|
| 255 |
+
// Add capture button
|
| 256 |
+
const captureBtn = document.createElement('button');
|
| 257 |
+
captureBtn.className = 'btn';
|
| 258 |
+
captureBtn.innerHTML = '📸 Capture';
|
| 259 |
+
captureBtn.onclick = () => captureFrame(video, stream);
|
| 260 |
+
uploadArea.appendChild(captureBtn);
|
| 261 |
+
})
|
| 262 |
+
.catch(function(err) {
|
| 263 |
+
alert('Camera access denied or not available');
|
| 264 |
+
});
|
| 265 |
+
} else {
|
| 266 |
+
alert('Camera not supported by this browser');
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
function captureFrame(video, stream) {
|
| 271 |
+
const captureCanvas = document.createElement('canvas');
|
| 272 |
+
captureCanvas.width = video.videoWidth;
|
| 273 |
+
captureCanvas.height = video.videoHeight;
|
| 274 |
+
captureCanvas.getContext('2d').drawImage(video, 0, 0);
|
| 275 |
+
|
| 276 |
+
// Stop the camera
|
| 277 |
+
stream.getTracks().forEach(track => track.stop());
|
| 278 |
+
|
| 279 |
+
// Display captured frame
|
| 280 |
+
displayImage(captureCanvas.toDataURL(), 'camera_capture.jpg');
|
| 281 |
+
|
| 282 |
+
// Reset upload area
|
| 283 |
+
uploadArea.innerHTML = `
|
| 284 |
+
<div id="uploadText">
|
| 285 |
+
<h3>📷 Click to Upload Image</h3>
|
| 286 |
+
<p>Or drag and drop an image here</p>
|
| 287 |
+
<p><small>Supports: JPG, PNG, GIF</small></p>
|
| 288 |
+
</div>
|
| 289 |
+
`;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
function clearResults() {
|
| 293 |
+
resultArea.style.display = 'none';
|
| 294 |
+
statusDiv.className = 'status safe';
|
| 295 |
+
statusDiv.innerHTML = '✅ System Ready - No threats detected';
|
| 296 |
+
detailsDiv.innerHTML = 'Upload an image to begin analysis...';
|
| 297 |
+
fileInput.value = '';
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
// Show result area on load
|
| 301 |
+
resultArea.style.display = 'block';
|
| 302 |
+
</script>
|
| 303 |
+
</body>
|
| 304 |
</html>
|