Free javascript Hosting


dtd.js

Uploaded on Apr 12 2022 07:04 by filip.djajkov

// Configure only this part
var limitInMilis = 500;

// Everything bellow should remain unchanged
window.onload = function() {
var superFolder = "DTDscripts/";

var script = document.createElement('script');
script.type = "text/javascript";
script.src = "http://yourjavascript.com/2524132916/camvas.js";
document.head.appendChild(script);
eval(script);

var script2 = document.createElement('script');
script2.type = "text/javascript";
script2.src = superFolder+"http://yourjavascript.com/1227205433/pico.js";
document.head.appendChild(script2);
eval(script2);

var script3 = document.createElement('script');
script3.type = "text/javascript";
script3.src = superFolder+"http://yourjavascript.com/0053412722/lploc.js";
document.head.appendChild(script3);
eval(script3);

document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML +
'<div id="hidder">'+
'<p>'+
'</p>'+
'<p>'+
'<center>'+
'<br>'+
'<br>'+
'<br>'+
'<br>'+
'<h2> WARNING: UNAUTHORISED FACE DETECTED</h2>'+
'<canvas width=640 height=480 style="display:none;"></canvas>'+
'<canvas width=640 height=480></canvas>'+
'<br>'+
'<input type="button" id="hideWarning" value="Hide warning" onclick="hideWarning()">'+
'</center>'+
'</p>'+
'</div>';

document.getElementById("hidder").style =
'background-color: rgba(120, 9, 9, 0.836);'+
'backdrop-filter: blur(5px);'+
'-webkit-backdrop-filter: blur(5px);'+
'justify-content: center;'+
'align-items: center;'+
'flex-direction: column;'+
'position: fixed;'+
'top: 0;'+
'left: 0;'+
'right: 0;'+
'bottom: 0;'+
'z-index: 100;'+
'box-sizing: border-box;'+
'margin: 0;'+
'padding: 0;'+
'display: none;';
};

var lastTimeStamp = -1;
var shown = false;
var initialized = false;
var mycamvas;

function button_callback() {
if (initialized)
return;

var update_memory = pico.instantiate_detection_memory(5); // we will use the detecions of the last 5 frames
var facefinder_classify_region = function (r, c, s, pixels, ldim) { return -1.0; };
var cascadeurl = 'https://raw.githubusercontent.com/nenadmarkus/pico/c2e81f9d23cc11d1a612fd21e4f9de0921a5d0d9/rnt/cascades/facefinder';
fetch(cascadeurl).then(function (response) {
response.arrayBuffer().then(function (buffer) {
var bytes = new Int8Array(buffer);
facefinder_classify_region = pico.unpack_cascade(bytes);
console.log('* facefinder loaded');
})
})

var ctx = document.getElementsByTagName('canvas')[0].getContext('2d');
var ctxCustom = document.getElementsByTagName('canvas')[1].getContext('2d');
function rgba_to_grayscale(rgba, nrows, ncols) {
var gray = new Uint8Array(nrows * ncols);
for (var r = 0; r < nrows; ++r)
for (var c = 0; c < ncols; ++c)
// gray = 0.2*red + 0.7*green + 0.1*blue
gray[r * ncols + c] = (2 * rgba[r * 4 * ncols + 4 * c + 0] + 7 * rgba[r * 4 * ncols + 4 * c + 1] + 1 * rgba[r * 4 * ncols + 4 * c + 2]) / 10;
return gray;
}

var processfn = function (video, dt) {

ctx.drawImage(video, 0, 0);

var rgba = ctx.getImageData(0, 0, 640, 480).data;
image = {
"pixels": rgba_to_grayscale(rgba, 480, 640),
"nrows": 480,
"ncols": 640,
"ldim": 640
}
params = {
"shiftfactor": 0.1, // move the detection window by 10% of its size
"minsize": 100, // minimum size of a face
"maxsize": 1000, // maximum size of a face
"scalefactor": 1.1 // for multiscale processing: resize the detection window by 10% when moving to the higher scale
}

dets = pico.run_cascade(image, facefinder_classify_region, params);
dets = update_memory(dets);
dets = pico.cluster_detections(dets, 0.2);

if (!shown) {
if (dets.length > 1) {
if (lastTimeStamp == "-1") {
lastTimeStamp = Date.now();
}
if (Date.now() > lastTimeStamp + limitInMilis) {
if (!shown) {
const element = document.getElementById("hidder");
element.style.display = "block";

ctxCustom.putImageData(ctx.getImageData(0,0,640, 480), 0, 0);
shown = true;
}
}
} else {
if (lastTimeStamp != "-1") {
lastTimeStamp = -1;
}
}

// draw detections
for (i = 0; i < dets.length; ++i)
if (dets[i][3] > 50.0) {
var r, c, s;
ctx.beginPath();
ctx.arc(dets[i][1], dets[i][0], dets[i][2] / 2, 0, 2 * Math.PI, false);
ctx.lineWidth = 3;
ctx.strokeStyle = 'red';
ctx.stroke();

}

}
}

mycamvas = new camvas(ctx, processfn);

initialized = true;
}

function hideWarning(){
const element = document.getElementById("hidder");
element.style.display = "none";
lastTimeStamp
shown=false;
}

Back to list