五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動(dòng)態(tài)

樹莓派上利用python+opencv+dlib實(shí)現(xiàn)嘴唇檢測的實(shí)現(xiàn)

發(fā)布日期:2021-12-17 04:43 | 文章來源:源碼中國

樹莓派上利用python+opencv+dlib實(shí)現(xiàn)嘴唇檢測

項(xiàng)目的目標(biāo)是在樹莓派上運(yùn)行python代碼以實(shí)現(xiàn)嘴唇檢測,本來以為樹莓派的硬件是可以流暢運(yùn)行實(shí)時(shí)檢測的,但是實(shí)驗(yàn)的效果表明樹莓派實(shí)時(shí)檢測是不可行,后面還需要改進(jìn)。

實(shí)驗(yàn)的效果如下:

1、安裝相關(guān)庫文件

這里需要用的庫有opencv,numpy,dlib。

1.1 安裝opencv

pip3 install opencv-python

1.2 安裝numpy

樹莓派中自帶了numpy庫

pip3 install numpy

1.3 安裝dlib

在樹莓派的系統(tǒng)里面安裝dlib比較簡單,只需要pip install就可以了,但是在window系統(tǒng)中會(huì)有報(bào)錯(cuò),這個(gè)時(shí)候我們就需要安裝pip install dlib-19.17.99-cp37-cp37m-win_amd64.whl就可以了, 需要注意的是: 不同的python版本要安裝對應(yīng)版本的dlib,也就是后面的“cp37-cp37m”,查看對應(yīng)python能安裝的版本號,可以使用命令行:pip debug --verbose,可以顯示合適的安裝版本號。
在樹莓派上我安裝了cmake和dlib

pip3 install cmake
pip3 install dlib

2、代碼部分

dlib提取人臉特征中包含68個(gè)點(diǎn)

顎點(diǎn)= 0–16
右眉點(diǎn)= 17–21
左眉點(diǎn)= 22–26
鼻點(diǎn)= 27–35
右眼點(diǎn)= 36–41
左眼點(diǎn)= 42–47
口角= 48–60
嘴唇分?jǐn)?shù)= 61–67

from gpiozero import LED
from time import sleep
from subprocess import check_call
import cv2
import numpy as np
import dlib
print(cv2.__version__)
def search_cap_num():
 for i in range(2000):
  cap = cv2.VideoCapture(i)
  cap_opened = cap.isOpened()
  if cap_opened == True:
return i
  
cap_num = search_cap_num()
cap = cv2.VideoCapture(cap_num)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
# 規(guī)定上嘴唇和下嘴唇連線的路徑
lip_order_dlib = np.array([[48, 49, 50, 51, 52, 53, 54, 64, 63, 62, 61, 60, 48],[48, 59, 58, 57, 56, 55, 54, 64, 65, 66, 67, 60, 48]]) - 48
lip_order_num = lip_order_dlib.shape[1]
while 1:
 landmarks_lip = []
 ret, frame = cap.read()
 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
 rects = detector(gray, 1)
 print('faces number:' + str(len(rects)))
 for (i, rect) in enumerate(rects):
  # 標(biāo)記人臉中的68個(gè)landmark點(diǎn)
  landmarks = predictor(gray, rect)  
  for n in range(48, 68):
x = landmarks.part(n).x
y = landmarks.part(n).y
landmarks_lip.append((x, y))
# cv2.circle(img=img, center=(x, y), radius=3, color=(0, 255, 0), thickness=-1)
  for m in range(lip_order_num-1):
cv2.line(frame, landmarks_lip[lip_order_dlib[0][m]], landmarks_lip[lip_order_dlib[0][m+1]], color=(0, 255, 0), thickness=2, lineType=8)
  for n in range(lip_order_num-1):
cv2.line(frame, landmarks_lip[lip_order_dlib[1][n]], landmarks_lip[lip_order_dlib[1][n+1]], color=(0, 255, 0), thickness=2, lineType=8)
 cv2.imshow("face", frame)
 if cv2.waitKey(1) & 0xff == ord('q'):
  break
cap.release()
cv2.destroyAllWindows()
# check_call(['sudo', 'poweroff'])

3、實(shí)驗(yàn)效果


效果總體而言比較卡頓,感覺分析一張圖片花費(fèi)時(shí)間在秒量級上。
要是僅僅是顯示攝像頭的圖片還是很快的,沒有任何卡頓,也就是說如果代碼中不存在rects = detector(gray, 1)這種獲取人臉區(qū)域的檢測命令,那么運(yùn)行速度大大提高,后面需要思考怎么在人臉檢測下提高代碼運(yùn)行速度。

到此這篇關(guān)于樹莓派上利用python+opencv+dlib實(shí)現(xiàn)嘴唇檢測的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)python+opencv+dlib嘴唇檢測內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部