mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 02:51:20 -08:00
Built@main artplayer-plugin-danmuku-mask
This commit is contained in:
1 parent
7a1240b889
commit
e9d544f416
5 files changed
+33
-1
No files matched your search
@@ -0,0 +1,8 @@
|
||||
|
||||
/*!
|
||||
* artplayer-plugin-danmuku-mask.js v1.0.0
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer
|
||||
* (c) 2017-2024 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(e,r,t,n,a){var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof o[n]&&o[n],i=s.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(r,t){if(!i[r]){if(!e[r]){var a="function"==typeof o[n]&&o[n];if(!t&&a)return a(r,!0);if(s)return s(r,!0);if(l&&"string"==typeof r)return l(r);var c=Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}f.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},f.cache={};var p=i[r]=new u.Module(r);e[r][0].call(p.exports,f,p,p.exports,this)}return i[r].exports;function f(e){var r=f.resolve(e);return!1===r?{}:u(r)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=i,u.parent=s,u.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(u,"root",{get:function(){return o[n]}}),o[n]=u;for(var c=0;c<r.length;c++)u(r[c]);if(t){var p=u(t);"object"==typeof exports&&"undefined"!=typeof module?module.exports=p:"function"==typeof define&&define.amd&&define(function(){return p})}}({laCzO:[function(e,r,t){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(t),n.export(t,"default",function(){return l});var a=e("@swc/helpers/_/_async_to_generator"),o=e("@swc/helpers/_/_ts_generator"),s=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var i=e("@tensorflow-models/body-segmentation");function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(r){var t=r.template,n=t.$player,l=t.$video,u=t.$danmuku,c=null,p=null,f=null,d=null,h=!1,m={solutionPath:e.solutionPath||"https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation",modelSelection:e.modelSelection||1,smoothSegmentation:void 0===e.smoothSegmentation||e.smoothSegmentation,minDetectionConfidence:e.minDetectionConfidence||.5,minTrackingConfidence:e.minTrackingConfidence||.5,selfieMode:e.selfieMode||!1,drawContour:e.drawContour||!1,foregroundThreshold:e.foregroundThreshold||.5,opacity:e.opacity||1,maskBlurAmount:e.maskBlurAmount||3};function g(){return(g=(0,a._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,s.setBackend("webgl")];case 1:return e.sent(),console.log("Using WebGL backend"),[3,4];case 2:return e.sent(),console.warn("WebGL backend not available, falling back to CPU"),[4,s.setBackend("cpu")];case 3:return e.sent(),[3,4];case 4:return[2]}})})).apply(this,arguments)}function v(){return(v=(0,a._)(function(){var e,r;return(0,o._)(this,function(t){switch(t.label){case 0:return[4,function(){return g.apply(this,arguments)}()];case 1:t.sent(),e=i.SupportedModels.MediaPipeSelfieSegmentation,r={runtime:"mediapipe",modelType:"general",solutionPath:m.solutionPath,modelSelection:m.modelSelection,smoothSegmentation:m.smoothSegmentation,minDetectionConfidence:m.minDetectionConfidence,minTrackingConfidence:m.minTrackingConfidence,selfieMode:m.selfieMode},t.label=2;case 2:return t.trys.push([2,4,,5]),[4,i.createSegmenter(e,r)];case 3:return c=t.sent(),h=!0,console.log("Segmenter initialized successfully"),[3,5];case 4:return console.error("Error initializing segmenter:",t.sent()),h=!1,[3,5];case 5:return[2]}})})).apply(this,arguments)}function _(){return x.apply(this,arguments)}function x(){return(x=(0,a._)(function(){var e,r,t,n,a;return(0,o._)(this,function(o){switch(o.label){case 0:if(!h||l.paused||l.ended)return d=requestAnimationFrame(_),[2];o.label=1;case 1:return o.trys.push([1,5,,6]),p.width=l.videoWidth,p.height=l.videoHeight,[4,c.segmentPeople(l)];case 2:if(!(e=o.sent())||0===e.length)return d=requestAnimationFrame(_),[2];return r={r:255,g:255,b:255,a:255},t={r:0,g:0,b:0,a:255},[4,i.toBinaryMask(e,r,t,m.drawContour,m.foregroundThreshold)];case 3:return n=o.sent(),[4,i.drawMask(p,l,n,m.opacity,m.maskBlurAmount)];case 4:return o.sent(),a=f.getImageData(0,0,p.width,p.height),f.putImageData(function(e){for(var r=e.data,t=0;t<r.length;t+=4)r[t]>250&&r[t+1]>250&&r[t+2]>250&&(r[t+3]=0);return e}(a),0,0),u.style.maskImage="url(".concat(p.toDataURL(),")"),[3,6];case 5:return console.error("Error in segmentBody:",o.sent()),[3,6];case 6:return d=requestAnimationFrame(_),[2]}})})).apply(this,arguments)}function y(){return b.apply(this,arguments)}function b(){return(b=(0,a._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:if(h)return[3,2];return[4,function(){return v.apply(this,arguments)}()];case 1:e.sent(),e.label=2;case 2:return p||(f=(p=document.createElement("canvas")).getContext("2d"),Object.assign(p.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",opacity:"0"}),n.appendChild(p)),Object.assign(u.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),_(),[2]}})})).apply(this,arguments)}functLine truncated
|
||||
Reference in new issue
Block a user