YOLO object identification more rapidly and consistently

一曲冷凌霜 提交于 2019-12-25 01:28:11

问题


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?

  1. Once identified the green rectangular is not sticking around consistently. I need to move slightly for object identification.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!