{"rsdb":{"rid":"244568","subhead":"","postdate":"0","aid":"168305","fid":"54","uid":"1","topic":"1","content":"

0.\u5f15\u8a00
<\/strong><\/p>

\u3000\u3000\u81ea\u5df1\u5728\u4e0b\u8f7ddlib\u5b98\u7f51\u7ed9\u7684example\u4ee3\u7801\u65f6\uff0c\u4e00\u5f00\u59cb\u4e0d\u77e5\u9053\u600e\u4e48\u4f7f\u7528\uff0c\u5728\u4e00\u756a\u6478\u7d22\u4e4b\u540e\u5f04\u660e\u767d\u600e\u4e48\u4f7f\u7528\u4e86\uff1b<\/p>

\u3000\u3000\u73b0\u5206\u4eab\u4e0b face_detector.py <\/strong><\/em><\/span>\u548c face_landmark_detection.py <\/strong><\/em><\/span>\u8fd9\u4e24\u4e2apy\u7684\u4f7f\u7528\u65b9\u6cd5\uff1b<\/p>

\u3000\u30001.\u7b80\u4ecb<\/strong>
<\/span><\/p>

\u3000\u3000python<\/a>:\u3000\u30003.6.3<\/em><\/p>

\u3000\u3000dlib:\u3000\u3000\u3000 19.7<\/em>\u3000\u3000<\/p>

\u3000\u3000\u5229\u7528dlib\u7684\u7279\u5f81\u63d0\u53d6\u5668\uff0c\u8fdb\u884c\u4eba\u8138 \u77e9\u5f62\u6846<\/span><\/span><\/strong> <\/span>\u7684\u7279\u5f81\u63d0\u53d6\uff1a<\/span><\/strong><\/span><\/p>

\u3000\u3000\u5229\u7528dlib\u768468\u70b9\u7279\u5f81\u9884\u6d4b\u5668\uff0c\u8fdb\u884c\u4eba\u8138 68\u70b9<\/span> <\/span><\/span>\u7279\u5f81\u63d0\u53d6\uff1a<\/span><\/strong><\/p>

\u3000\u3000\u3000\u3000\u6548\u679c\uff1a<\/p>

\u3000\u3000\u3000\u3000\"\"\u3000\u3000\"\"<\/p>

\u3000\u3000\u3000\u3000\u3000\u3000(a) face_detector.py\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000(b) face_landmark_detection.py<\/strong><\/em><\/em><\/strong><\/em><\/p>

2.py\u6587\u4ef6\u529f\u80fd\u4ecb\u7ecd<\/strong>
<\/span><\/p>

\u3000\u3000face_detector.py <\/span><\/strong>:\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u8bc6\u522b\u51fa\u56fe\u7247\u6587\u4ef6\u4e2d\u4e00\u5f20\u6216\u591a\u5f20\u4eba\u8138\uff0c\u5e76\u7528\u77e9\u5f62\u6846\u6846\u51fa\u6807\u8bc6\u51fa\u4eba\u8138\uff1b<\/em><\/p>

\u3000\u3000\u3000\u3000link: http:\/\/dlib.net\/cnn_face_detector.py.html<\/a><\/em><\/p>

\u3000\u3000face_landmark_detection.py <\/strong><\/span>\uff1a\u3000\u3000\u5728face_detector.py\u7684\u8bc6\u522b\u4eba\u8138\u57fa\u7840\u4e0a\uff0c\u8bc6\u522b\u51fa\u4eba\u8138\u90e8\u7684\u5177\u4f53\u7279\u5f81\u90e8\u4f4d\uff1a\u4e0b\u5df4\u8f6e\u5ed3\u3001\u7709\u6bdb\u3001\u773c\u775b\u3001\u5634\u5df4\uff0c\u540c\u6837\u7528\u6807\u8bb0\u6807\u8bc6\u51fa\u9762\u90e8\u7279\u5f81\uff1b<\/em><\/em><\/p>

 \u3000\u3000\u3000\u3000\u3000\u3000link: http:\/\/dlib.net\/face_landmark_detection.py.html<\/a><\/em><\/p>

\u3000\u3000\u3000\u30002.1. face_detector.py<\/span><\/strong><\/em><\/span><\/p>

\u3000\u3000\u3000\u3000\u5b98\u7f51\u7ed9\u7684face_detector.py<\/strong><\/em><\/span><\/p>

import sys<\/p>

import dlib
from skimage import io<\/p>


detector = dlib.get_frontal_face_detector()
win = dlib.image_window()<\/p>

for f in sys.argv[1:]:
    print("Processing file: {}".format(f))
    img = io.imread(f)
    # The 1 in the second argument indicates that we should upsample the image
    # 1 time.  This will make everything bigger and allow us to detect more
    # faces.
    dets = detector(img, 1)
    print("Number of faces detected: {}".format(len(dets)))
    for i, d in enumerate(dets):
        print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
            i, d.left(), d.top(), d.right(), d.bottom()))<\/p>

    win.clear_overlay()
    win.set_image(img)
    win.add_overlay(dets)
    dlib.hit_enter_to_continue()<\/p>


# Finally, if you really want to you can ask the detector to tell you the score
# for each detection.  The score is bigger for more confident detections.
# The third argument to run is an optional adjustment to the detection threshold,
# where a negative value will return more detections and a positive value fewer.
# Also, the idx tells you which of the face sub-detectors matched.  This can be
# used to broadly identify faces in different orientations.
if (len(sys.argv[1:]) > 0):
    img = io.imread(sys.argv[1])
    dets, scores, idx = detector.run(img, 1, -1)
    for i, d in enumerate(dets):
        print("Detection {}, score: {}, face_type:{}".format(
            d, scores[i], idx[i]))<\/p>

 \u4e3a\u4e86\u65b9\u4fbf\u7406\u89e3\uff0c\u4fee\u6539\u589e\u52a0\u6ce8\u91ca\u4e4b\u540e\u7684 face_detector.py<\/strong><\/em><\/span><\/p>

import dlib
from skimage import io<\/p>

# \u4f7f\u7528\u7279\u5f81\u63d0\u53d6\u5668frontal_face_detector
detector = dlib.get_frontal_face_detector()<\/p>

# path\u662f\u56fe\u7247\u6240\u5728\u8def\u5f84
path = "F:\/code\/
python<\/a>\/P_dlib_face\/pic\/"
img = io.imread(path+"1.jpg")<\/p>

# \u7279\u5f81\u63d0\u53d6\u5668\u7684\u5b9e\u4f8b\u5316
dets = detector(img)<\/p>

print("\u4eba\u8138\u6570\uff1a", len(dets))<\/p>

# \u8f93\u51fa\u4eba\u8138\u77e9\u5f62\u7684\u56db\u4e2a\u5750\u6807\u70b9
for i, d in enumerate(dets):
    print("\u7b2c", i, "\u4e2a\u4eba\u8138d\u7684\u5750\u6807\uff1a",
          "left:", d.left(),
          "right:", d.right(),
          "top:", d.top(),
          "bottom:", d.bottom())<\/p>

# \u7ed8\u5236\u56fe\u7247
win = dlib.image_window()
# \u6e05\u9664\u8986\u76d6
#win.clear_overlay()
win.set_image(img)
# \u5c06\u751f\u6210\u7684\u77e9\u9635\u8986\u76d6\u4e0a
win.add_overlay(dets)
# \u4fdd\u6301\u56fe\u50cf
dlib.hit_enter_to_continue()<\/p>

\u5bf9test.jpg\u8fdb\u884c\u4eba\u8138\u68c0\u6d4b\uff1a<\/p>

\u7ed3\u679c<\/strong>\uff1a<\/p>

\u3000\u3000\u56fe\u7247\u7a97\u53e3\u7ed3\u679c\uff1a<\/p>

\"\"<\/p>

\u3000\u3000\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>

\u5bf9\u4e8e\u591a\u4e2a\u4eba\u8138\u7684\u68c0\u6d4b\u7ed3\u679c\uff1a<\/p>

\"\"<\/p>

\u3000\u30002.2 face_landmark_detection.py<\/em><\/span><\/strong><\/span><\/p>

\u3000\u3000\u3000\u3000<\/strong>\u5b98\u7f51\u7ed9\u7684 face_detector.py<\/em><\/strong><\/span><\/p>

#!\/usr\/bin\/python
# The contents of this file are in t","orderid":"0","title":"Python 3 \u5229\u7528 Dlib 19.7 \u8fdb\u884c\u4eba\u8138\u8bc6\u522b(\u4e00)","smalltitle":"","mid":"0","fname":"linux\u7f16\u7a0b\u57fa\u7840","special_id":"0","bak_id":"0","info":"0","hits":"848","pages":"4","comments":"0","posttime":"2018-02-13 12:56:58","list":"1518497818","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"
Python<\/A> \u5229\u7528<\/A> Dlib<\/A> 19.7<\/A> \u8fdb\u884c<\/A> \u4eba\u8138<\/A> \u8bc6\u522b<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"113.87.122.142","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Python 3 \u5229\u7528 Dlib 19.7 \u8fdb\u884c\u4eba\u8138\u8bc6\u522b","lastview":"1714128311","digg_num":"2","digg_time":"1710826172","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}