国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python 3利用Dlib 19.7實現攝像頭人臉檢測特征點標定

2020-02-22 23:20:18
字體:
來源:轉載
供稿:網友

Python 3 利用 Dlib 19.7 實現攝像頭人臉檢測特征點標定

0.引言

利用python開發,借助Dlib庫捕獲攝像頭中的人臉,進行實時特征點標定;

圖1 工程效果示例(gif)

圖2 工程效果示例(靜態圖片)

(實現比較簡單,代碼量也比較少,適合入門或者興趣學習。)

1.開發環境

  python:  3.6.3

  dlib:    19.7

  OpenCv, numpy

import dlib     # 人臉識別的庫dlibimport numpy as np # 數據處理的庫numpyimport cv2     # 圖像處理的庫OpenCv 

2.源碼介紹

  其實實現很簡單,主要分為兩個部分:攝像頭調用+人臉特征點標定

2.1 攝像頭調用

  介紹下opencv中攝像頭的調用方法;

  利用 cap = cv2.VideoCapture(0) 創建一個對象;

  (具體可以參考官方文檔)

# 2018-2-26# By TimeStamp# cnblogs: http://www.cnblogs.com/AdaminXie"""cv2.VideoCapture(), 創建cv2攝像頭對象/ open the default camera  Python: cv2.VideoCapture() → <VideoCapture object>  Python: cv2.VideoCapture(filename) → <VideoCapture object>    filename – name of the opened video file (eg. video.avi) or image sequence (eg. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)  Python: cv2.VideoCapture(device) → <VideoCapture object>  device – id of the opened video capturing device (i.e. a camera index). If there is a single camera connected, just pass 0."""cap = cv2.VideoCapture(0)"""cv2.VideoCapture.set(propId, value),設置視頻參數;  propId:  CV_CAP_PROP_POS_MSEC Current position of the video file in milliseconds.  CV_CAP_PROP_POS_FRAMES 0-based index of the frame to be decoded/captured next.  CV_CAP_PROP_POS_AVI_RATIO Relative position of the video file: 0 - start of the film, 1 - end of the film.  CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.  CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.  CV_CAP_PROP_FPS Frame rate.  CV_CAP_PROP_FOURCC 4-character code of codec.  CV_CAP_PROP_FRAME_COUNT Number of frames in the video file.  CV_CAP_PROP_FORMAT Format of the Mat objects returned by retrieve() .  CV_CAP_PROP_MODE Backend-specific value indicating the current capture mode.  CV_CAP_PROP_BRIGHTNESS Brightness of the image (only for cameras).  CV_CAP_PROP_CONTRAST Contrast of the image (only for cameras).  CV_CAP_PROP_SATURATION Saturation of the image (only for cameras).  CV_CAP_PROP_HUE Hue of the image (only for cameras).  CV_CAP_PROP_GAIN Gain of the image (only for cameras).  CV_CAP_PROP_EXPOSURE Exposure (only for cameras).  CV_CAP_PROP_CONVERT_RGB Boolean flags indicating whether images should be converted to RGB.  CV_CAP_PROP_WHITE_BALANCE_U The U value of the whitebalance setting (note: only supported by DC1394 v 2.x backend currently)  CV_CAP_PROP_WHITE_BALANCE_V The V value of the whitebalance setting (note: only supported by DC1394 v 2.x backend currently)  CV_CAP_PROP_RECTIFICATION Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)  CV_CAP_PROP_ISO_SPEED The ISO speed of the camera (note: only supported by DC1394 v 2.x backend currently)  CV_CAP_PROP_BUFFERSIZE Amount of frames stored in internal buffer memory (note: only supported by DC1394 v 2.x backend currently)    value: 設置的參數值/ Value of the property"""cap.set(3, 480)"""cv2.VideoCapture.isOpened(), 檢查攝像頭初始化是否成功 / check if we succeeded返回true或false"""cap.isOpened()""" cv2.VideoCapture.read([imgage]) -> retval,image, 讀取視頻 / Grabs, decodes and returns the next video frame返回兩個值:  一個是布爾值true/false,用來判斷讀取視頻是否成功/是否到視頻末尾  圖像對象,圖像的三維矩陣"""flag, im_rd = cap.read()            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南召县| 砚山县| 海安县| 辽源市| 浙江省| 金寨县| 安国市| 新兴县| 巴塘县| 腾冲县| 通州市| 绥滨县| 方正县| 大城县| 汉川市| 额济纳旗| 阳城县| 特克斯县| 中江县| 林甸县| 巴塘县| 和田县| 安平县| 宁武县| 东乌珠穆沁旗| 青冈县| 珲春市| 蒙山县| 漯河市| 正阳县| 怀远县| 宿松县| 宝兴县| 莱阳市| 任丘市| 高青县| 三明市| 雅江县| 香格里拉县| 嘉祥县| 平江县|