来自ImageGrab.grab的Python PIL和People检测

时间:2018-03-26 03:48:54

标签: python python-3.x image python-imaging-library

我试图将人员检测代码和周围的绘图框调整为此代码:

while(True):
    screen = np.array(ImageGrab.grab(bbox=(0,40, 1680, 1050)))
    new_screen = process_img(screen)

    print('Loop took {} seconds'.format(time.time()-last_time))
    last_time = time.time()
    cv2.imshow('window', new_screen)
    #cv2.imshow('NotAFortniteCheat', cv2.cvtColor(screen, 
    cv2.COLOR_BGR2RGB))
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

这是有效的,但是试图在其上添加人物检测会引发我太多错误并让我觉得人物检测只能在图像或预制视频而不是实时捕捉?

尝试:

if __name__ == '__main__':

hog = cv2.HOGDescriptor()
hog.setSVMDetector( cv2.HOGDescriptor_getDefaultPeopleDetector() )
while(True):
    screen = np.array(ImageGrab.grab)
    found,w=hog.detectMultiScale(screen, winStride=(8,8), padding=(32,32), 
    scale=1.05)
    draw_detections(screen,found)
    new_screen = process_img(screen)
    cv2.imshow('feed',new_screen)
    ch = 0xFF & cv2.waitKey(1)
    if ch == 27:
        break

0 个答案:

没有答案