无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

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

分享到微博請遵守國家法律
枣阳市| 宁武县| 石景山区| 呼伦贝尔市| 五原县| 鹤壁市| 盐津县| 区。| 崇仁县| 郁南县| 江津市| 资阳市| 黔南| 喀什市| 山阴县| 库尔勒市| 轮台县| 岳普湖县| 麻阳| 灵武市| 濮阳市| 云霄县| 双城市| 沿河| 临潭县| 雅江县| 日照市| 德惠市| 科尔| 桦甸市| 于田县| 柳州市| 佳木斯市| 报价| 丹江口市| 乌苏市| 靖西县| 宾阳县| 瑞丽市| 海盐县| 马龙县|