YOLO对象识别更快,更一致 [英] YOLO object identification more rapidly and consistently
问题描述
使用YOLO
和p5.js
,我正在尝试使用网络摄像头识别对象.即使我已授予访问网络摄像头的权限,但仍然存在以下问题.有什么方法可以更快,更一致地改进对象识别?
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?
- 一旦确定了绿色矩形并没有持续粘住.我需要稍微移动一下以识别对象.
- 我有
test.mp4
个视频保存在本地,我们如何在保存的视频上进行对象识别.
- 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.
以下是我的代码:
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
});
}
推荐答案
-
一个可能的解决方案是不使用p5.js,而是使用getUserMedia()方法访问摄像机.这样,您可以将视频流镜像到图像元素并检测该图像元素.
A possible solution is not to use p5.js and instead use getUserMedia() method for camera access. In this way you can mirror the video stream to an image element and detect the image element.
对于保存的视频文件,您可以使用HTML Media Capture接受视频文件并将其放入HTML中:
For the saved video file you can use HTML Media Capture to accept a video file and put it into HTML: https://www.html5rocks.com/en/tutorials/getusermedia/intro/
完成此操作后,您可以创建一个在按下播放按钮时启用检测的功能.像这样的东西.
Once you have done that, you can make a function that enables the detection when you press the play button. Something like this.
var video = document.getElementById('video');
video.addEventListener('play', function() { // block of code }, 16);
这篇关于YOLO对象识别更快,更一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!