国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Python用dilb提取照片上人臉的示例

瀏覽:25日期:2022-07-07 09:54:35

上代碼:

#coding=utf-8import cv2import dlibpath = 'imagePath/9.jpg'img = cv2.imread(path)gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)#人臉分類器detector = dlib.get_frontal_face_detector()# 獲取人臉檢測器predictor = dlib.shape_predictor( 'shape_predictor_68_face_landmarks.dat')color = (0, 255, 0) # 定義繪制顏色dets = detector(gray, 1)for face in dets: shape = predictor(img, face) # 尋找人臉的68個標(biāo)定點(diǎn) chang=[] kuan= [] # 遍歷所有點(diǎn),打印出其坐標(biāo),并圈出來 for pt in shape.parts(): pt_pos = (pt.x, pt.y) chang.append(pt.x) kuan.append(pt.y) #cv2.circle(img, pt_pos, 1, (0, 255, 0), 1) x1 = max(chang) x2 = min(chang) y1 = max(kuan) y2 = min(kuan) cv2.rectangle(img, (x2, y2), (x1, y1), color, 1) cropped = img[y2 + 1:y1, x2 + 1:x1] # 裁剪坐標(biāo)為[y0:y1, x0:x1] cv2.imshow('image', cropped) k = cv2.waitKey(0) if k == ord('s'): cv2.imwrite('imagePath/9-7.png', cropped)cv2.destroyAllWindows()

識別效果:

Python用dilb提取照片上人臉的示例

以上就是Python用dilb提取照片上人臉的示例的詳細(xì)內(nèi)容,更多關(guān)于python 提取人臉的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 阿拉尔市| 通辽市| 灯塔市| 德保县| 高要市| 扎赉特旗| 新沂市| 平阴县| 武穴市| 常宁市| 即墨市| 城市| 玉溪市| 咸丰县| 启东市| 陕西省| 安康市| 高安市| 陵水| 池州市| 丹巴县| 林甸县| 仪陇县| 图木舒克市| 麻城市| 浮梁县| 海盐县| 嘉荫县| 石景山区| 城步| 新闻| 攀枝花市| 栖霞市| 大埔区| 太仆寺旗| 同江市| 磐安县| 阿拉善右旗| 紫阳县| 蒙自县| 湟源县|