Skip to content

Commit ab55d18

Browse files
committed
Update video size
1 parent 1318a27 commit ab55d18

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

‎index.html‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,29 @@
88
<script defer src="face-api.min.js"></script>
99
<script defer src="script.js"></script>
1010
<style>
11-
body {
12-
margin: 0;
13-
padding: 0;
14-
width: 100vw;
15-
height: 100vh;
16-
display: flex;
17-
justify-content: center;
18-
align-items: center;
19-
}
20-
2111
canvas {
2212
position: absolute;
2313
}
2414

15+
#container {
16+
position: relative;
17+
display: flex;
18+
justify-content: center;
19+
}
20+
2521
#video {
2622
display: none;
2723
}
24+
25+
#loading {
26+
text-align: center;
27+
}
2828
</style>
2929
</head>
3030
<body>
31-
<video id="video" width="720" height="560" autoplay muted></video>
32-
<p id="loading">Wating for camera to load</p>
31+
<div id="container">
32+
<video id="video" width="300" height="300" autoplay muted></video>
33+
<p id="loading">Wating for camera to load</p>
34+
</div>
3335
</body>
3436
</html>

‎script.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const container = document.getElementById("container");
12
const video = document.getElementById("video");
23
const loader = document.getElementById("loading");
34

@@ -25,7 +26,7 @@ function startVideo() {
2526

2627
video.addEventListener("play", () => {
2728
const canvas = faceapi.createCanvasFromMedia(video);
28-
document.body.append(canvas);
29+
container.appendChild(canvas);
2930
const displaySize = { width: video.width, height: video.height };
3031
faceapi.matchDimensions(canvas, displaySize);
3132
setInterval(async () => {

0 commit comments

Comments
 (0)