yootd 0.0.87 → 0.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/video-player/index.js +128 -151
- package/package.json +4 -11
@@ -1,10 +1,10 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
5
4
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
6
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
7
6
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
7
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
8
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
10
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
@@ -14,15 +14,17 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
14
14
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
15
15
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
17
|
-
import * as faceapi from '@vladmandic/face-api';
|
18
|
-
|
19
|
-
import * as
|
17
|
+
// import * as faceapi from '@vladmandic/face-api';
|
18
|
+
//
|
19
|
+
// import * as posedetection from '@tensorflow-models/pose-detection';
|
20
|
+
// import * as tf from '@tensorflow/tfjs';
|
21
|
+
|
20
22
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
21
23
|
import { EndPoint } from 'yootd-webrtc-sdk';
|
22
24
|
import { useBem } from "../hooks/useBem";
|
23
25
|
import "./index.scss";
|
24
26
|
import { throttle } from 'lodash';
|
25
|
-
import {
|
27
|
+
import { Spin } from "./..";
|
26
28
|
import { useOSS } from "../hooks/useOSS";
|
27
29
|
import controlBottomBg from "./assets/control-background.png";
|
28
30
|
var PROGRESS_BAR_HEIGHT = 63;
|
@@ -31,6 +33,8 @@ var MAX_RESULTS = 20; // maximum number of results to return
|
|
31
33
|
|
32
34
|
// print hello world
|
33
35
|
|
36
|
+
// type DetectionResult = Record<string, any>;
|
37
|
+
|
34
38
|
var speeds = ['2.0', '1.75', '1.5', '1.25', '1.0', '0.75', '0.5'];
|
35
39
|
export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
36
40
|
var src = _ref.src,
|
@@ -62,6 +66,8 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
62
66
|
var videoRef = useRef(null);
|
63
67
|
var canvasRef = useRef(null);
|
64
68
|
var poseCanvasRef = useRef(null);
|
69
|
+
var detectAllFacesRef = useRef();
|
70
|
+
var getAdjacentPairsRef = useRef();
|
65
71
|
var _useState = useState(null),
|
66
72
|
_useState2 = _slicedToArray(_useState, 2),
|
67
73
|
poseDetector = _useState2[0],
|
@@ -291,7 +297,6 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
291
297
|
|
292
298
|
// convert video duration (seconds) to hh::mm:ss if the duration is larger than 3600 , else convert to mm:ss
|
293
299
|
var formatDuration = function formatDuration(duration) {
|
294
|
-
console.log('duration 111111111', duration);
|
295
300
|
var hours = Math.floor(duration / 3600);
|
296
301
|
var minutes = Math.floor(duration % 3600 / 60);
|
297
302
|
var seconds = Math.floor(duration % 60);
|
@@ -357,80 +362,6 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
357
362
|
return !prev;
|
358
363
|
});
|
359
364
|
};
|
360
|
-
var initFaceApi = useCallback(function () {
|
361
|
-
void _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
362
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
363
|
-
while (1) switch (_context.prev = _context.next) {
|
364
|
-
case 0:
|
365
|
-
_context.prev = 0;
|
366
|
-
_context.next = 3;
|
367
|
-
return faceapi.nets.ssdMobilenetv1.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
368
|
-
case 3:
|
369
|
-
_context.next = 5;
|
370
|
-
return faceapi.nets.ssdMobilenetv1.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
371
|
-
case 5:
|
372
|
-
_context.next = 7;
|
373
|
-
return faceapi.nets.ageGenderNet.load("".concat(OSS, "/face-api-models/model"));
|
374
|
-
case 7:
|
375
|
-
_context.next = 9;
|
376
|
-
return faceapi.nets.faceLandmark68Net.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
377
|
-
case 9:
|
378
|
-
_context.next = 11;
|
379
|
-
return faceapi.nets.faceRecognitionNet.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
380
|
-
case 11:
|
381
|
-
_context.next = 13;
|
382
|
-
return faceapi.nets.faceExpressionNet.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
383
|
-
case 13:
|
384
|
-
setOptions(new faceapi.SsdMobilenetv1Options({
|
385
|
-
minConfidence: MIN_SCORE,
|
386
|
-
maxResults: MAX_RESULTS
|
387
|
-
}));
|
388
|
-
setFaceApiInited(true);
|
389
|
-
_context.next = 20;
|
390
|
-
break;
|
391
|
-
case 17:
|
392
|
-
_context.prev = 17;
|
393
|
-
_context.t0 = _context["catch"](0);
|
394
|
-
console.log(_context.t0);
|
395
|
-
case 20:
|
396
|
-
case "end":
|
397
|
-
return _context.stop();
|
398
|
-
}
|
399
|
-
}, _callee, null, [[0, 17]]);
|
400
|
-
}))();
|
401
|
-
}, []);
|
402
|
-
var initPoseDetecter = useCallback(function () {
|
403
|
-
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
404
|
-
var detectorConfig, _poseDetector;
|
405
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
406
|
-
while (1) switch (_context2.prev = _context2.next) {
|
407
|
-
case 0:
|
408
|
-
_context2.prev = 0;
|
409
|
-
detectorConfig = {
|
410
|
-
modelType: posedetection.movenet.modelType.MULTIPOSE_LIGHTNING,
|
411
|
-
enableTracking: true,
|
412
|
-
trackerType: posedetection.TrackerType.BoundingBox,
|
413
|
-
scoreThreshold: 0.3,
|
414
|
-
modelUrl: "".concat(OSS, "/model-zoo/pose-detection-models/model.json")
|
415
|
-
};
|
416
|
-
_context2.next = 4;
|
417
|
-
return posedetection.createDetector(posedetection.SupportedModels.MoveNet, detectorConfig);
|
418
|
-
case 4:
|
419
|
-
_poseDetector = _context2.sent;
|
420
|
-
setPoseDetector(_poseDetector);
|
421
|
-
_context2.next = 11;
|
422
|
-
break;
|
423
|
-
case 8:
|
424
|
-
_context2.prev = 8;
|
425
|
-
_context2.t0 = _context2["catch"](0);
|
426
|
-
void message.error('初始化姿态检测器失败');
|
427
|
-
case 11:
|
428
|
-
case "end":
|
429
|
-
return _context2.stop();
|
430
|
-
}
|
431
|
-
}, _callee2, null, [[0, 8]]);
|
432
|
-
}))();
|
433
|
-
}, []);
|
434
365
|
var drawFaces = useCallback(function (canvas, detections, fps, faceFeature) {
|
435
366
|
var ctx = canvas.getContext('2d', {
|
436
367
|
willReadFrequently: true
|
@@ -543,9 +474,9 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
543
474
|
}, []);
|
544
475
|
var detectFaces = useCallback(function () {
|
545
476
|
return new Promise(function (resolve, reject) {
|
546
|
-
if (videoRef.current != null && options != null && faceApiInited) {
|
477
|
+
if (videoRef.current != null && detectAllFacesRef.current != null && options != null && faceApiInited) {
|
547
478
|
var t0 = performance.now();
|
548
|
-
|
479
|
+
detectAllFacesRef.current(videoRef.current, options).withFaceLandmarks().withFaceExpressions().withAgeAndGender()
|
549
480
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
550
481
|
// @ts-ignore
|
551
482
|
.then(function (detections) {
|
@@ -581,11 +512,15 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
581
512
|
|
582
513
|
// 绘制骨架
|
583
514
|
var drawSkeleton = function drawSkeleton(keypoints, ctx) {
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
515
|
+
if (getAdjacentPairsRef.current == null) {
|
516
|
+
return;
|
517
|
+
}
|
518
|
+
// @ts-expect-error
|
519
|
+
var adjacentPairs = getAdjacentPairsRef.current('MoveNet');
|
520
|
+
adjacentPairs.forEach(function (_ref3) {
|
521
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
522
|
+
i = _ref4[0],
|
523
|
+
j = _ref4[1];
|
589
524
|
var kp1 = keypoints[i];
|
590
525
|
var kp2 = keypoints[j];
|
591
526
|
if (kp1.score && kp2.score && kp1.score > 0.3 && kp2.score > 0.3) {
|
@@ -616,34 +551,34 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
616
551
|
var video = videoRef.current;
|
617
552
|
var canvas = poseCanvasRef.current;
|
618
553
|
var detect = /*#__PURE__*/function () {
|
619
|
-
var
|
554
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
620
555
|
var pose;
|
621
|
-
return _regeneratorRuntime().wrap(function
|
622
|
-
while (1) switch (
|
556
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
557
|
+
while (1) switch (_context.prev = _context.next) {
|
623
558
|
case 0:
|
624
|
-
|
625
|
-
|
559
|
+
_context.prev = 0;
|
560
|
+
_context.next = 3;
|
626
561
|
return poseDetector.estimatePoses(video, {
|
627
562
|
flipHorizontal: false,
|
628
563
|
maxPoses: 1
|
629
564
|
});
|
630
565
|
case 3:
|
631
|
-
pose =
|
566
|
+
pose = _context.sent;
|
632
567
|
drawPose(canvas, pose);
|
633
|
-
|
568
|
+
_context.next = 10;
|
634
569
|
break;
|
635
570
|
case 7:
|
636
|
-
|
637
|
-
|
638
|
-
console.error('检测肢体失败',
|
571
|
+
_context.prev = 7;
|
572
|
+
_context.t0 = _context["catch"](0);
|
573
|
+
console.error('检测肢体失败', _context.t0);
|
639
574
|
case 10:
|
640
575
|
case "end":
|
641
|
-
return
|
576
|
+
return _context.stop();
|
642
577
|
}
|
643
|
-
},
|
578
|
+
}, _callee, null, [[0, 7]]);
|
644
579
|
}));
|
645
580
|
return function detect() {
|
646
|
-
return
|
581
|
+
return _ref5.apply(this, arguments);
|
647
582
|
};
|
648
583
|
}();
|
649
584
|
detect();
|
@@ -698,6 +633,99 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
698
633
|
}
|
699
634
|
}
|
700
635
|
};
|
636
|
+
useEffect(function () {
|
637
|
+
var loaded = true;
|
638
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
639
|
+
var faceapi, posedetection, tf, detectorConfig, _poseDetector;
|
640
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
641
|
+
while (1) switch (_context2.prev = _context2.next) {
|
642
|
+
case 0:
|
643
|
+
_context2.next = 2;
|
644
|
+
return import('@vladmandic/face-api');
|
645
|
+
case 2:
|
646
|
+
faceapi = _context2.sent;
|
647
|
+
_context2.next = 5;
|
648
|
+
return import('@tensorflow-models/pose-detection');
|
649
|
+
case 5:
|
650
|
+
posedetection = _context2.sent;
|
651
|
+
_context2.next = 8;
|
652
|
+
return import('@tensorflow/tfjs');
|
653
|
+
case 8:
|
654
|
+
tf = _context2.sent;
|
655
|
+
console.log('tf', tf.ready);
|
656
|
+
if (!(loaded && !faceApiInited && (aiFeature.emotion || aiFeature.character || aiFeature.anchor))) {
|
657
|
+
_context2.next = 34;
|
658
|
+
break;
|
659
|
+
}
|
660
|
+
_context2.prev = 11;
|
661
|
+
_context2.next = 14;
|
662
|
+
return tf.ready();
|
663
|
+
case 14:
|
664
|
+
_context2.next = 16;
|
665
|
+
return tf.setBackend('webgl');
|
666
|
+
case 16:
|
667
|
+
_context2.next = 18;
|
668
|
+
return faceapi.nets.ssdMobilenetv1.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
669
|
+
case 18:
|
670
|
+
_context2.next = 20;
|
671
|
+
return faceapi.nets.ageGenderNet.load("".concat(OSS, "/face-api-models/model"));
|
672
|
+
case 20:
|
673
|
+
_context2.next = 22;
|
674
|
+
return faceapi.nets.faceLandmark68Net.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
675
|
+
case 22:
|
676
|
+
_context2.next = 24;
|
677
|
+
return faceapi.nets.faceRecognitionNet.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
678
|
+
case 24:
|
679
|
+
_context2.next = 26;
|
680
|
+
return faceapi.nets.faceExpressionNet.load("".concat(OSS, "/model-zoo/face-api-models/model"));
|
681
|
+
case 26:
|
682
|
+
setOptions(new faceapi.SsdMobilenetv1Options({
|
683
|
+
minConfidence: MIN_SCORE,
|
684
|
+
maxResults: MAX_RESULTS
|
685
|
+
}));
|
686
|
+
detectAllFacesRef.current = faceapi.detectAllFaces;
|
687
|
+
setFaceApiInited(true);
|
688
|
+
_context2.next = 34;
|
689
|
+
break;
|
690
|
+
case 31:
|
691
|
+
_context2.prev = 31;
|
692
|
+
_context2.t0 = _context2["catch"](11);
|
693
|
+
console.error(_context2.t0);
|
694
|
+
case 34:
|
695
|
+
if (!(aiFeature.pose && poseDetector == null)) {
|
696
|
+
_context2.next = 47;
|
697
|
+
break;
|
698
|
+
}
|
699
|
+
_context2.prev = 35;
|
700
|
+
detectorConfig = {
|
701
|
+
modelType: posedetection.movenet.modelType.MULTIPOSE_LIGHTNING,
|
702
|
+
enableTracking: true,
|
703
|
+
trackerType: posedetection.TrackerType.BoundingBox,
|
704
|
+
scoreThreshold: 0.3,
|
705
|
+
modelUrl: "".concat(OSS, "/model-zoo/pose-detection-models/model.json")
|
706
|
+
};
|
707
|
+
_context2.next = 39;
|
708
|
+
return posedetection.createDetector(posedetection.SupportedModels.MoveNet, detectorConfig);
|
709
|
+
case 39:
|
710
|
+
_poseDetector = _context2.sent;
|
711
|
+
getAdjacentPairsRef.current = posedetection.util.getAdjacentPairs;
|
712
|
+
setPoseDetector(_poseDetector);
|
713
|
+
_context2.next = 47;
|
714
|
+
break;
|
715
|
+
case 44:
|
716
|
+
_context2.prev = 44;
|
717
|
+
_context2.t1 = _context2["catch"](35);
|
718
|
+
console.error(_context2.t1);
|
719
|
+
case 47:
|
720
|
+
case "end":
|
721
|
+
return _context2.stop();
|
722
|
+
}
|
723
|
+
}, _callee2, null, [[11, 31], [35, 44]]);
|
724
|
+
}))();
|
725
|
+
return function () {
|
726
|
+
loaded = false;
|
727
|
+
};
|
728
|
+
}, [aiFeature, faceApiInited, poseDetector]);
|
701
729
|
useEffect(function () {
|
702
730
|
var player = null;
|
703
731
|
if (isLive && videoRef.current != null) {
|
@@ -739,34 +767,6 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
739
767
|
dom === null || dom === void 0 || dom.removeEventListener('fullscreenchange', handleFullScreen);
|
740
768
|
};
|
741
769
|
}, []);
|
742
|
-
useEffect(function () {
|
743
|
-
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
744
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
745
|
-
while (1) switch (_context4.prev = _context4.next) {
|
746
|
-
case 0:
|
747
|
-
_context4.prev = 0;
|
748
|
-
_context4.next = 3;
|
749
|
-
return tf.ready();
|
750
|
-
case 3:
|
751
|
-
if ((aiFeature.emotion || aiFeature.character || aiFeature.anchor) && !faceApiInited) {
|
752
|
-
// 开始初始化人脸
|
753
|
-
initFaceApi();
|
754
|
-
}
|
755
|
-
if (aiFeature.pose && !poseDetector) {
|
756
|
-
initPoseDetecter();
|
757
|
-
}
|
758
|
-
_context4.next = 9;
|
759
|
-
break;
|
760
|
-
case 7:
|
761
|
-
_context4.prev = 7;
|
762
|
-
_context4.t0 = _context4["catch"](0);
|
763
|
-
case 9:
|
764
|
-
case "end":
|
765
|
-
return _context4.stop();
|
766
|
-
}
|
767
|
-
}, _callee4, null, [[0, 7]]);
|
768
|
-
}))();
|
769
|
-
}, [aiFeature, faceApiInited, initFaceApi, initPoseDetecter, poseDetector]);
|
770
770
|
useEffect(function () {
|
771
771
|
if (features == null) {
|
772
772
|
return;
|
@@ -780,29 +780,6 @@ export var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
780
780
|
}, [features, showSettingPanel]);
|
781
781
|
useEffect(function () {
|
782
782
|
var handler = null;
|
783
|
-
// let lastTime = Date.now();
|
784
|
-
/* const start = () => {
|
785
|
-
if (
|
786
|
-
!faceFeature.anchor &&
|
787
|
-
!faceFeature.emotion &&
|
788
|
-
!faceFeature.character
|
789
|
-
) {
|
790
|
-
return;
|
791
|
-
}
|
792
|
-
if (lastTime + 1000 <= Date.now()) {
|
793
|
-
lastTime = Date.now();
|
794
|
-
detect()
|
795
|
-
.catch((e) => {
|
796
|
-
console.log("error", e);
|
797
|
-
})
|
798
|
-
.finally(() => {
|
799
|
-
handler = requestAnimationFrame(start);
|
800
|
-
});
|
801
|
-
} else {
|
802
|
-
handler = requestAnimationFrame(start);
|
803
|
-
}
|
804
|
-
}; */
|
805
|
-
|
806
783
|
var lastTime = 0;
|
807
784
|
var fps = 30;
|
808
785
|
var start = function start(currentTime) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "yootd",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.88",
|
4
4
|
"description": "A react library developed with dumi",
|
5
5
|
"license": "MIT",
|
6
6
|
"module": "dist/index.js",
|
@@ -62,24 +62,17 @@
|
|
62
62
|
"@types/react-dom": "^18.0.0",
|
63
63
|
"@umijs/lint": "^4.0.0",
|
64
64
|
"@vladmandic/face-api": "^1.7.14",
|
65
|
-
"axios": "^1.7.7",
|
66
|
-
"dayjs": "^1.11.13",
|
67
65
|
"dumi": "^2.3.0",
|
68
66
|
"dumi-theme-antd": "^0.4.2",
|
69
67
|
"eslint": "^8.23.0",
|
70
68
|
"father": "^4.1.0",
|
71
69
|
"husky": "^8.0.1",
|
72
70
|
"lint-staged": "^13.0.3",
|
73
|
-
"lodash": "^4.17.21",
|
74
|
-
"nanoid": "^5.0.8",
|
75
71
|
"prettier": "^2.7.1",
|
76
72
|
"prettier-plugin-organize-imports": "^3.0.0",
|
77
73
|
"prettier-plugin-packagejson": "^2.2.18",
|
78
|
-
"react": "^18.0.0",
|
79
|
-
"react-dom": "^18.0.0",
|
80
74
|
"sass": "^1.80.0",
|
81
|
-
"stylelint": "^14.9.1"
|
82
|
-
"yootd-webrtc-sdk": "^1.0.1"
|
75
|
+
"stylelint": "^14.9.1"
|
83
76
|
},
|
84
77
|
"peerDependencies": {
|
85
78
|
"@dnd-kit/core": ">=6.1.0",
|
@@ -94,8 +87,8 @@
|
|
94
87
|
"dayjs": ">=1.11.13",
|
95
88
|
"lodash": ">=4.17.21",
|
96
89
|
"nanoid": ">=5.0.8",
|
97
|
-
"react": ">=
|
98
|
-
"react-dom": ">=
|
90
|
+
"react": ">=18.0.0",
|
91
|
+
"react-dom": ">=18.0.0",
|
99
92
|
"yootd-webrtc-sdk": "^1.0.1"
|
100
93
|
},
|
101
94
|
"publishConfig": {
|