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

歡迎光臨散文網(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)的評論 (共 條)

分享到微博請遵守國家法律
安福县| 北票市| 永清县| 如皋市| 治多县| 新巴尔虎左旗| 珲春市| 滨海县| 邯郸市| 砀山县| 赞皇县| 灵台县| 资中县| 鄂州市| 石楼县| 都安| 韩城市| 兴隆县| 南岸区| 通化县| 自治县| 玉门市| 逊克县| 金华市| 金寨县| 司法| 娄底市| 伽师县| 易门县| 广灵县| 安岳县| 宝坻区| 农安县| 永德县| 海林市| 辽宁省| 札达县| 大冶市| 湄潭县| 吉林省| 道真|