问题
Using YOLO
and p5.js
I am trying to identify the objects using my webcam. Even though, I gave permission to access the webcam, following are the problems. Is there any way we can improve the object identification more rapidly and consistently?
- Once identified the green rectangular is not sticking around consistently. I need to move slightly for object identification.
- I have
test.mp4
video saved locally, how can we do the object identification on saved video.
Following is my code:
let video; //Variable for video stream
let yolo; //Initializing model method with YOLO.
let status; //Status check to determine whether the model has been loaded
let objects = []; //List of objects returned from YOLO
function setup() {
createCanvas(800, 600);
video = createCapture(VIDEO); //Capturing live video from webcam
video.size(400, 500);
// Creating a YOLO method using ml5
yolo = ml5.YOLO(video, startDetecting);
// Hide the original video
video.hide();
status = select('#status');
}
function draw() {
image(video, 0, 0, width, height); // Displaying image on a canvas
for (let i = 0; i < objects.length; i++) //Iterating through all objects
{
noStroke();
fill(0, 255, 0); //Color of text
text(objects[i].label, objects[i].x * width, objects[i].y * height - 5); //Displaying the label
noFill();
strokeWeight(4);
stroke(0, 255, 0); // Define rectangular outline here
rect(objects[i].x * width, objects[i].y * height, objects[i].w * width, objects[i].h * height);
}
}
function startDetecting() {
status.html('Model loaded!'); //When the model is loaded
detect(); //Calling detect method
}
function detect() {
yolo.detect(function(err, results) {
objects = results; //Storing results in object
detect(); //Continuous detection
});
}
来源:https://stackoverflow.com/questions/57839115/yolo-object-identification-more-rapidly-and-consistently