最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【開源】ESP32-cam+python 實(shí)現(xiàn)人臉識別(opencv)

2023-01-14 15:06 作者:謝必安_玄  | 我要投稿

import CV2

import numpy as np

import mediapipe as mp

import time


pTime = 0


cap = CV2.VideoCapture("http://192.168.31.89:81/stream")


mpFaceDetection = mp.solutions.face_detection


mpDraw = mp.solutions.drawing_utils


faceDetection = mpFaceDetection.FaceDetection(0.75)

def fancyDraw(img,bbox,l=30,t=5,rt=1):


? ? x,y,w,h=bbox

? ? x1,y1=x+w,y+h


? ? CV2.rectangle(img,bbox,(255,0,255),rt)

? ? #Top Left x,y


? ? CV2.line(img,(x,y),(x+1,y),(255,0,255),t)

? ? CV2.line(img,(x,y),(x,y+1),(255,0,255),t)

? ? # Top Right x1,y


? ? CV2.line(img,(x1,y),(x1-1,y),(255,0,255),t)

? ? CV2.line(img,(x1,y),(x1,y+1),(255,0,255),t)

? ? # Bottom Left x,y1


? ? CV2.line(img,(x,y1),(x+1,y1),(255,0,255),t)

? ? CV2.line(img,(x,y1),(x,y1-1),(255,0,255),t)

? ? # Bottom Right x1,y1


? ? CV2.line(img,(x1,y1),(x1-1,y1),(255,0,255),t)

? ? CV2.line(img,(x1,y1),(x1,y1-1),(255,0,255),t)

? ? return img


while True:

? ? success,img=cap.read()

? ? imgRGB =CV2.cvtColor(img,CV2.COLOR_BGR2RGB)

? ? results = faceDetection.process(imgRGB)

? ? if results.detections:

? ? ? ? for id , detection in enumerate(results.detettions):

? ? ? ? ? ? # mpDraw.draw_detection(img,detection)

? ? ? ? ? ? # print(id,detection)

? ? ? ? ? ? bboxC = detection.location_data.relative_bounding_box

? ? ? ? ? ? ih,iw,ic = img.shape


? ? ? ? ? ? bbox=int(bboxC.xmin*iw),int(bboxC.ymin* ih),int(bboxC.width * iw),int(bboxC.height* ih)

? ? ? ? ? ? # print(bbox)

? ? ? ? ? ? # CV2.rectangle(img,bbox,(255,0,255),2)

? ? ? ? ? ? img=fancyDraw(img,bbox,l=10)

? ? ? ? ? ? CV2.putText(img, f'{int(detection.score[0]* 100)}%', (bbox[0], bbox[1] - 20), CV2.FONT_HERSHEY_PLAIN, 3, (255, 0,255),2)

? ? cTime = time.time()

? ? fps=1/(cTime-pTime)

? ? pTime = cTime

? ? CV2.putText(img,f'FPS: {int(fps)}',(20,70),CV2.FONT_HERSHEY_PLAIN,3,(0,255,0),2)

? ? #旋轉(zhuǎn)90度,旋轉(zhuǎn)幾次

? ? img=np.rot90(img,k=3)

? ? CV2.imshow("img",img)

? ? CV2.waitkey(1)



【開源】ESP32-cam+python 實(shí)現(xiàn)人臉識別(opencv)的評論 (共 條)

分享到微博請遵守國家法律
察雅县| 衡南县| 平潭县| 石渠县| 田东县| 惠来县| 大渡口区| 西安市| 明光市| 阿尔山市| 峨边| 贵州省| 镇平县| 凤城市| 奎屯市| 巴东县| 徐州市| 和田县| 绥宁县| 宜良县| 隆回县| 丰台区| 桂林市| 营口市| 东辽县| 山西省| 兴安县| 盘锦市| 永福县| 张家界市| 恩平市| 南昌县| 乡城县| 凤冈县| 海兴县| 都昌县| 平南县| 利津县| 邻水| 西畴县| 西贡区|