Skip to content

Commit 5ce13e7

Browse files
Merge pull request #195 from JingyuanZhang/master
feat(models): update humanseg models and support 2 model and update docs
2 parents 55598db + 26c89b1 commit 5ce13e7

File tree

15 files changed

+1203
-7978
lines changed

15 files changed

+1203
-7978
lines changed

packages/paddlejs-examples/humanStream/index.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77
<style>
88
body {
99
margin: 0 auto;
10-
position: fixed;
1110
width: 100%;
1211
height: 100%;
12+
overflow: auto;
13+
}
14+
video {
15+
width: 500px;
16+
height: 280px;
17+
transform: scaleX(-1);
18+
object-fit: contain;
19+
}
20+
#demo {
21+
transform: scaleX(-1);
22+
width: 500px;
23+
height: 280px;
1324
}
1425
#videoSelect::before {
1526
content: "请选择设备摄像头:";
@@ -52,9 +63,13 @@
5263
</div>
5364
</div>
5465
<canvas id="demo"></canvas>
66+
<div id="background">
67+
</div>
5568
<div id="isLoading">
5669
<p class="loading-text center">loading中……</p>
5770
</div>
71+
<div id="timer"></div>
72+
<div id="counter"></div>
5873
<!--canvas id="canvasout" width="250" height="300"></canvas-->
5974
</body>
6075
</html>

packages/paddlejs-examples/humanStream/index.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const videoToolDom = document.getElementById('video-tool');
88

99
const bgElement = document.createElement('div') as HTMLDivElement;
1010
const container = document.querySelector('body');
11+
1112
container.appendChild(bgElement);
1213

1314
load();
@@ -30,25 +31,22 @@ videoToolDom.addEventListener('click', function (e: Event) {
3031

3132
const canvas1 = document.getElementById('demo') as HTMLCanvasElement;
3233

33-
const ctx = canvas1.getContext('2d');
34-
const img = new Image();
35-
img.src = './bgImgs/bg.jpg';
36-
img.onload = function () {
37-
ctx.drawImage(img, 0, 0, canvas1.width, canvas1.height);
38-
};
3934

35+
const videoCanvas = document.createElement('canvas') as HTMLCanvasElement;
36+
const videoCanvasCtx = videoCanvas.getContext('2d');
4037
async function load() {
41-
await humanseg.load();
38+
await humanseg.load(true, true);
4239
camera = new Camera(video, {
40+
mirror: true,
41+
enableOnInactiveState: true,
4342
onFrame: async () => {
43+
videoCanvas.width = video.width;
44+
videoCanvas.height = video.height;
45+
videoCanvasCtx.drawImage(video, 0, 0, video.width, video.height);
4446
const {
4547
data
46-
} = await humanseg.getGrayValue(video);
47-
humanseg.drawHumanSeg(canvas1, data);
48+
} = await humanseg.getGrayValue(videoCanvas);
49+
humanseg.blurBackground(data, canvas1);
4850
}
49-
// canvas大小不合适可以自行修改width,height
50-
// width: 800,
51-
// height: 600
5251
});
5352
}
54-

0 commit comments

Comments
 (0)