国产无码免费,人妻口爆,国产V在线,99中文精品7,国产成人无码AA精品一,制度丝袜诱惑av,久久99免费麻辣视频,蜜臀久久99精品久久久久久酒店
        訂閱
        糾錯
        加入自媒體

        使用Python+OpenCV+Dlib實現人臉檢測與人臉特征關鍵點識別

        2020-08-12 10:12
        磐創AI
        關注

        到目前為止,我們在檢測人臉方面做得很好,但是我們仍然需要一些工作來提取所有特征(地標)。接下來讓我們開始吧。步驟3:識別人臉特征你喜歡魔術嗎?到目前為止,DLib的工作方式相當神奇,只需幾行代碼我們就可以實現很多,而現在我們遇到了一個全新的問題,它還會繼續這么簡單嗎?回答是肯定的!原來DLib提供了一個名為shape_predictor()的函數,它將為我們提供所有的魔法,但是需要一個預先訓練的模型才能工作。有幾種模型可以與shape_predictor一起工作,我正在使用的模型可以在這里下載,也可以嘗試其他模型。讓我們看看新代碼現在是什么樣子import cv2import dlib# Load the detectordetector = dlib.get_frontal_face_detector()# Load the predictorpredictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")# read the imageimg = cv2.imread("face.jpg")# Convert image into grayscalegray = cv2.cvtColor(src=img, code=cv2.COLOR_BGR2GRAY)# Use detector to find landmarksfaces = detector(gray)for face in faces:    x1 = face.left() # left point    y1 = face.top() # top point    x2 = face.right() # right point    y2 = face.bottom() # bottom point    # Look for the landmarks    landmarks = predictor(image=gray, box=face)    x = landmarks.part(27).x    y = landmarks.part(27).y    # Draw a circle    cv2.circle(img=img, center=(x, y), radius=5, color=(0, 255, 0), thickness=-1)# show the imagecv2.imshow(winname="Face", mat=img)# Wait for a key press to exitcv2.waitKey(delay=0)# Close all windowscv2.destroyAllWindows()像以前一樣,我們總是在同一個代碼上構建代碼,現在使用我們的預測函數為每個人臉找到特征。但現在我還在做一些奇怪的事情,比如如下代碼的數值27是用來干嘛的?landmarks = predictor(image=gray, box=face)x = landmarks.part(27).xy = landmarks.part(27).y我們的預測函數會返回一個包含68個點的對象,根據我們之前看到的圖片,如果你注意到的話,會發現點27正好在眼睛之間,所以如果所有的計算正確,你應該看到一個綠點在眼睛之間,如下圖所示:

        我們已經很接近了,現在讓我們渲染所有的點,而不是只渲染一個:import cv2import numpy as npimport dlib# Load the detectordetector = dlib.get_frontal_face_detector()# Load the predictorpredictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")# read the imageimg = cv2.imread("face.jpg")# Convert image into grayscalegray = cv2.cvtColor(src=img, code=cv2.COLOR_BGR2GRAY)# Use detector to find landmarksfaces = detector(gray)for face in faces:    x1 = face.left() # left point    y1 = face.top() # top point    x2 = face.right() # right point    y2 = face.bottom() # bottom point    # Create landmark object    landmarks = predictor(image=gray, box=face)    # Loop through all the points    for n in range(0, 68):        x = landmarks.part(n).x        y = landmarks.part(n).y        # Draw a circle        cv2.circle(img=img, center=(x, y), radius=3, color=(0, 255, 0), thickness=-1)# show the imagecv2.imshow(winname="Face", mat=img)# Delay between every framcv2.waitKey(delay=0)# Close all windowscv2.destroyAllWindows()

        但是如果你對所有的點都不感興趣呢?實際上,你可以調整你的范圍間隔來獲得上面術語表中指定的任何特征,就像我在這里做的那樣:

        <上一頁  1  2  3  下一頁>  
        聲明: 本文由入駐維科號的作者撰寫,觀點僅代表作者本人,不代表OFweek立場。如有侵權或其他問題,請聯系舉報。

        發表評論

        0條評論,0人參與

        請輸入評論內容...

        請輸入評論/評論長度6~500個字

        您提交的評論過于頻繁,請輸入驗證碼繼續

        暫無評論

        暫無評論

          人工智能 獵頭職位 更多
          掃碼關注公眾號
          OFweek人工智能網
          獲取更多精彩內容
          文章糾錯
          x
          *文字標題:
          *糾錯內容:
          聯系郵箱:
          *驗 證 碼:

          粵公網安備 44030502002758號

          主站蜘蛛池模板: 久久久久久AV| 亚洲成人av在线| av无码免费在线观看| 九色视频丨PORNY丨丝袜| 爱3P| 芜湖县| 51国产| 亚洲网在线| 阿坝县| 国产小精品| 91在线无码精品秘?国产千人斩| 欧美性生交XXXXX久久久| jizz网站| 鄂托克前旗| 91免费高清| 中文字幕第4页| 阿城市| 18禁不禁短片| 国产精品XXX| 天堂网中文字幕| 色婷婷?av| 人妻窝窝WWW聚色窝| jizz国产| 晋江市| 高清无码18禁| 啪啪电影| 中文字幕亚洲二| 常熟市| 国产资源网| 日韩成人A级毛片| 久久久久久av| 襄城县| 日本熟妇视频| 久久久久久久久熟女AV| 超碰人人澡| 景宁| 男人天堂久久| 日韩无码一区二区三区| 西平县| www.97| 曰韩一级|