webrtc-streamer 0.7.0 → 0.7.1
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/README.md +316 -240
- package/docs/api.md +11 -0
- package/html/admin.html +2 -2
- package/html/help.html +3 -3
- package/html/index.html +2 -2
- package/html/{janusvideoroom.json → janusconfig.js} +0 -0
- package/html/janustest.html +2 -2
- package/html/janusvideoroom.html +10 -21
- package/html/jitsiroom.html +1 -1
- package/html/jitsitest.html +2 -2
- package/html/libs/adapter.min.js +40 -6
- package/html/libs/blazeface +17 -0
- package/html/libs/lib-jitsi-meet.min.js +2 -25
- package/html/map.html +1 -1
- package/html/sendstream.html +17 -22
- package/html/tensorflow.js +45 -12
- package/html/webrtc-streamer-algo-element.js +1 -0
- package/html/webrtc-streamer-element.html +1 -0
- package/html/webrtc-streamer-element.js +23 -9
- package/html/webrtc-streamer-footer-element.js +1 -1
- package/html/{webrtcstreamer.json → webrtcconfig.js} +0 -0
- package/html/webrtcstreamer.html +1 -1
- package/html/webrtcstreamer.js +34 -40
- package/html/whipclient.html +76 -0
- package/html/{xmppvideoroom.json → xmppconfig.js} +0 -0
- package/html/xmppvideoroom.html +2 -2
- package/libv4l2cpp/README.md +6 -6
- package/libv4l2cpp/inc/V4l2Access.h +8 -9
- package/libv4l2cpp/inc/V4l2Capture.h +2 -2
- package/libv4l2cpp/inc/V4l2Device.h +20 -12
- package/libv4l2cpp/inc/V4l2MmapDevice.h +2 -2
- package/libv4l2cpp/inc/V4l2Output.h +4 -4
- package/libv4l2cpp/main.cpp +118 -0
- package/libv4l2cpp/src/V4l2Capture.cpp +4 -4
- package/libv4l2cpp/src/V4l2Device.cpp +7 -7
- package/libv4l2cpp/src/V4l2MmapDevice.cpp +2 -2
- package/libv4l2cpp/src/V4l2Output.cpp +6 -6
- package/package.json +1 -1
package/html/help.html
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
<a href="/janusvideoroom.html">Publish WebRTC streams to a Janus Video Room</a></br>
|
|
12
12
|
<a href="/xmppvideoroom.html">Publish WebRTC streams to XMPP Video Room (Jitsi)</a></br>
|
|
13
13
|
<h5>Config</h5>
|
|
14
|
-
<a href="/
|
|
15
|
-
<a href="/
|
|
16
|
-
<a href="/
|
|
14
|
+
<a href="/webrtcconfig.js">Configuration for WebRtcStreamer</a></br>
|
|
15
|
+
<a href="/janusconfig.js">Configuration for JanusVideoRoom</a></br>
|
|
16
|
+
<a href="/xmppconfig.js">Configuration for XMPPVideoRoom</a></br>
|
|
17
17
|
<h5>API</h5>
|
|
18
18
|
<a href="/api/help">API list</a></br>
|
|
19
19
|
<a href="/api/version">Version</a></br>
|
package/html/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<link rel="icon" type="image/png" href="webrtc.png" />
|
|
5
5
|
<link rel="stylesheet" type="text/css" href="styles.css">
|
|
6
6
|
<script src="libs/adapter.min.js" ></script>
|
|
7
|
-
<script src="
|
|
7
|
+
<script src="webrtcconfig.js" ></script>
|
|
8
8
|
<script src="webrtcstreamer.js" ></script>
|
|
9
9
|
<script>
|
|
10
10
|
// ------------------------------------------
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
.then( (response) => onGetDeviceList( response ))
|
|
237
237
|
|
|
238
238
|
fetch(webrtcConfig.url + "/api/version")
|
|
239
|
-
.then( (response) => response.
|
|
239
|
+
.then( (response) => response.text() )
|
|
240
240
|
.then( (response) => onVersion( response ))
|
|
241
241
|
|
|
242
242
|
}
|
|
File without changes
|
package/html/janustest.html
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<head>
|
|
3
3
|
<script src="libs/EventEmitter.min.js" ></script>
|
|
4
4
|
<script src="janusvideoroom.js" ></script>
|
|
5
|
-
<script src="
|
|
6
|
-
<script src="
|
|
5
|
+
<script src="janusconfig.js" ></script>
|
|
6
|
+
<script src="webrtcconfig.js" ></script>
|
|
7
7
|
<script>
|
|
8
8
|
function writeStatus(name, status) {
|
|
9
9
|
var textNode = document.createElement("h3");
|
package/html/janusvideoroom.html
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
<head>
|
|
3
3
|
<script src="libs/EventEmitter.min.js" ></script>
|
|
4
|
-
<script src="
|
|
4
|
+
<script src="janusconfig.js" ></script>
|
|
5
5
|
<script src="janusvideoroom.js" ></script>
|
|
6
|
-
<script src="
|
|
7
|
-
<link rel="stylesheet" type="text/css" href="styles.css">
|
|
6
|
+
<script src="webrtcconfig.js" ></script>
|
|
7
|
+
<link rel="stylesheet" type="text/css" href="styles.css">
|
|
8
|
+
<script type="module" src="webrtc-streamer-footer-element.js"></script>
|
|
8
9
|
</head>
|
|
9
10
|
<body>
|
|
10
11
|
Janus Url:<input id="janusUrl" type="text" size="50" />
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
<input type="button" onclick="connect()" value="ConnectRoom" />
|
|
13
14
|
<input type="button" onclick="openroom()" value="OpenRoom" />
|
|
14
15
|
<nav id="menu"></nav>
|
|
15
|
-
<footer
|
|
16
|
+
<webrtc-streamer-footer></webrtc-streamer-footer>
|
|
16
17
|
</body>
|
|
17
18
|
<script>
|
|
18
19
|
// set default value
|
|
@@ -33,8 +34,8 @@
|
|
|
33
34
|
function clientCallBack (name, status) {
|
|
34
35
|
console.log("clientCallBack name:"+ name + " status:"+ status);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const navId = "nav_" + name;
|
|
38
|
+
const navElt = document.querySelector(`[id="${navId}"]`);
|
|
38
39
|
if (navElt) {
|
|
39
40
|
if (status == "down") {
|
|
40
41
|
navElt.className = "";
|
|
@@ -123,29 +124,17 @@
|
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
// ------------------------------------------
|
|
127
|
-
// Fill version
|
|
128
|
-
// ------------------------------------------
|
|
129
|
-
function onVersion(version) {
|
|
130
|
-
document.getElementById("footer").innerHTML = "<p><a href='https://github.com/mpromonet/webrtc-streamer'>WebRTC-Streamer</a>"
|
|
131
|
-
+ " " + version.split(" ")[0] + "</p>";
|
|
132
|
-
}
|
|
133
127
|
|
|
134
128
|
// load
|
|
135
129
|
window.onload = function() {
|
|
136
130
|
fetch(webrtcConfig.url + "/api/getMediaList")
|
|
137
131
|
.then( (response) => (response.json()) )
|
|
138
132
|
.then( (response) => onGetDeviceList(response) )
|
|
139
|
-
.catch( (error) =>
|
|
140
|
-
|
|
141
|
-
fetch(webrtcConfig.url + "/api/version")
|
|
142
|
-
.then( (response) => (response.json()) )
|
|
143
|
-
.then( (response) => onVersion(response) )
|
|
144
|
-
.catch( (error) => this.onError("version " + error ))
|
|
145
|
-
|
|
133
|
+
.catch( (error) => console.log("getMediaList " + error ));
|
|
134
|
+
connect();
|
|
146
135
|
}
|
|
147
136
|
|
|
148
|
-
// unload
|
|
137
|
+
// unload
|
|
149
138
|
window.onbeforeunload = function() {
|
|
150
139
|
}
|
|
151
140
|
</script>
|
package/html/jitsiroom.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<link rel="stylesheet" type="text/css" href="styles.css">
|
|
7
7
|
<script src="libs/jquery-3.5.1.min.js"></script>
|
|
8
8
|
<script src="libs/lib-jitsi-meet.min.js"></script>
|
|
9
|
-
<script src="
|
|
9
|
+
<script src="xmppconfig.js" ></script>
|
|
10
10
|
<link rel="icon" type="image/ico" href="jitsi.ico" />
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/html/jitsitest.html
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<script src="libs/jquery-3.5.1.min.js"></script>
|
|
8
8
|
<script src="libs/EventEmitter.min.js" ></script>
|
|
9
9
|
<script src="xmppvideoroom.js" ></script>
|
|
10
|
-
<script src="
|
|
11
|
-
<script src="
|
|
10
|
+
<script src="xmppconfig.js" ></script>
|
|
11
|
+
<script src="webrtcconfig.js" ></script>
|
|
12
12
|
</head>
|
|
13
13
|
<body></body>
|
|
14
14
|
<script>
|
package/html/libs/adapter.min.js
CHANGED
|
@@ -111,6 +111,7 @@ function adapterFactory() {
|
|
|
111
111
|
chromeShim.fixNegotiationNeeded(window, browserDetails);
|
|
112
112
|
|
|
113
113
|
commonShim.shimRTCIceCandidate(window, browserDetails);
|
|
114
|
+
commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
|
|
114
115
|
commonShim.shimConnectionState(window, browserDetails);
|
|
115
116
|
commonShim.shimMaxMessageSize(window, browserDetails);
|
|
116
117
|
commonShim.shimSendThrowTypeError(window, browserDetails);
|
|
@@ -169,6 +170,7 @@ function adapterFactory() {
|
|
|
169
170
|
safariShim.shimAudioContext(window, browserDetails);
|
|
170
171
|
|
|
171
172
|
commonShim.shimRTCIceCandidate(window, browserDetails);
|
|
173
|
+
commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
|
|
172
174
|
commonShim.shimMaxMessageSize(window, browserDetails);
|
|
173
175
|
commonShim.shimSendThrowTypeError(window, browserDetails);
|
|
174
176
|
commonShim.removeExtmapAllowMixed(window, browserDetails);
|
|
@@ -1206,6 +1208,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
1206
1208
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
1207
1209
|
|
|
1208
1210
|
exports.shimRTCIceCandidate = shimRTCIceCandidate;
|
|
1211
|
+
exports.shimRTCIceCandidateRelayProtocol = shimRTCIceCandidateRelayProtocol;
|
|
1209
1212
|
exports.shimMaxMessageSize = shimMaxMessageSize;
|
|
1210
1213
|
exports.shimSendThrowTypeError = shimSendThrowTypeError;
|
|
1211
1214
|
exports.shimConnectionState = shimConnectionState;
|
|
@@ -1274,6 +1277,30 @@ function shimRTCIceCandidate(window) {
|
|
|
1274
1277
|
});
|
|
1275
1278
|
}
|
|
1276
1279
|
|
|
1280
|
+
function shimRTCIceCandidateRelayProtocol(window) {
|
|
1281
|
+
if (!window.RTCIceCandidate || window.RTCIceCandidate && 'relayProtocol' in window.RTCIceCandidate.prototype) {
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// Hook up the augmented candidate in onicecandidate and
|
|
1286
|
+
// addEventListener('icecandidate', ...)
|
|
1287
|
+
utils.wrapPeerConnectionEvent(window, 'icecandidate', function (e) {
|
|
1288
|
+
if (e.candidate) {
|
|
1289
|
+
var parsedCandidate = _sdp2.default.parseCandidate(e.candidate.candidate);
|
|
1290
|
+
if (parsedCandidate.type === 'relay') {
|
|
1291
|
+
// This is a libwebrtc-specific mapping of local type preference
|
|
1292
|
+
// to relayProtocol.
|
|
1293
|
+
e.candidate.relayProtocol = {
|
|
1294
|
+
0: 'tls',
|
|
1295
|
+
1: 'tcp',
|
|
1296
|
+
2: 'udp'
|
|
1297
|
+
}[parsedCandidate.priority >> 24];
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
return e;
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1277
1304
|
function shimMaxMessageSize(window, browserDetails) {
|
|
1278
1305
|
if (!window.RTCPeerConnection) {
|
|
1279
1306
|
return;
|
|
@@ -1676,6 +1703,8 @@ var utils = _interopRequireWildcard(_utils);
|
|
|
1676
1703
|
|
|
1677
1704
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
1678
1705
|
|
|
1706
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
1707
|
+
|
|
1679
1708
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1680
1709
|
|
|
1681
1710
|
function shimOnTrack(window) {
|
|
@@ -1845,11 +1874,16 @@ function shimAddTransceiver(window) {
|
|
|
1845
1874
|
if (origAddTransceiver) {
|
|
1846
1875
|
window.RTCPeerConnection.prototype.addTransceiver = function addTransceiver() {
|
|
1847
1876
|
this.setParametersPromises = [];
|
|
1848
|
-
|
|
1849
|
-
var
|
|
1877
|
+
// WebIDL input coercion and validation
|
|
1878
|
+
var sendEncodings = arguments[1] && arguments[1].sendEncodings;
|
|
1879
|
+
if (sendEncodings === undefined) {
|
|
1880
|
+
sendEncodings = [];
|
|
1881
|
+
}
|
|
1882
|
+
sendEncodings = [].concat(_toConsumableArray(sendEncodings));
|
|
1883
|
+
var shouldPerformCheck = sendEncodings.length > 0;
|
|
1850
1884
|
if (shouldPerformCheck) {
|
|
1851
1885
|
// If sendEncodings params are provided, validate grammar
|
|
1852
|
-
|
|
1886
|
+
sendEncodings.forEach(function (encodingParam) {
|
|
1853
1887
|
if ('rid' in encodingParam) {
|
|
1854
1888
|
var ridRegex = /^[a-z0-9]{0,16}$/i;
|
|
1855
1889
|
if (!ridRegex.test(encodingParam.rid)) {
|
|
@@ -1883,8 +1917,8 @@ function shimAddTransceiver(window) {
|
|
|
1883
1917
|
if (!('encodings' in params) ||
|
|
1884
1918
|
// Avoid being fooled by patched getParameters() below.
|
|
1885
1919
|
params.encodings.length === 1 && Object.keys(params.encodings[0]).length === 0) {
|
|
1886
|
-
params.encodings =
|
|
1887
|
-
sender.sendEncodings =
|
|
1920
|
+
params.encodings = sendEncodings;
|
|
1921
|
+
sender.sendEncodings = sendEncodings;
|
|
1888
1922
|
this.setParametersPromises.push(sender.setParameters(params).then(function () {
|
|
1889
1923
|
delete sender.sendEncodings;
|
|
1890
1924
|
}).catch(function () {
|
|
@@ -2623,7 +2657,7 @@ function detectBrowser(window) {
|
|
|
2623
2657
|
// Firefox.
|
|
2624
2658
|
result.browser = 'firefox';
|
|
2625
2659
|
result.version = extractVersion(navigator.userAgent, /Firefox\/(\d+)\./, 1);
|
|
2626
|
-
} else if (navigator.webkitGetUserMedia || window.isSecureContext === false && window.webkitRTCPeerConnection
|
|
2660
|
+
} else if (navigator.webkitGetUserMedia || window.isSecureContext === false && window.webkitRTCPeerConnection) {
|
|
2627
2661
|
// Chrome, Chromium, Webview, Opera.
|
|
2628
2662
|
// Version matches Chrome/WebRTC version.
|
|
2629
2663
|
// Chrome 74 removed webkitGetUserMedia on http as well so we need the
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
* =============================================================================
|
|
16
|
+
*/
|
|
17
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core"),require("@tensorflow/tfjs-converter")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core","@tensorflow/tfjs-converter"],e):e(t.blazeface={},t.tf,t.tf)}(this,function(t,e,n){"use strict";function r(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}c((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var i=function(t){return{startEndTensor:t,startPoint:e.slice(t,[0,0],[-1,2]),endPoint:e.slice(t,[0,2],[-1,2])}},s=function(t,n){var r=e.mul(t.startPoint,n),o=e.mul(t.endPoint,n),s=e.concat2d([r,o],1);return i(s)},a={strides:[8,16],anchors:[2,6]};function c(t,n){var r,o,i;if(t.topLeft instanceof e.Tensor&&t.bottomRight instanceof e.Tensor){var s=e.tidy(function(){return[e.concat([e.slice(e.sub(n-1,t.topLeft),0,1),e.slice(t.topLeft,1,1)]),e.concat([e.sub(n-1,e.slice(t.bottomRight,0,1)),e.slice(t.bottomRight,1,1)])]});r=s[0],o=s[1],null!=t.landmarks&&(i=e.tidy(function(){var r=e.sub(e.tensor1d([n-1,0]),t.landmarks),o=e.tensor1d([1,-1]);return e.mul(r,o)}))}else{var a=t.topLeft,c=a[0],u=a[1],l=t.bottomRight,d=l[0],f=l[1];r=[n-1-c,u],o=[n-1-d,f],null!=t.landmarks&&(i=t.landmarks.map(function(t){return[n-1-t[0],t[1]]}))}var h={topLeft:r,bottomRight:o};return null!=i&&(h.landmarks=i),null!=t.probability&&(h.probability=t.probability instanceof e.Tensor?t.probability.clone():t.probability),h}function u(t,n){return e.tidy(function(){var r;return r=t.hasOwnProperty("box")?t.box:t,e.squeeze(s(r,n).startEndTensor)})}var l=function(){function t(t,n,r,o,i,s){this.blazeFaceModel=t,this.width=n,this.height=r,this.maxFaces=o,this.anchorsData=function(t,e,n){for(var r=[],o=0;o<n.strides.length;o++)for(var i=n.strides[o],s=Math.floor((e+i-1)/i),a=Math.floor((t+i-1)/i),c=n.anchors[o],u=0;u<s;u++)for(var l=i*(u+.5),d=0;d<a;d++)for(var f=i*(d+.5),h=0;h<c;h++)r.push([f,l]);return r}(n,r,a),this.anchors=e.tensor2d(this.anchorsData),this.inputSizeData=[n,r],this.inputSize=e.tensor1d([n,r]),this.iouThreshold=i,this.scoreThreshold=s}return t.prototype.getBoundingBoxes=function(t,n,s){return void 0===s&&(s=!0),r(this,void 0,void 0,function(){var a,c,u,l,d,f,h,p,b,v,m,y,w,g,x=this;return o(this,function(T){switch(T.label){case 0:return a=e.tidy(function(){var n,r,o,i,s,a,c,u,l,d,f,h,p,b=e.image.resizeBilinear(t,[x.width,x.height]),v=e.mul(e.sub(e.div(b,255),.5),2),m=x.blazeFaceModel.predict(v),y=e.squeeze(m),w=(n=y,r=x.anchors,o=x.inputSize,i=e.slice(n,[0,1],[-1,2]),s=e.add(i,r),a=e.slice(n,[0,3],[-1,2]),c=e.div(a,o),u=e.div(s,o),l=e.div(c,2),d=e.sub(u,l),f=e.add(u,l),h=e.mul(d,o),p=e.mul(f,o),e.concat2d([h,p],1)),g=e.slice(y,[0,0],[-1,1]);return[y,w,e.squeeze(e.sigmoid(g))]}),c=a[0],u=a[1],l=a[2],d=console.warn,console.warn=function(){},f=e.image.nonMaxSuppression(u,l,this.maxFaces,this.iouThreshold,this.scoreThreshold),console.warn=d,[4,f.array()];case 1:return h=T.sent(),f.dispose(),p=h.map(function(t){return e.slice(u,[t,0],[1,-1])}),n?[3,3]:[4,Promise.all(p.map(function(t){return r(x,void 0,void 0,function(){var e;return o(this,function(n){switch(n.label){case 0:return[4,t.array()];case 1:return e=n.sent(),t.dispose(),[2,e]}})})}))];case 2:p=T.sent(),T.label=3;case 3:for(b=t.shape[1],v=t.shape[2],m=n?e.div([v,b],this.inputSize):[v/this.inputSizeData[0],b/this.inputSizeData[1]],y=[],w=function(t){var r=p[t],o=e.tidy(function(){var o=r instanceof e.Tensor?i(r):i(e.tensor2d(r));if(!s)return o;var a,u=h[t];return a=n?e.slice(x.anchors,[u,0],[1,2]):x.anchorsData[u],{box:o,landmarks:e.reshape(e.squeeze(e.slice(c,[u,5],[1,-1])),[6,-1]),probability:e.slice(l,[u],[1]),anchor:a}});y.push(o)},g=0;g<p.length;g++)w(g);return u.dispose(),l.dispose(),c.dispose(),[2,{boxes:y,scaleFactor:m}]}})})},t.prototype.estimateFaces=function(t,n,i,s){return void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===s&&(s=!0),r(this,void 0,void 0,function(){var a,l,d,f,h,p,b=this;return o(this,function(v){switch(v.label){case 0:return a=function(t){return t instanceof e.Tensor?[t.shape[0],t.shape[1]]:[t.height,t.width]}(t),l=a[1],d=e.tidy(function(){return t instanceof e.Tensor||(t=e.browser.fromPixels(t)),e.expandDims(e.cast(t,"float32"),0)}),[4,this.getBoundingBoxes(d,n,s)];case 1:return f=v.sent(),h=f.boxes,p=f.scaleFactor,d.dispose(),n?[2,h.map(function(t){var n=u(t,p),r={topLeft:e.slice(n,[0],[2]),bottomRight:e.slice(n,[2],[2])};if(s){var o=t,a=o.landmarks,d=o.probability,f=o.anchor,h=e.mul(e.add(a,f),p);r.landmarks=h,r.probability=d}return i&&(r=c(r,l)),r})]:[2,Promise.all(h.map(function(t){return r(b,void 0,void 0,function(){var e,n,a,d,f,h,b,v,m,y,w,g=this;return o(this,function(x){switch(x.label){case 0:return e=u(t,p),s?[3,2]:[4,e.array()];case 1:return f=x.sent(),n={topLeft:f.slice(0,2),bottomRight:f.slice(2)},[3,4];case 2:return[4,Promise.all([t.landmarks,e,t.probability].map(function(t){return r(g,void 0,void 0,function(){return o(this,function(e){return[2,t.array()]})})}))];case 3:a=x.sent(),d=a[0],f=a[1],h=a[2],b=t.anchor,m=(v=p)[0],y=v[1],w=d.map(function(t){return[(t[0]+b[0])*m,(t[1]+b[1])*y]}),n={topLeft:f.slice(0,2),bottomRight:f.slice(2),landmarks:w,probability:h},(T=t.box).startEndTensor.dispose(),T.startPoint.dispose(),T.endPoint.dispose(),t.landmarks.dispose(),t.probability.dispose(),x.label=4;case 4:return e.dispose(),i&&(n=c(n,l)),[2,n]}var T})})}))]}})})},t}(),d="https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1";t.load=function(t){var e=void 0===t?{}:t,i=e.maxFaces,s=void 0===i?10:i,a=e.inputWidth,c=void 0===a?128:a,u=e.inputHeight,f=void 0===u?128:u,h=e.iouThreshold,p=void 0===h?.3:h,b=e.scoreThreshold,v=void 0===b?.75:b,m=e.modelUrl;return r(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return null==m?[3,2]:[4,n.loadGraphModel(m)];case 1:return t=e.sent(),[3,4];case 2:return[4,n.loadGraphModel(d,{fromTFHub:!0})];case 3:t=e.sent(),e.label=4;case 4:return[2,new l(t,c,f,s,p,v)]}})})},t.BlazeFaceModel=l,Object.defineProperty(t,"__esModule",{value:!0})});
|