You are on page 1of 3

MaixPy run face detection (tiny yolo v2)

MaixPy run face detect (tiny yolo v2)


Today we use MaixPy to run face detection, here is the frimware and model.
maixpy_yolo2.zip (1015.3 KB)

## API
kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
input args:
* kpu_net: kpu net obj
* threshold: prop gate
* nms_value: box_iou gate
* anchor_num: anchor number
* anchor: anchor args

code = kpu.run_yolo2(task, img)


input args:
* kpu_net: kpu_net obj
* image_t: image from sensor

return value:
* {"x":140, "y":46, "w":82, "h":111, "value":3.169619, "classid":0,
"index":0, "objnum":3}: all face windows coordinate and size
API details refer to: https://maixpy.sipeed.com/zh/libs/Maix/kpu.html

Test Code
import sensor,image,lcd
import KPU as kpu
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_hmirror(0)
sensor.run(1)
task = kpu.load(0x300000)
anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658, 5.155437,
6.92275, 6.718375, 9.01025)
a = kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
img_lcd=image.Image()
while(True):
img = sensor.snapshot()
code = kpu.run_yolo2(task, img)
if code:
for i in code:
a = img.draw_rectangle(i.rect())
a = lcd.display(img)
a = kpu.deinit(task)

Result

You might also like