91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 8KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-13
  • 語言: 其他
  • 標簽: 人臉識別??

資源簡介

人臉識別基于神經網絡的完整工程代碼,包括get_my_face,other_faces,is_my_face,train_model,搭建好環境就能用。

資源截圖

代碼片段和文件信息

import?cv2
import?dlib
import?os
import?sys
import?random

output_dir?=?‘./my_faces‘
size?=?64

if?not?os.path.exists(output_dir):
????os.makedirs(output_dir)

#?改變圖片的亮度與對比度
def?relight(img?light=1?bias=0):
????w?=?img.shape[1]
????h?=?img.shape[0]
????#image?=?[]
????for?i?in?range(0w):
????????for?j?in?range(0h):
????????????for?c?in?range(3):
????????????????tmp?=?int(img[jic]*light?+?bias)
????????????????if?tmp?>?255:
????????????????????tmp?=?255
????????????????elif?tmp?????????????????????tmp?=?0
????????????????img[jic]?=?tmp
????return?img

#使用dlib自帶的frontal_face_detector作為我們的特征提取器
detector?=?dlib.get_frontal_face_detector()
#?打開攝像頭?參數為輸入流,可以為攝像頭或視頻文件
camera?=?cv2.VideoCapture(0)

index?=?1
while?True:
????if?(index?<=?10000):
????????print(‘Being?processed?picture?%s‘?%?index)
????????#?從攝像頭讀取照片
????????success?img?=?camera.read()
????????#?轉為灰度圖片
????????gray_img?=?cv2.cvtColor(img?cv2.COLOR_BGR2GRAY)
????????#?使用detector進行人臉檢測
????????dets?=?detector(gray_img?1)

????????for?i?d?in?enumerate(dets):
????????????x1?=?d.top()?if?d.top()?>?0?else?0
????????????y1?=?d.bottom()?if?d.bottom()?>?0?else?0
????????????x2?=?d.left()?if?d.left()?>?0?else?0
????????????y2?=?d.right()?if?d.right()?>?0?else?0

????????????face?=?img[x1:y1x2:y2]
????????????#?調整圖片的對比度與亮度,?對比度與亮度值都取隨機數,這樣能增加樣本的多樣性
????????????face?=?relight(face?random.uniform(0.5?1.5)?random.randint(-50?50))

????????????face?=?cv2.resize(face?(sizesize))

????????????cv2.imshow(‘image‘?face)

????????????cv2.imwrite(output_dir+‘/‘+str(index)+‘.jpg‘?face)

????????????index?+=?1
????????key?=?cv2.waitKey(30)?&?0xff
????????if?key?==?27:
????????????break
????else:
????????print(‘Finished!‘)
????????break

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-05-24?01:36??FaceRecognition-tensorflow-master\
?????文件?????????143??2017-05-24?01:36??FaceRecognition-tensorflow-master\README.md
?????文件????????1937??2017-05-24?01:36??FaceRecognition-tensorflow-master\get_my_faces.py
?????文件????????5102??2017-05-24?01:36??FaceRecognition-tensorflow-master\is_my_face.py
?????文件????????1872??2017-05-24?01:36??FaceRecognition-tensorflow-master\set_other_faces.py
?????文件????????5770??2017-05-24?01:36??FaceRecognition-tensorflow-master\train_faces.py

評論

共有 條評論