81面のキーポイント検出



81 Face Key Point Detection



私は以前、主に顔の68のキーポイントを検出するためにDlibを実行しましたが、対応する68の顔のキーポイントは次のとおりです。

https://img-blog.csdnimg.cn/20190327192943610.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG1ubizeMFF4color=LmNzZG1ubizeMFF4FF



それらの中で、dlibの68ポイントの使用は参照することができます: https://blog.csdn.net/xingchenbingbuyu/article/details/51116354

この記事のデモは、dlibに基づく拡張機能です。



プロジェクトアドレス: https://github.com/codeniko/shape_predictor_81_face_landmarks

プロジェクトは、指定された画像(ビデオストリームの写真またはフレーム)に対して81の顔の特徴の検出を実装します。トレーニングプロセスは68ポイントのdlibに似ており、作成者は13ポイントの額部分を追加します。その領域の頭部検出または画像処理の精度が向上します。作者が額に帽子をかぶったら〜

誰かの頭に帽子をかぶる。



これらの13のポイントの抽出、著者はpatrikhubereosプロジェクトに言及しています。 https://github.com/codeniko/eos

著者はまた、サリーの顔モデルを使用しました

以下は、作者の元の言葉です。

「ここで変更を加えてから、ibugの大規模な画像データベース全体で実行して、各画像の68個のランドマーク座標を81個のランドマーク座標で上書きしました。ここから、形状予測モデルのトレーニングは、 http://dlib.net/train_shape_predictor.py.html 「」

プロジェクトを実行している作者のデモビデオを見ることができます。 https://www.youtube.com/watch?v=mDJrASIB1T0

以下は81の特徴点の分布であり、そのうち0〜67は68点のdlibであり、68〜80は著者が追加した13点です。

https://img-blog.csdnimg.cn/20190327193427434.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubizeMFF4FF4_LmNzZG4ubizeMFF


プロジェクトコードをダウンロードした後、プロジェクトパスに切り込み、anaconda環境を使用し、webcam_record.pyスクリプトを実行します。手順は、次のとおりです。

python webcam_record.py

https://img-blog.csdnimg.cn/2019032719370633.png

上記のコードを実行すると、カメラがリアルタイムでキャプチャされ、顔のキーが検出されます。結果は次のとおりです。

https://img-blog.csdnimg.cn/20190327194309530.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG1ubizeMFF4color=LmNzZG1ubizeMFF4FF

リアルタイム検出は本当に良いです、完全にCPUが実行されています、それは小さな画像の顔検出には良いですが、顔は顔の横方向に小さすぎて検出されません〜

私の携帯電話の女性スターは誰だと思います~~~

スクリプトのソースコードは次のとおりです(dlibベースと同様)。

website_record.py

import sys import os import dlib import glob from skimage import io import numpy as np import cv2 Cap = cv2.VideoCapture(0) #read camera Fourcc = cv2.VideoWriter_fourcc(*'XVID') #Generate the encoded form of the video file Out = cv2.VideoWriter('output.avi',fourcc, 20.0, (1280, 720)) #output video parameter information Predictor_path = 'shape_predictor_81_face_landmarks.dat' # Detector = dlib.get_frontal_face_detector() #Use frontal_face_detector that comes with dlib as our face extractor predictor = dlib.shape_predictor(predictor_path) #2. Building a feature extractor using an officially provided model while(cap.isOpened()): ret, frame = cap.read() Frame = cv2.flip(frame, 1) #Image horizontal flip Dets = detector(frame, 0) #3. Face detection using the detector dets is the result of the return for k, d in enumerate(dets): Shape = predictor(frame, d) #5. Using predictor for face key recognition landmarks = np.matrix([[p.x, p.y] for p in shape.parts()]) for num in range(shape.num_parts): Cv2.circle(frame, (shape.parts()[num].x, shape.parts()[num].y), 3, (0,255,0), -1) #6.Draw feature points cv2.imshow('frame', frame) out.write(frame) if cv2.waitKey(1) & 0xFF == ord('q'): print('q pressed') break cap.release() out.release() cv2.destroyAllWindows()

事前にいくつかのライブラリをインストールする必要があります。pipを使用してください

pip cmake、opencv-python、dlib

Cmakeはdlibライブラリをコンパイルするために使用されます〜

楽しい !