Пример #1
0
def update_all(root, canvas, cam, fps_label):
    #update_image(canvas, cam)
    
    ret, img = cam.read()
    cv2.flip(img,1)
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    gray = cv2.equalizeHist(gray)
    rects = detect(gray, cascade)
    vis = img.copy()
    vis = vis[...,::-1]#converts BGR to RGB
    a = Image.fromarray(vis)
    
    faces=[]
    for x1, y1, x2, y2 in rects:
        faces.append([[(x1+x2)/2,(y1+y2)/2]])
    draw_sprites.draw_sprites(a,faces)
        
    b = ImageTk.PhotoImage(image=a)
    #canvas.delete(tk.ALL)
    #canvas.delete('all')
    global frame 
    frame = canvas.create_image(0,0,image=b,anchor=tk.NW) 
    root.update()
    time.sleep(.001)
    update_fps(fps_label)
    root.after(0, func=lambda: update_all(root, canvas, cam, fps_label))
Пример #2
0
def update_all(root, canvas, cam, fps_label):
    #update_image(canvas, cam)

    ret, img = cam.read()
    cv2.flip(img, 1)
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    gray = cv2.equalizeHist(gray)
    rects = detect(gray, cascade)
    vis = img.copy()
    vis = vis[..., ::-1]  #converts BGR to RGB
    a = Image.fromarray(vis)

    faces = []
    for x1, y1, x2, y2 in rects:
        faces.append([[(x1 + x2) / 2, (y1 + y2) / 2]])
    draw_sprites.draw_sprites(a, faces)

    b = ImageTk.PhotoImage(image=a)
    #canvas.delete(tk.ALL)
    #canvas.delete('all')
    global frame
    frame = canvas.create_image(0, 0, image=b, anchor=tk.NW)
    root.update()
    time.sleep(.001)
    update_fps(fps_label)
    root.after(0, func=lambda: update_all(root, canvas, cam, fps_label))
Пример #3
0
def draw_rects(img, rects, color):
    pil_im = Image.fromarray(np.uint8(cm.gist_earth(img)*255))
    faces=[]
    for x1, y1, x2, y2 in rects:
        faces.append([[(x1+x2)/2,(y1+y2)/2]])
    pil_img=draw_sprites.draw_sprites(pi,faces)
    img=image2array(pil_img)
Пример #4
0
def draw_rects(img, rects, color):
    pil_im = Image.fromarray(np.uint8(cm.gist_earth(img) * 255))
    faces = []
    for x1, y1, x2, y2 in rects:
        faces.append([[(x1 + x2) / 2, (y1 + y2) / 2]])
    pil_img = draw_sprites.draw_sprites(pi, faces)
    img = image2array(pil_img)