第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

采用開源方案的實(shí)時(shí)人臉識(shí)別實(shí)驗(yàn)

实时人脸识别实验

采用开源方案的实时人脸识别实验,本方案采用大名鼎鼎的dlib库,使用深度学习的目前最高水平的人脸识别代码,号称此模型在使用LFW人脸库的测试中, 正确率可达到惊人的99.38%.

原文:(Built using dlib's state-of-the-art face recognition built with deep learning. The model has an accuracy of 99.38% on the Labeled Faces in the Wild benchmark.)


42c65360-025d-11e7-94ea-b12f28cb34b4.png

本代码来自 Adam Geitgey 的 face_recognition开源项目,Adam Geitgey的face_recognition

36f0e3f0-13cb-11e7-8258-4d0c9ce1e419.gif


%matplotlib inline 
import matplotlib.pyplot as pltfrom IPython import displayimport face_recognitionimport cv2
# 初始化人员(姓名和照片)user_name = ['who','weixin','gaoshine','suowei']
user_img = []
user_encoding =[]for i in range(len(user_name)):
    mName = user_name[i]
    mImg = face_recognition.load_image_file("./data/%s.jpg" % mName)
    user_img.append(mImg)
    user_encoding.append(face_recognition.face_encodings(mImg)[0])# Create arrays of known face encodings and their namesknown_face_encodings = user_encoding
known_face_names = user_name# Initialize some variablesface_locations = []
face_encodings = []
face_names = []
process_this_frame = True
# 采集摄像头video_capture = cv2.VideoCapture(0)
i = 0j = 10000while True:    # 捕获单帧图像
    ret, frame = video_capture.read()    # 将原图缩小到1/4大小用于人脸识别
    small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)    # 颜色空间转换BGR转换为RGB,opencv使用的是BGR,而face_recognition使用了RGB 
    rgb_small_frame = small_frame[:, :, ::-1] 

        
    # 处理每一帧的图像
    if process_this_frame:        # 从当前帧中查找和识别人脸
        face_locations = face_recognition.face_locations(rgb_small_frame)
        face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)

        face_names = []        for face_encoding in face_encodings:            # 试图从已知的人脸库中匹配, matches返回的独热码来比对那个user_name = ['weixin','gaoshine','suowei'] 
            matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
            name = "Unknown"
            
            # 如果匹配到即采用第一个
            if True in matches:
                first_match_index = matches.index(True)
                name = known_face_names[first_match_index]

            face_names.append(name)

    process_this_frame = not process_this_frame    # 显示结果
    for (top, right, bottom, left), name in zip(face_locations, face_names):        # 图像尺寸回复原大小(X4)
        top *= 4
        right *= 4
        bottom *= 4
        left *= 4

        # 在人脸画方框标注
        cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)        # 在人脸方框上写标注
        cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
        font = cv2.FONT_HERSHEY_DUPLEX
        cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)    # 显示图像
    cv2.imshow('Video', frame)
    
    i = i + 1
    if i%25:
        j = j + 1
        # 将原图缩小到1/2大小保存
        save_frame = cv2.resize(frame, (0, 0), fx=0.5, fy=0.5)
        cv2.cv2.imwrite("./output/%d.jpg" % j, save_frame)    
    # 按 'q' 退出!
    if cv2.waitKey(1) & 0xFF == ord('q'):        break# 释放摄像头资源video_capture.release()
cv2.destroyAllWindows()

以上的代码,简单到发指.
不过我测试了一下,看看效果并不理性啊,看来呢个LFW的那个基准测试已经不那么权威了.
下一步看看这个face_recognition的一些具体参数,了解一下能不能提升一下识别率.
下面是我们测试时图片:


Gif-2018-04-08-16-04-33.gif



作者:gaoshine
链接:https://www.jianshu.com/p/cf4c6f6ccc51


點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消