CiMor - Group 23
Team Number | ?Group 23 |
---|---|
Students | Lise van de Ven Leonie Sonneveld Kamran Hongxin |
Coach | Gijs Huisman |
Brief | Erasmus MC |
Keywords | Erasmus MC, medical picture taking, home environment, comfort |
One Liner | CiMor shifts the medical picture taking process to a more private and comfortable environment: the patient?s home. |
Link to video | https://youtu.be/UTrBYSpKRbc |
Link to video 2 | |
Property | |
? ITD Projects |
The code running on PC:
var serial; // variable to hold an instance of the serialport library
var portName = '/dev/tty.usbmodem11101'; // fill in your serial port name here
let inData =0; // variable to hold the input data from Arduino
let rainDrop;
let x=0;
let y=0;
let facemesh;
let video;
let predictions = [];
let framewidth = 1280;
let frameheight = 960;
let nx2,ny2,lx2,ly2,rx2,ry2;
let bol = [];
let idx=10;
let ex=400;
let tempi=0;
let cord = [
[640,560,575,435,755,440],
[650, 390, 580, 320, 745, 310],
[905, 545, 790, 450, 940, 420],
[670, 680, 585, 550, 760, 550],
[640,560,575,435,755,440],
[600, 550, 575, 425, 725, 450],
];
function preload(){
song = loadSound('cs.mp3');
song10 = loadSound('10.aac');
song12 = loadSound('12.aac');
song13 = loadSound('13.aac');
song14 = loadSound('14.aac');
song9 = loadSound('8.aac');
rainDrop = loadImage('assets/rainDrops.png');
Logo = loadImage('frame3.png');
middle = loadImage('middle.png');
middlee = loadImage('middle2.png');
sese = loadImage('top.png');
right = loadImage('right.png');
down = loadImage('down.png');
left = loadImage('left.png');
slide9= loadImage('ITDcode9.gif');
slide10=loadImage('ITDcode10.png');
slide11=loadImage('ITDcode11.png');
slide1=loadImage('ITDcode8.png');
slide0=loadImage('ITDcode7.png');
check=loadImage('gloom.png');
}
function setup(){
//set up communication port
serial = new p5.SerialPort(); // make a new instance of the serialport library
serial.list();
serial.open('/dev/tty.usbmodem1201');
serial.on('connected', serverConnected); // callback for connecting to the server
serial.on('open', portOpen); // callback for the port opening
serial.on('data', function () {
inData = Number(serial.readLine());
console.log("!!!!" + inData);
}); // callback for when new data arrives
serial.on('error', serialError); // callback for errors
serial.on('close', portClose); // callback for the port closing
serial.list(); // list the serial ports
serial.open(portName); // open a serial port
bol[0] = middle;
bol[1] = sese;
bol[2] = right;
bol[3] = down;
bol[4] = middlee;
bol[5] = left;
bol[6] = slide9;
bol[7] = slide10;
bol[8] = slide11;
bol[9] = slide1;
bol[10] = slide0;
createCanvas(framewidth+ex, (frameheight));
video = createCapture(VIDEO);
video.size(width, height);
video.hide();
facemesh = ml5.facemesh(video, modelReady);
facemesh.on("predict", results => {
predictions = results;
});
colorMode(HSB, 360, 100, 100, 100);
imageMode(CENTER);
song9.play();
setTimeout(create,20000);
}
function modelReady() {
//console.log("Model ready!");
}
triggered = false;
function draw(){
console.log("idx"+idx);
if (inData > 2){
let amount = map(inData, 0, 1000, 1, 12);
//console.log("indata: " + inData);
if(amount < 0) amount = 0;
translate(width,0);
scale(-1, 1);
drawingContext.filter = 'blur('+str(amount)+'px)';
image(video, width/(2)+200, height/(2), 1280, frameheight);
let amount2 = map(mouseX, 0, width, 12, 1);
if(amount2 < 0) amount2 = 0;
translate(width,0);
scale(-1, 1);
drawingContext.filter = 'blur('+str(amount2)+'px)';
image(rainDrop, (width/2)-200, height/2, framewidth, frameheight);
//console.log('Frame rate: '+frameRate());
drawingContext.filter = 'blur('+str(0)+'px)';
image(bol[idx], width/2-200, height/2, framewidth,frameheight);
image(Logo, width/2-80, height/2, 1580,frameheight);
}
if (idx == 6 && !triggered){
triggered = true;
for (let i = 1; i < 7; i++){
if (i < 6){
setTimeout(() => {
image(check,1410,168+(i-1)*159,190,163);
}, 1000*i);
} else {
setTimeout(() => {
idx = 7;
}, 1000*i);
}
}
}
if (idx < 6){
for (let i = 0; i < predictions.length; i += 1) {
const keypoints = predictions[i].scaledMesh;
const [nx, ny] = keypoints[1];
const [lx, ly] = keypoints[145];
const [rx, ry] = keypoints[374];
fill(50, 150, 100, 50);
strokeWeight(1);
nx2 = 1280-(nx*2);
ny2=ny*2;
lx2=1280-(lx*2);
ly2=(ly-5)*2;
rx2=1280-(rx*2);
ry2=(ry-5)*2;
distl=dist(cord[idx][4],cord[idx][5],lx2,ly2);
distr=dist(cord[idx][2],cord[idx][3],rx2,ry2);
distn=dist(cord[idx][0],cord[idx][1],nx2,ny2);
// console.log("nose",distn)
// console.log("lefteye",distl)
// console.log("righteye",distr)
r=40;
if (distn>r){
fill(9, 100, 100, 100);
circle((1280-(nx*2)), ny*2, 8);
circle(cord[idx][0],cord[idx][1],30);
} else {
fill(166, 100, 100, 100);
circle((1280-(nx*2)), ny*2, 8);
circle(cord[idx][0],cord[idx][1],30);
}
if (distl>r){
fill(9, 100, 100, 100);
circle((1280-(lx*2)), (ly-5)*2, 16);
circle(cord[idx][4],cord[idx][5],30);
} else {
fill(116, 100, 100, 100);
circle((1280-(lx*2)), (ly-5)*2, 16);
circle(cord[idx][4],cord[idx][5],30);
}
if (distr>r){
fill(9, 100, 100, 100);
circle((1280-(rx*2)), (ry-5)*2, 16);
circle(cord[idx][2],cord[idx][3],30);
} else {
fill(116, 100, 100, 100);
circle((1280-(rx*2)), (ry-5)*2, 16);
circle(cord[idx][2],cord[idx][3],30);
}
// distl=dist(cord[idx][4],cord[idx][5],lx2,ly2);
// distr=dist(cord[idx][2],cord[idx][3],rx2,ry2);
// distn=dist(cord[idx][0],cord[idx][1],nx2,ny2);
// push();
// translate((cord[idx][4] + lx2) / 2, (cord[idx][5] + ly2) / 2);
// rotate(atan2(ly2 - cord[idx][5], lx2 - cord[idx][4]));
// text(nfc(distl, 1), 0, -5);
// pop();
//console.log(distl, distr, distn);
if (distl<r && distr<r && distn<r)
{
//console.log(idx)
if (idx==10){
console.log('a')
idx=0;
}
if (idx==0){
idx=9;
song10.play();
console.log('bah bah');
}
if (idx==5){
idx = 6;
song12.play()
} else if (idx<=6 && idx>=1 ) {
song.play();
idx = (idx+1)
//console.log(idx);
}
if (idx>=1 && idx<=6){
let keshande=((idx-2)*159)+150;
image(video, 1400, keshande, 196, 125);
}
}
}
if(idx <6) {
line(cord[idx][4],cord[idx][5],lx2,ly2);
line(cord[idx][2],cord[idx][3],rx2,ry2);
line(cord[idx][0],cord[idx][1],nx2,ny2);
}
}}
function keyPressed() {
if (keyCode === LEFT_ARROW) {
idx=0;
}
if (keyCode === RIGHT_ARROW) {
idx=1;
}
}
function mouseClicked() {
//serial.write(idx%2 + "\n")
serial.write(1 + "\n")
if (idx == 6) return;
song9.stop();
song10.stop();
song12.stop();
song13.stop();
song14.stop();
if (idx==10){
idx=0;
console.log('idx=0');
}
else if (idx==9){
idx=1;
console.log('idx=1');
}
else if (idx==8){
idx=10;
} else {
idx = (idx+1)
if(idx==7){
song13.play();
}
if(idx==8){
song14.play();
}
//console.log(idx);
}
}
// function drawKeypoints() {
// for (let i = 0; i < predictions.length; i += 1) {
// const keypoints = predictions[i].scaledMesh;
// const [x0, y0] = keypoints[1];
// const [x1, y1] = keypoints[145];
// const [x2, y2] = keypoints[374];
// fill(200, 0, 0);
// circle(x0, y0, 15);
// circle(x1, y1, 15);
// circle(x2, y2, 15);
// }
// }
function mySelectEvent() {
let item = portSelector.value();
// if there's a port open, close it:
if (serial.serialport != null) {
serial.close();
}
// open the new port:
serial.open(item);
}
function serverConnected() {
print('connected to server.');
}
function portOpen() {
print('the serial port opened.')
}
function serialEvent() {
}
function serialError(err) {
print('Something went wrong with the serial port. ' + err);
}
function portClose() {
print('The serial port closed.');
}
function create(){
serial.write(0 + "\n")
}