|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
<title>🕵️♂️ Secret Agent Motion Detector</title>
|
|
|
<style>
|
|
|
|
|
|
body {
|
|
|
background-color: #1a1a1a;
|
|
|
color: #00ff41;
|
|
|
font-family: 'Courier New', Courier, monospace;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
align-items: center;
|
|
|
min-height: 100vh;
|
|
|
margin: 0;
|
|
|
padding: 20px;
|
|
|
}
|
|
|
|
|
|
h1 {
|
|
|
text-shadow: 0 0 10px #00ff41;
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
|
|
|
.instructions {
|
|
|
background: #222;
|
|
|
padding: 15px;
|
|
|
border-radius: 10px;
|
|
|
border: 1px solid #444;
|
|
|
max-width: 600px;
|
|
|
text-align: center;
|
|
|
margin-bottom: 20px;
|
|
|
color: #ddd;
|
|
|
}
|
|
|
|
|
|
|
|
|
#canvasFinal {
|
|
|
border: 4px solid #00ff41;
|
|
|
border-radius: 8px;
|
|
|
box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
|
|
|
background-color: #000;
|
|
|
max-width: 100%;
|
|
|
display: none;
|
|
|
}
|
|
|
|
|
|
|
|
|
#camStream, #canvasHidden {
|
|
|
display: none;
|
|
|
}
|
|
|
|
|
|
button {
|
|
|
background-color: #00ff41;
|
|
|
color: #000;
|
|
|
border: none;
|
|
|
padding: 15px 30px;
|
|
|
font-size: 1.2rem;
|
|
|
font-weight: bold;
|
|
|
font-family: inherit;
|
|
|
cursor: pointer;
|
|
|
border-radius: 5px;
|
|
|
margin-bottom: 20px;
|
|
|
transition: all 0.3s;
|
|
|
}
|
|
|
|
|
|
button:hover {
|
|
|
background-color: #fff;
|
|
|
box-shadow: 0 0 15px #fff;
|
|
|
}
|
|
|
|
|
|
.status {
|
|
|
margin-top: 10px;
|
|
|
font-size: 0.9rem;
|
|
|
color: #888;
|
|
|
}
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
|
|
|
<button id="startBtn" onclick="startSpyCamera()">🚀 Activate Movement Detection Mode</button>
|
|
|
|
|
|
<p class="status" id="statusText">Waiting for activation...</p>
|
|
|
|
|
|
|
|
|
<video id="camStream" playsinline autoplay></video>
|
|
|
<canvas id="canvasHidden"></canvas>
|
|
|
<canvas id="canvasFinal"></canvas>
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
|
|
const video = document.getElementById('camStream');
|
|
|
const hiddenCanvas = document.getElementById('canvasHidden');
|
|
|
const finalCanvas = document.getElementById('canvasFinal');
|
|
|
const startBtn = document.getElementById('startBtn');
|
|
|
const statusText = document.getElementById('statusText');
|
|
|
|
|
|
|
|
|
const hiddenCtx = hiddenCanvas.getContext('2d');
|
|
|
const finalCtx = finalCanvas.getContext('2d');
|
|
|
|
|
|
|
|
|
let previousFrameData = null;
|
|
|
|
|
|
async function startSpyCamera() {
|
|
|
try {
|
|
|
|
|
|
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
|
|
|
|
|
|
|
|
|
video.srcObject = stream;
|
|
|
|
|
|
|
|
|
statusText.innerText = "System Active. Scanning for movement...";
|
|
|
startBtn.style.display = "none";
|
|
|
finalCanvas.style.display = "block";
|
|
|
|
|
|
|
|
|
requestAnimationFrame(processVideo);
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
statusText.innerText = "⚠️ Error: Could not access camera. Please allow permission.";
|
|
|
console.error(err);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function processVideo() {
|
|
|
|
|
|
if (video.readyState === video.HAVE_ENOUGH_DATA) {
|
|
|
|
|
|
|
|
|
const width = video.videoWidth;
|
|
|
const height = video.videoHeight;
|
|
|
hiddenCanvas.width = width;
|
|
|
hiddenCanvas.height = height;
|
|
|
finalCanvas.width = width;
|
|
|
finalCanvas.height = height;
|
|
|
|
|
|
|
|
|
hiddenCtx.drawImage(video, 0, 0, width, height);
|
|
|
|
|
|
|
|
|
const currentFrame = hiddenCtx.getImageData(0, 0, width, height);
|
|
|
const currentData = currentFrame.data;
|
|
|
|
|
|
|
|
|
const outputImage = finalCtx.createImageData(width, height);
|
|
|
const outputData = outputImage.data;
|
|
|
|
|
|
|
|
|
if (previousFrameData) {
|
|
|
const prevData = previousFrameData.data;
|
|
|
|
|
|
|
|
|
for (let i = 0; i < currentData.length; i += 4) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outputData[i] = 0.5 * (255 - currentData[i]) + 0.5 * prevData[i];
|
|
|
outputData[i+1] = 0.5 * (255 - currentData[i+1]) + 0.5 * prevData[i+1];
|
|
|
outputData[i+2] = 0.5 * (255 - currentData[i+2]) + 0.5 * prevData[i+2];
|
|
|
outputData[i+3] = 255;
|
|
|
}
|
|
|
|
|
|
|
|
|
finalCtx.putImageData(outputImage, 0, 0);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
previousFrameData = new ImageData(
|
|
|
new Uint8ClampedArray(currentFrame.data),
|
|
|
currentFrame.width,
|
|
|
currentFrame.height
|
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
requestAnimationFrame(processVideo);
|
|
|
}
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|
|
|
|