@@ -96,8 +96,9 @@ const main =
9696 }
9797
9898function getStraightLineParams(arrs) {
99+ const deltaX = 5.0;
99100 const x1 = arrs[0][0]; const y1 = arrs[0][1];
100- const x2 = arrs[3][0]; const y2 = arrs[3][1];
101+ const x2 = arrs[3][0] < x1 ? arrs[3][0] - deltaX : arrs[3][0] + deltaX ; const y2 = arrs[3][1];
101102 const a = y2 - y1;
102103 const b = x1 - x2;
103104 const c = a * x1 + b * y1;
@@ -113,7 +114,7 @@ function getAllStraightLineParams(annots) {
113114 return {
114115 'thumb': getStraightLineParams(annots['thumb']),
115116 'indexFinger': getStraightLineParams(annots['indexFinger']),
116- 'middleFinder ': getStraightLineParams(annots['middleFinger']),
117+ 'middleFinger ': getStraightLineParams(annots['middleFinger']),
117118 'ringFinger': getStraightLineParams(annots['ringFinger']),
118119 'pinky': getStraightLineParams(annots['pinky'])
119120 }
@@ -148,6 +149,16 @@ function computeMse(p, xy) {
148149 return mse;
149150}
150151
152+ function computeAllMse(params, xys) {
153+ return {
154+ thumb: computeMse(params['thumb'], xys['thumb']),
155+ indexFinger: computeMse(params['indexFinger'], xys['indexFinger']),
156+ middleFinger: computeMse(params['middleFinger'], xys['middleFinger']),
157+ ringFinger: computeMse(params['ringFinger'], xys['ringFinger']),
158+ pinky: computeMse(params['pinky'], xys['pinky'])
159+ }
160+ }
161+
151162const landmarksRealTime = async (video) => {
152163 videoWidth = video.videoWidth;
153164 videoHeight = video.videoHeight;
@@ -185,8 +196,10 @@ const landmarksRealTime = async (video) => {
185196 console.log(annots);
186197
187198 const params = getAllStraightLineParams(annots);
188- const xy = toXY(annots);
189- console.log(computeMse(params['indexFinger'], xy['indexFinger']));
199+ const xys = toXY(annots);
200+ console.log(params);
201+ console.log(xys);
202+ console.log(computeAllMse(params, xys));
190203
191204 drawKeypoints(ctx, result, annots);
192205 }
0 commit comments