“face-api-test-html-csv2” by Theresa
https://openprocessing.org/sketch/2083518
License CreativeCommons Attribution NonCommercial ShareAlike
https://creativecommons.org/licenses/by-nc-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
A fork of face-api-test-html-csv1 by Theresa
CC Attribution NonCommercial ShareAlike
face-api-test-html-csv2
xxxxxxxxxx
//https://www.youtube.com/watch?v=3yqANLRWGLo
let faceapi;
let detections = [];
let video;
let canvas;
/*
let table;
let tneutral = "";
let thappiness = "";
let tanger = "";
let tsad = "";
let tdisgusted = "";
let tsurprised = "";
let tfear = "";
let tmarks = "";
*/
function setup() {
frameRate(1);
/*
table = new p5.Table();
table.addColumn('time');
table.addColumn('neutral');
table.addColumn('happiness');
table.addColumn('anger');
table.addColumn('sad');
table.addColumn('disgusted');
table.addColumn('surprised');
table.addColumn('fear');
table.addColumn('landmarks');
*/
canvas = createCanvas(480, 360);
canvas.id("canvas");
video = createCapture(VIDEO);// Creat the video: ビデオオブジェクトを作る
video.id("video");
video.size(width, height);
const faceOptions = {
withLandmarks: true,
withExpressions: true,
withDescriptors: true,
minConfidence: 0.5
};
//Initialize the model: モデルの初期化
faceapi = ml5.faceApi(video, faceOptions, faceReady);
}
function faceReady() {
faceapi.detect(gotFaces);// Start detecting faces: 顔認識開始
}
// Got faces: 顔を検知
function gotFaces(error, result) {
if (error) {
console.log(error);
return;
}
detections = result; //Now all the data in this detections: 全ての検知されたデータがこのdetectionの中に
// console.log(detections);
clear();//Draw transparent background;: 透明の背景を描く
drawBoxs(detections);//Draw detection box: 顔の周りの四角の描画
drawLandmarks(detections);//// Draw all the face points: 全ての顔のポイントの描画
drawExpressions(detections, 20, 250, 14);//Draw face expression: 表情の描画
faceapi.detect(gotFaces);// Call the function again at here: 認識実行の関数をここでまた呼び出す
}
/*
function drawBoxs(detections){
if (detections.length > 0) {//If at least 1 face is detected: もし1つ以上の顔が検知されていたら
for (f=0; f < detections.length; f++){
let {_x, _y, _width, _height} = detections[f].alignedRect._box;
stroke(44, 169, 225);
strokeWeight(1);
noFill();
rect(_x, _y, _width, _height);
}
}
}
*/
function drawLandmarks(detections){
if (detections.length > 0) {//If at least 1 face is detected: もし1つ以上の顔が検知されていたら
for (f=0; f < detections.length; f++){
let points = detections[f].landmarks.positions;
for (let i = 0; i < points.length; i++) {
stroke(44, 169, 225);
strokeWeight(3);
point(points[i]._x, points[i]._y);
tmarks += (points[i]._x + ";" + points[i]._y +",")
}
}
}
}
function keyPressed() {
if (key == "c") {
//save(table, 'KI.csv');
}
}
See More Shortcuts
Please verify your email to comment
Verify Email