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.