Sudipta Nayak
video related changes
1157dc7
<!-- templates/result.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Object Detection Result</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start; /* Align content at the top */
height: 100vh;
margin: 0;
}
h1 {
margin-bottom: 20px;
}
#loading {
display: none;
}
#output {
max-width: 100%;
height: auto;
display: none; /* Initially hidden until loaded */
}
#output-video {
max-width: 100%;
height: auto;
display: none; /* Initially hidden until loaded */
}
</style>
<script async src="https://docs.opencv.org/master/opencv.js" onload="onOpenCvReady();" type="text/javascript"></script>
<script type="text/javascript">
function onOpenCvReady() {
var isVideo = "{{ is_video }}"; // Assuming you pass a variable indicating whether it's a video
if (isVideo === "true") {
document.getElementById("output-video").src = "{{ output_image }}";
document.getElementById("output-video").style.display = "block"; // Show the output video
} else {
document.getElementById("output").src = "{{ output_image }}";
document.getElementById("output").style.display = "block"; // Show the output image
}
document.getElementById("loading").style.display = "none"; // Hide the loading icon
}
// Function to show loading icon while waiting for response
function showLoading() {
document.getElementById("loading").style.display = "block";
}
</script>
</head>
<body>
<h1>Object Detection Result</h1>
<form action="/detect/" method="post" enctype="multipart/form-data" onsubmit="showLoading();">
<label for="file">Upload an Image or Video :</label>
<input type="file" id="file" name="file" accept=".jpg, .jpeg, .png, .mp4, .mov" required>
<button type="submit">Detect</button>
</form>
<br/>
<div id="loading">Loading...</div>
<img id="output"/>
<video id="output-video" controls></video>
</body>
</html>