【发布时间】:2023-03-05 11:07:02
【问题描述】:
使用YOLO 和p5.js 我正在尝试使用我的网络摄像头识别对象。即使,我允许访问网络摄像头,以下是问题。有什么方法可以让我们更快速、更一致地改进对象识别?
- 一旦识别出绿色矩形并没有始终保持一致。我需要稍微移动一下才能识别物体。
- 我在本地保存了
test.mp4的视频,如何对保存的视频进行对象识别。
以下是我的代码:
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
});
}
【问题讨论】:
标签: javascript html p5.js yolo