Raspberry pi opencv+ YOLO:在检测“人”时返回对还是错。
我想将Raspberry Pi与OpenCV + Yolo一起进行智能监测系统。
问题是:当检测“人”时,它不是在屏幕上显示盒子,而是返回ture还是错误?
我了解到,在检测某些内容时,它可以成功在屏幕上显示一个盒子。我使用一本中文书中的代码,恐怕它可能会使规则粘贴在此处粘贴整个代码,因此我BREIF描述了它使用的代码。
原始代码使用以下3个Yolo文件:
yolo4-tiny.cfg
coco.names
yolo4-tine.weight
该
import cv2, numpy and time
代码将图像大小调整到较小的帧大小,然后将图像放入Yolo中,
def XXX(image, model):
classes, confs, boxes = model.detect(image, 0.6, 0.3)
return classes, confs, boxes
下一步是在图像中显示框。
def YYY(image, classes, confs, boxes, names, colors):
new_image = image.copy()
for (classid, conf, box) in zip(classes, confs, boxes):
x, y, w , h = box
label = '{}: {:.2f}'.format(names[int(classid)], float(conf))
color = colors[int(classid)]
cv2.rectangle(new_image, (x, y), (x + w, y + h), color, 2)
cv2.putText(new_image, label, (x, y - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, color, 2
)
return new_image
我的问题是在检测“人”时如何返回真实。谢谢您的呼吸。
I would like to use Raspberry Pi with OpenCV + yolo to do smart monitering system.
The question is: Instead of showing a box on the screen, could it return Ture or False when detecting "person"?
I learned that it could successful show on screen a box on screen when detecting something. I use a code from a chinese book, I am afraid that it might viloate the rule to paste the whole code here, so I breif describe the code it use.
the original code use the following 3 yolo file:
yolo4-tiny.cfg
coco.names
yolo4-tine.weight
And
import cv2, numpy and time
the code resize the image to a smaller frame and then put the image into yolo
def XXX(image, model):
classes, confs, boxes = model.detect(image, 0.6, 0.3)
return classes, confs, boxes
the next step is show the box in the image.
def YYY(image, classes, confs, boxes, names, colors):
new_image = image.copy()
for (classid, conf, box) in zip(classes, confs, boxes):
x, y, w , h = box
label = '{}: {:.2f}'.format(names[int(classid)], float(conf))
color = colors[int(classid)]
cv2.rectangle(new_image, (x, y), (x + w, y + h), color, 2)
cv2.putText(new_image, label, (x, y - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, color, 2
)
return new_image
My question is how to return true when detecting "person". Thank you for respone this question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的情况下,(我尚未使用Yolo,但是我使用了OpenCV面部检测和MTCNN),您可以使用
detchect()
函数的返回变量之一。可以肯定地假设,如果模型在检测功能中创建一个边界框,则存在一个人。In your case, (I haven't used Yolo, but I've used OpenCV face detection and MTCNN), you can use one of the returned variables from the
detect()
function. It should be safe to assume that if the model creates a bounding box in the detection function, then a person exists.