Как-нибудь улучшить производительность кодов распознавания лиц на Raspberry Pi?

У меня есть следующие коды, выполняющие функцию распознавания лиц на Raspberry Pi. До какой-либо оптимизации производительность составляла всего 0,3 FPS. После многопоточности производительность улучшается до ~1.5FPS, что все еще далеко от желаемого.

Кто-нибудь может помочь оптимизировать код? Большое спасибо.

#
def handle():
    global q 
    while True:         
        res = q.get()
        o1, o2, o3 = res.get()    
        process_img(o1, o2, o3)   # process_img function deals with the processes of delivering the face recognition results

# part of main algorithm
pool = mp.Pool(processes = 4)
thread = threading.Thread(target = handle)     
thread.daemon = True
thread.start()

for frame in camera.capture_continuous(rawCapture, format = "bgr", use_video_port = True):
    bgrImg = frame.array 
    bgrImg = cv2.flip(bgrImg,1)
    if fps % 10 == 0:    
        r = pool.apply_async(get_bb, [bgrImg])  # get_bb is the function that does image processing to find who the person in the picture is using SVM classifier
        q.put(r)
        fps = 0
    fps += 1    
    if cv2.waitKey(1) & 0xFF == ord('q'):           
        cv2.destroyAllWindows()
        break
#

0 ответов

Другие вопросы по тегам