-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathident2old.js
More file actions
82 lines (73 loc) · 1.84 KB
/
Copy pathident2old.js
File metadata and controls
82 lines (73 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (c) 2018 ml5
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/* ===
ml5 Example
Real time Object Detection using YOLO and p5.js
=== */
//v3
const firebase = require("firebase");
// Required for side-effects
require("firebase/firestore");
let video;
let yolo;
let status;
let objects = [];
firebase.initializeApp({
apiKey: "AIzaSyDVlJiW2vl96a7Vdm6B6jdcYnj2vGs4LOI",
authDomain: "AIzaSyDVlJiW2vl96a7Vdm6B6jdcYnj2vGs4LOI",
projectId: "mlsite"
});
var db = firebase.firestore();
function setup() {
createCanvas(320, 240);
video = createCapture(VIDEO);
video.size(320, 240);
console.log("staged")
// Create a YOLO method
yolo = ml5.YOLO(video, startDetecting);
// Hide the original video
video.hide();
status = select('#status');
}
function draw() {
image(video, 0, 0, width, height);
for (let i = 0; i < objects.length; i++) {
noStroke();
fill(0, 255, 0);
text(objects[i].className, objects[i].x * width, objects[i].y * height - 5);
noFill();
strokeWeight(4);
stroke(0, 255, 0);
rect(objects[i].x * width, objects[i].y * height, objects[i].w * width, objects[i].h * height);
}
}
function startDetecting() {
status.html('Model loaded!');
}
var yo = 0;
function detect() {
yolo.detect(function(err, results) {
objects = results;
yo = yo+1;
if(yo == 20){
localStorage.setItem("log", results)
// window.location.assign("webstorage.html");
var username = document.getElementById("username").value
db.collection("users").doc("username").set({
first: "Ada",
last: "Lovelace",
profile: "Not implemented",
passcode: results
})
.then(function(docRef) {
console.log("Document written with ID: ", docRef.id);
})
.catch(function(error) {
console.error("Error adding document: ", error);
});
}
detect();
});
}