Flipfly demo example
DEPLOYED
by morphcast
HTML
<head>
<title>MorphCast AI HTML5 SDK - Flipfly demo example</title>
</head>
<body>
<script src="https://ai-sdk.morphcast.com/v1.15/ai-sdk.js"></script>
<canvas id="canvas"></canvas>
<div>
<button id="toggle">Pause</button>
</div>
<div style="color:red">PRIVACY NOTE: by pressing START RECORDING video and audio coming from your webcam will be recorded and uploaded into an aws s3 bucket created for this demo.</div>
<div><b>Results</b></div><br />
Face compare: <div id="auth">-</div><br />
Event barrier: <div id="results">-</div>
</body>
JavaScript
CY.loader()
.licenseKey('f2fddf1df7c30cac7908d10246256efd264ce7aa32ec')
//.addModule(CY.modules().FACE_DETECTOR.name)
.addModule(CY.modules().ALARM_NO_FACE.name, {
timeWindowMs: 10000,
initialToleranceMs: 7000,
threshold: 0.75
})
.addModule(CY.modules().FACE_ATTENTION.name, {
riseSmoothness: 0.83, // fattore di smorzamento temporale della salita, da 0 (smorzamento minimo) ad 1 (smorzamento)
fallSmoothness: 0.83, // idem, per la discesa
//smoothness: 0.83, // unico parametro per configurare in contemporanea gli smorzamenti sopra
})
.addModule(CY.modules().ALARM_LOW_ATTENTION.name, {
timeWindowMs: 10000,
initialToleranceMs: 7000,
threshold: 0.75
})
.addModule(CY.modules().ALARM_MORE_FACES.name, {
timeWindowMs: 3000,
initialToleranceMs: 7000,
threshold: 0.33
})
.addModule(CY.modules().WEBCAM_RECORDER.name, {
bucketName: 'ext-adecco',
bucketRegion: 'eu-central-1',
identityPoolId: 'eu-central-1:43014775-ab54-47f5-ba4e-653a8666595d',
chunkLength: 4000
})
.maxInputFrameSize(640)
.addModule(CY.modules().FACE_COMPARE.name, {
region: 'eu-central-1',
identityPoolId: 'eu-central-1:43014775-ab54-47f5-ba4e-653a8666595d'
})
.load().then(({
start,
stop,
terminate,
getModule
}) => {
const toggle = document.querySelector('#toggle');
var playing = false;
toggle.textContent = 'START RECORDING';
toggle.onclick = function() {
if (playing) {
stop();
playing = false;
toggle.textContent = 'Resume';
} else {
start().then(()=>{
// command to face_compare module to start the auth flow
getModule(CY.modules().FACE_COMPARE.name).startAuthFlow();
});
playing = true;
toggle.textContent = 'Pause';
}
};
setTimeout(() => {
stop();
terminate();
console.log('terminated');
alert('TERMINATED');
}, 200000);
}).catch((err) => {
...