1. 代码部分
此代码块为recognize_video.py内的代码
# USAGE
# python recognize_video.py --detector face_detection_model \
# --embedding-model openface_nn4.small2.v1.t7 \
# --recognizer output/recognizer.pickle \
# --le output/le.pickle
# v4_v1解决了多线程中的Exception in thread Thread-7:UnboundLocalError:
# local variable 'name' referenced before assignment
# 加载必要的包
from imutils.video import VideoStream
from imutils.video import FPS
import numpy as np
import imutils
import pickle
import time
import cv2
import os
import tkinter as tk
import threading
def recognize_video():
## 创建识别窗口
win_rec = tk.Tk()
win_rec.title('人脸识别')
win_rec.geometry('300x320')
var_name = tk.StringVar()
var_proba = tk.StringVar()
var_ans = tk.StringVar()
## 创建画布用于切换图片
canvas1 = tk.Canvas(win_rec, height = 129, width = 183)
canvas2 = tk.Canvas(win_rec, height = 129, width = 183)
stop = tk.PhotoImage(file = 'stop.gif')
welcome = tk.PhotoImage(file = 'welcome.gif')
canvas1.create_image(0,0, anchor = 'nw', image = stop)
canvas2.create_image(0,0, anchor = 'nw', image = welcome)
## 创建Label用于显示人名及匹配度
tk.Label(win_rec, text = '姓 名:').place(x = 50, y = 50)
tk.Label(win_rec, text = '匹配度:').place(x = 50, y = 90)
tk.Label(win_rec, textvariable = var_name).place(x = 100, y = 50)
tk.Label(win_rec, textvariable = var_proba).place(x = 100, y = 90)
tk.Label(win_rec, textvariable = var_ans).place(x = 100, y = 130)
tk.Label(win_rec,


1818

被折叠的 条评论
为什么被折叠?



