- Linienschnitt-Algorithmus für präzise Fahrzeugzählung - Interaktive Linienauswahl im Browser (Canvas-basiert) - Session-Management für benutzerdefinierte Zähllinien - Typ-spezifische Zähler (Autos, LKW, Busse, Motorräder) - REST-API für Linienkonfiguration und Zähler-Reset - Gestrichelte Zähllinie als Video-Overlay - Detailliertes Zähler-Display im Video Features: - Linienüberquerung-Erkennung (beide Richtungen) - Keine Mehrfachzählung durch Track-ID-Management - Funktioniert für Webcam und Video-Upload - Benutzerfreundliche UI mit Echtzeit-Feedback 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
223 lines
7.5 KiB
HTML
223 lines
7.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Video Playback</title>
|
|
<style>
|
|
body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
margin: 0;
|
|
background-color: #f0f0f0;
|
|
padding: 20px;
|
|
}
|
|
.video-container {
|
|
position: relative;
|
|
width: 1020px;
|
|
height: 600px;
|
|
}
|
|
#videoFeed {
|
|
width: 1020px;
|
|
height: 600px;
|
|
border: 2px solid #ccc;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
display: block;
|
|
}
|
|
#lineCanvas {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 1020px;
|
|
height: 600px;
|
|
cursor: crosshair;
|
|
pointer-events: none;
|
|
}
|
|
#lineCanvas.active {
|
|
pointer-events: auto;
|
|
}
|
|
.controls {
|
|
margin-top: 20px;
|
|
display: flex;
|
|
gap: 10px;
|
|
flex-wrap: wrap;
|
|
justify-content: center;
|
|
}
|
|
button {
|
|
padding: 10px 20px;
|
|
font-size: 16px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
background-color: #007bff;
|
|
color: white;
|
|
transition: background-color 0.3s;
|
|
}
|
|
button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
button.active {
|
|
background-color: #28a745;
|
|
}
|
|
button.danger {
|
|
background-color: #dc3545;
|
|
}
|
|
button.danger:hover {
|
|
background-color: #c82333;
|
|
}
|
|
a {
|
|
margin-top: 20px;
|
|
text-decoration: none;
|
|
color: #007bff;
|
|
font-size: 18px;
|
|
}
|
|
a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
.info {
|
|
margin-top: 10px;
|
|
color: #555;
|
|
font-size: 14px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Video Playback with Object Detection</h1>
|
|
<div class="video-container">
|
|
<img id="videoFeed" src="{{ url_for('video_feed', filename=filename) }}" />
|
|
<canvas id="lineCanvas"></canvas>
|
|
</div>
|
|
<div class="controls">
|
|
<button id="setLineBtn">Zähllinie setzen</button>
|
|
<button id="resetCountBtn" class="danger">Zähler zurücksetzen</button>
|
|
</div>
|
|
<div class="info" id="infoText">Klicke auf "Zähllinie setzen" und dann zweimal auf das Video, um die Zähllinie zu definieren.</div>
|
|
<a href="/">Back to Home</a>
|
|
|
|
<script>
|
|
const canvas = document.getElementById('lineCanvas');
|
|
const ctx = canvas.getContext('2d');
|
|
const setLineBtn = document.getElementById('setLineBtn');
|
|
const resetCountBtn = document.getElementById('resetCountBtn');
|
|
const infoText = document.getElementById('infoText');
|
|
|
|
let isSettingLine = false;
|
|
let firstPoint = null;
|
|
let currentLine = null;
|
|
|
|
// Load existing line from server
|
|
fetch('/api/get_line')
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
currentLine = data;
|
|
drawLine();
|
|
});
|
|
|
|
setLineBtn.addEventListener('click', () => {
|
|
isSettingLine = !isSettingLine;
|
|
if (isSettingLine) {
|
|
setLineBtn.textContent = 'Abbrechen';
|
|
setLineBtn.classList.add('active');
|
|
canvas.classList.add('active');
|
|
firstPoint = null;
|
|
infoText.textContent = 'Klicke auf den Startpunkt der Zähllinie...';
|
|
} else {
|
|
setLineBtn.textContent = 'Zähllinie setzen';
|
|
setLineBtn.classList.remove('active');
|
|
canvas.classList.remove('active');
|
|
firstPoint = null;
|
|
infoText.textContent = 'Klicke auf "Zähllinie setzen" und dann zweimal auf das Video, um die Zähllinie zu definieren.';
|
|
drawLine();
|
|
}
|
|
});
|
|
|
|
canvas.addEventListener('click', (e) => {
|
|
if (!isSettingLine) return;
|
|
|
|
const rect = canvas.getBoundingClientRect();
|
|
const x = Math.round(e.clientX - rect.left);
|
|
const y = Math.round(e.clientY - rect.top);
|
|
|
|
if (!firstPoint) {
|
|
firstPoint = { x, y };
|
|
infoText.textContent = 'Klicke auf den Endpunkt der Zähllinie...';
|
|
drawTemporaryPoint(x, y);
|
|
} else {
|
|
currentLine = { x1: firstPoint.x, y1: firstPoint.y, x2: x, y2: y };
|
|
|
|
// Send line to server
|
|
fetch('/api/set_line', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(currentLine)
|
|
})
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
console.log('Line set:', data);
|
|
infoText.textContent = 'Zähllinie erfolgreich gesetzt!';
|
|
setTimeout(() => {
|
|
infoText.textContent = 'Klicke auf "Zähllinie setzen" und dann zweimal auf das Video, um die Zähllinie zu definieren.';
|
|
}, 2000);
|
|
});
|
|
|
|
isSettingLine = false;
|
|
setLineBtn.textContent = 'Zähllinie setzen';
|
|
setLineBtn.classList.remove('active');
|
|
canvas.classList.remove('active');
|
|
firstPoint = null;
|
|
drawLine();
|
|
}
|
|
});
|
|
|
|
resetCountBtn.addEventListener('click', () => {
|
|
fetch('/api/reset_count', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
console.log('Count reset:', data);
|
|
infoText.textContent = 'Zähler wurde zurückgesetzt!';
|
|
setTimeout(() => {
|
|
infoText.textContent = 'Klicke auf "Zähllinie setzen" und dann zweimal auf das Video, um die Zähllinie zu definieren.';
|
|
}, 2000);
|
|
});
|
|
});
|
|
|
|
function drawLine() {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
if (currentLine) {
|
|
ctx.strokeStyle = 'rgba(255, 255, 0, 0.8)';
|
|
ctx.lineWidth = 3;
|
|
ctx.setLineDash([10, 10]);
|
|
ctx.beginPath();
|
|
ctx.moveTo(currentLine.x1, currentLine.y1);
|
|
ctx.lineTo(currentLine.x2, currentLine.y2);
|
|
ctx.stroke();
|
|
ctx.setLineDash([]);
|
|
}
|
|
}
|
|
|
|
function drawTemporaryPoint(x, y) {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
drawLine();
|
|
ctx.fillStyle = 'rgba(255, 255, 0, 0.8)';
|
|
ctx.beginPath();
|
|
ctx.arc(x, y, 5, 0, 2 * Math.PI);
|
|
ctx.fill();
|
|
}
|
|
|
|
// Redraw line periodically in case it gets cleared
|
|
setInterval(() => {
|
|
if (!isSettingLine && currentLine) {
|
|
drawLine();
|
|
}
|
|
}, 100);
|
|
</script>
|
|
</body>
|
|
</html>
|