xxxxxxxxxx
254
let capture;
let tracker;
var w;
var h;
//face = 0;
var changeColor;
let a = 0;
let button1;
let button2;
let button3;
let button4;
var h1;
let sceneNum = 0;
var policy;
var canvas;
function setup() {
canvas = createCanvas(600, 400);
capture = createCapture(VIDEO); //video feed
capture.size(width, height);
capture.hide();
tracker = new clm.tracker(); //clm tracker
tracker.init();
tracker.start(capture.elt);
pixelDensity(5)
background('#c35775');
revoke = createButton('Revoke Access');
revoke.position(width/2.5, height)
revoke.mousePressed(revoke);
revoke.style("white","#BF3030");
}
function myCheckedEvent() {
if (this.checked()) {
console.log('Checking!');
} else {
console.log('Unchecking!');
}
}
function mousePressed() {
//nameP.mouseOver(overpara);
h1.style('font-size', '22px');
h1.style('color', '#579834');
h1.html('Do you accept & agree to open camera?');
createP('You can revoke this access at any time.');
//openCam();
//drawScene1 = createCapture(VIDEO, ready);
}
function draw() {
capture.loadPixels();
// switching scenes
switch (sceneNum) {
case 0:
console.log('scene 0');
drawScene0();
checkbox();
button1();
button2();
break;
case 1:
console.log('scene 1');
drawScene1();
revoke();
checkbox.hide();
button1.hide();
button2.hide();
break;
case 2:
// console.log('scene 2');
drawScene2();
revoke();
// break;
// case 3:
// console.log('scene 3');
// drawScene3();
// break;
}
function drawScene0() {
checkbox = createCheckbox('I Agree', false);
checkbox.changed(myCheckedEvent);
checkbox.style('font-size', '22px');
checkbox.style('color', '#579834');
h1 = createElement('h1', 'Welcome! Please read camera privacy policy below');
h1.style('font-size', '22px');
h1.style('color', '#579834');
P = createElement('createP');
createP('You have the full right to your data, No commodification, I do not want your data, I will not sell you data. I will not be tracking any data while you use the camera, I will not be collecting any data while you use the camera, This camera does not need any login information, You can input your data at your own level of comfort for updates & product information from me, I will only count the number of times the camera has been used , the CLM tracker is not the most accurate right now, camera only tracks the face.');
//style('color', '#579834');
//create accept button
//let col = (153, 255, 153, 10);
button1 = createButton("Accept");
button1.position(150, 200);
button1.mousePressed(openCam);
//button.style('background-color', col);
//create reject button
button2 = createButton("Reject");
button2.position(300, 200);
button2.mousePressed();
// button.style('background-color', col);
nameP.html(input.value());
h1.position(x, y);
x = x + random(-5, 5);
if (mousePressed) {
console.log("end of scene 0");
sceneNum = 1;
}
}
function overpara() {
nameP.html('Read Policy');
}
function revoke() {
background(0)
sceneNum = 2;
push();
textSize(15)
fill(255)
textAlign(CENTER)
text('Your camera has been switched off - Refresh to access camera again', 640 / 2, 480 / 2)
pop();
console.log('revoke');
}
function openCam() {
//image(capture, 0, 0, width, height);
capture = createCapture(VIDEO, ready);
capture.elt.setAttribute('playsinline', ''); // this line makes your program works on iPhone 11
capture.size(width, height);
// capture.hide();
// load clmtrackr functions:
tracker = new clm.tracker(); // create a new clmtrackr object
tracker.init(); // initialize the object
tracker.start(capture.elt) // start tracking the video element capture.elt
// 2. MAKE TEXT FLASH
textSize(30);
fill(128 + sin(frameCount * 0.1) * 128, a);
noStroke();
text('Reposition Captain', 30, 50);
if (positions.length > 0) {
if (positions[16][1] < 100 || positions[20][1] < 100 || positions[7][1] > 400 || positions[1][0] < 100 || positions[13][0] > 600) {
/// Modulates the tint of the image based on position
tint(128 + sin(frameCount * 0.1) * 128, 50, 50);
tint(3, 252, 136);
a = 220;
} else {
tint(255, 255, 255); // resets the tint to white when we are in position
a = 0;
}
}
}
// create reject boolean variable
var go = false;
function ready() {
go = true;
}
function drawScene1() {
if (go) {
capture.image(createCapture());
}
image(capture, 0, 0, width, height);
let positions = tracker.getCurrentPosition(); // updates the tracker with current positions
// console.log(positions);
noFill();
stroke(255);
if (mousePressed) {
console.log("end of scene 1");
sceneNum = 2;
}
}
//function drawScene2() {
function beginCapture() {
// this opens camera after accepting terms
let capture = true;
//function agreetoPolicy() {
//background(255, 0, 0);
// name sign box
let inp = createInput('');
inp.input(myInputEvent);
// sign name
function myInputEvent() {
console.log('Full Name Signature: ', this.value());
}
createP.html(input.value());
h1.position(x, y);
x = x + random(-5, 5);
}
// uncomment to reveal connecting lines
// beginShape();
// for (let i = 0; i < positions.length; i++) {
// vertex(positions[i][0], positions[i][1]);
// }
// endShape();
// console.log(positions);
// // this writes the position points in numbers
// for (let i = 0; i < positions.length; i++) {
// ellipse(positions[i][0], positions[i][1], 4, 4);
// //text(i, positions[i][0], positions[i][1]);
// }
// if button1.mousePressed() {
// drawScene1;
// let tracker.init(); // initialize the object
// tracker.start(capture.elt) // start tracking the video element capture.elt
// } else {
// console.log('negative');
// }
function changescene(){
sceneNum++
}
}