xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 2.13M
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-10-31
  • 語言: 其他
  • 標簽: 其他??

資源簡介

DIY_Face_recognition_system-master.zip

資源截圖

代碼片段和文件信息

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

output_dir?=?‘./wyj_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?<=?200):??#截取1000張圖片
????????print(‘Being?processed?picture?%s‘?%?index)??#輸出當前截取圖片的進度
????????#?從攝像頭讀取照片
????????success?img?=?camera.read()
????????#?轉為灰度圖片
????????gray_img?=?cv2.cvtColor(img?cv2.COLOR_BGR2GRAY)
????????#?使用detector進行人臉檢測
????????dets?=?detector(gray_img?1)??#detector會返回識別到的人臉的矩形的左下角和右上角的坐標

????????for?i?d?in?enumerate(dets):??#enumerate用于遍歷括號中的元素及其下標,其中i對應元素下標,d對應元素
????????????x1?=?d.top()?if?d.top()?>?0?else?0??#通過left,right,top,down獲取矩形的四個坐標x1,x2,y1,y2
????????????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
????????????#?調整圖片的對比度與亮度,?對比度與亮度值都取隨機數,這樣能增加樣本的多樣性
????????????face?=?relight(face?random.uniform(0.5?1.5)?random.randint(-50?50))

????????????face?=?cv2.resize(face?(sizesize))??#調整圖片大小

????????????cv2.imshow(‘Easy?&?Happy-get?picture?now‘?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??2019-10-27?20:04??DIY_Face_recognition_system-master\
?????文件????????2607??2019-10-27?15:54??DIY_Face_recognition_system-master\pictures_get.py
?????文件????????1877??2019-10-27?15:54??DIY_Face_recognition_system-master\pictures_set.py
?????文件?????????556??2019-10-27?20:06??DIY_Face_recognition_system-master\README.md
?????文件????????6298??2019-10-27?15:54??DIY_Face_recognition_system-master\test.py
?????文件????????6942??2019-10-27?15:54??DIY_Face_recognition_system-master\train.py
?????文件?????2394816??2019-10-27?15:54??DIY_Face_recognition_system-master\項目報告-基本.pdf

評論

共有 條評論