Skip to content

Commit f96e724

Browse files
committed
remove fat
1 parent cba5087 commit f96e724

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

html/rps-tf/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<div id="info" style='display:none'></div>
2323
<div id="predictions"></div>
2424
<div id="canvas-wrapper">
25-
<canvas id="output" style=""></canvas>
25+
<canvas id="output"></canvas>
2626
<video id="video" playsinline style="
2727
-webkit-transform: scaleX(-1);
2828
transform: scaleX(-1);

html/rps-tf/index.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let videoWidth, videoHeight,
66
ringFinger: [0, 13, 14, 15, 16],
77
pinky: [0, 17, 18, 19, 20]
88
};
9-
9+
let model;
1010
const VIDEO_WIDTH = 640;
1111
const VIDEO_HEIGHT = 500;
1212
const mobile = false;
@@ -15,13 +15,27 @@ const state = {
1515
backend: 'webgl'
1616
};
1717

18-
function drawPoint(ctx, y, x, r) {
19-
ctx.beginPath();
20-
ctx.arc(x, y, r, 0, 2 * Math.PI);
21-
ctx.fill();
22-
}
23-
2418
function drawKeypoints(ctx, keypoints) {
19+
function drawPoint(ctx, y, x, r) {
20+
ctx.beginPath();
21+
ctx.arc(x, y, r, 0, 2 * Math.PI);
22+
ctx.fill();
23+
}
24+
25+
function drawPath(ctx, points, closePath) {
26+
const region = new Path2D();
27+
region.moveTo(points[0][0], points[0][1]);
28+
for (let i = 1; i < points.length; i++) {
29+
const point = points[i];
30+
region.lineTo(point[0], point[1]);
31+
}
32+
33+
if (closePath) {
34+
region.closePath();
35+
}
36+
ctx.stroke(region);
37+
}
38+
2539
const keypointsArray = keypoints;
2640

2741
for (let i = 0; i < keypointsArray.length; i++) {
@@ -38,22 +52,6 @@ function drawKeypoints(ctx, keypoints) {
3852
}
3953
}
4054

41-
function drawPath(ctx, points, closePath) {
42-
const region = new Path2D();
43-
region.moveTo(points[0][0], points[0][1]);
44-
for (let i = 1; i < points.length; i++) {
45-
const point = points[i];
46-
region.lineTo(point[0], point[1]);
47-
}
48-
49-
if (closePath) {
50-
region.closePath();
51-
}
52-
ctx.stroke(region);
53-
}
54-
55-
let model;
56-
5755
async function setupCamera() {
5856
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
5957
throw new Error(
@@ -65,8 +63,6 @@ async function setupCamera() {
6563
'audio': false,
6664
'video': {
6765
facingMode: 'user',
68-
// Only setting the video to a specified size in order to accommodate a
69-
// point cloud, so on mobile devices accept the default size.
7066
width: mobile ? undefined : VIDEO_WIDTH,
7167
height: mobile ? undefined : VIDEO_HEIGHT
7268
},

0 commit comments

Comments
 (0)