欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 用python3.6在電腦上實現(xiàn)用攝像頭來人臉識別源程序 [打印本頁]

作者: 曾欽昶    時間: 2019-5-18 22:03
標題: 用python3.6在電腦上實現(xiàn)用攝像頭來人臉識別源程序
在這里,我用了anaconda,OpenCV,python3.6來實現(xiàn)代碼的,代碼在附件中,可以自己下載了,自己試試

python源程序如下:
  1. # -*- coding: UTF-8 -*-
  2. import face_recognition
  3. import cv2
  4. import os
  5. # 這是一個超級簡單(但很慢)的例子,在你的網(wǎng)絡攝像頭上實時運行人臉識別
  6. # PLEASE NOTE: This example requires OpenCV (the `cv2` library) to be installed only to read from your webcam.
  7. # 請注意:這個例子需要安裝OpenCV
  8. # 具體的演示。如果你安裝它有困難,試試其他不需要它的演示。
  9. # 得到一個參考的攝像頭# 0(默認)
  10. video_capture = cv2.VideoCapture(0)
  11. # 加載示例圖片并學習如何識別它。
  12. path ="images"#在同級目錄下的images文件中放需要被識別出的人物圖
  13. total_image=[]
  14. total_image_name=[]
  15. total_face_encoding=[]
  16. for fn in os.listdir(path): #fn 表示的是文件名
  17.   total_face_encoding.append(face_recognition.face_encodings(face_recognition.load_image_file(path+"/"+fn))[0])
  18.   fn=fn[:(len(fn)-4)]#截取圖片名(這里應該把images文件中的圖片名命名為為人物名)
  19.   total_image_name.append(fn)#圖片名字列表
  20. while True:
  21.   # 抓取一幀視頻
  22.   ret, frame = video_capture.read()
  23.   # 發(fā)現(xiàn)在視頻幀所有的臉和face_enqcodings
  24.   face_locations = face_recognition.face_locations(frame)
  25.   face_encodings = face_recognition.face_encodings(frame, face_locations)
  26.   # 在這個視頻幀中循環(huán)遍歷每個人臉
  27.   for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
  28.       # 看看面部是否與已知人臉相匹配。
  29.       for i,v in enumerate(total_face_encoding):
  30.           match = face_recognition.compare_faces([v], face_encoding,tolerance=0.5)
  31.           name = "Unknown"
  32.           if match[0]:
  33.               name = total_image_name[i]
  34.               break
  35.       # 畫出一個框,框住臉
  36.       cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
  37.       # 畫出一個帶名字的標簽,放在框下
  38.       cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
  39.       font = cv2.FONT_HERSHEY_DUPLEX
  40.       cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
  41.   # 顯示結果圖像
  42.   cv2.imshow('Video', frame)
  43.   # 按q退出
  44.   if cv2.waitKey(1) & 0xFF == ord('q'):
  45.       break
  46. # 釋放攝像頭中的流
  47. video_capture.release()
  48. cv2.destroyAllWindows()
復制代碼

以上代碼下載:
人臉識別.zip (1.32 KB, 下載次數(shù): 214)


作者: 放眼天下    時間: 2019-10-25 10:58
這個怎么么用啊...電腦上自帶的攝像頭可以嗎
作者: bunny0928    時間: 2019-10-27 08:52
想試一試

作者: QDMLIT    時間: 2019-10-31 15:58
謝謝你的辛勤勞動
作者: 鵬博士PBs    時間: 2020-4-24 17:38
樓上的人臉識別face_recognition的定義是否需要更改
作者: xnhtao    時間: 2020-5-12 08:43
人臉識別這么簡單嗎?
作者: xintiandi    時間: 2020-5-13 09:26
不錯。支持一下,現(xiàn)在python是主流了。
作者: lirizhi    時間: 2020-5-25 10:28
不錯。支持一下。
作者: vvcc    時間: 2020-6-1 09:16
可以試試
作者: MikeCai    時間: 2020-6-9 09:16
thanks you for your sharing
作者: 好好學習1999    時間: 2021-2-1 13:29
放眼天下 發(fā)表于 2019-10-25 10:58
這個怎么么用啊...電腦上自帶的攝像頭可以嗎

同問 用電腦自帶的攝像頭可以嗎
作者: dzc3458    時間: 2021-11-2 09:29
xnhtao 發(fā)表于 2020-5-12 08:43
人臉識別這么簡單嗎?

都是別人寫好了的庫,真實的人臉識別難得多
作者: zjnbzm    時間: 2023-10-8 10:40
謝謝分享一下這個程序,謝謝樓主!
作者: wljlxh110    時間: 2026-3-18 09:12
謝謝你的辛勤勞動




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1