鍓嶈█
澶у濂斤紝鎴戞槸闃垮厜銆?/p>
鏈笓鏍忔暣鐞嗕簡銆奝yTorch娣卞害瀛︿範椤圭洰瀹炴垬100渚嬨€嬶紝鍐呭寘鍚簡鍚勭涓嶅悓鐨勬繁搴﹀涔犻」鐩紝鍖呭惈椤圭洰鍘熺悊浠ュ強婧愮爜锛屾瘡涓€涓」鐩疄渚嬮兘闄勫甫鏈夊畬鏁寸殑浠g爜+鏁版嵁闆嗐€?/p>
姝e湪鏇存柊涓瓇 鉁?/p>
馃毃 鎴戠殑椤圭洰鐜锛?/p>
- 骞冲彴锛歐indows10
- 璇█鐜锛歱ython3.7
- 缂栬瘧鍣細PyCharm
- PyTorch鐗堟湰锛?.8.1
馃挜 椤圭洰涓撴爮锛氥€怭yTorch娣卞害瀛︿範椤圭洰瀹炴垬100渚嬨€?/p>
瀹夎鎵€闇€妯″潡锛?/strong>
pip install cv2
pip install midiapipe
MidiaPipe
MediaPipe 涓虹洿鎾拰娴佸獟浣撴彁渚涜法骞冲彴銆佸彲瀹氬埗鐨勬満鍣ㄥ涔犺В鍐虫柟妗堛€?/p>
- 绔埌绔姞閫熷紩鎿庯細鍐呯疆鐨勫揩閫?ML 鎺ㄧ悊鍜屽鐞嗗嵆浣垮湪甯歌纭欢涓婁篃鑳藉姞閫?/li>
- 涓€娆℃瀯寤猴紝浠绘剰閮ㄧ讲锛氱粺涓€瑙e喅鏂规閫傜敤浜?Android銆乮OS銆佹闈?浜戙€乄eb 鍜岀墿鑱旂綉
- 鍗崇敤鍨嬭В鍐虫柟妗堬細鍏堣繘鐨勬満鍣ㄥ涔犺В鍐虫柟妗堝睍绀轰簡妗嗘灦鐨勫叏閮ㄥ姛鑳?/li>
- 鍏嶈垂寮€婧愶細Apache 2.0涓嬬殑妗嗘灦鍜岃В鍐虫柟妗堬紝瀹屽叏鍙墿灞曞拰鍙畾鍒?/li>
FaceDetection妯″瀷
MediaPipe 浜鸿劯妫€娴嬫槸涓€绉嶈秴蹇殑浜鸿劯妫€娴嬭В鍐虫柟妗堬紝甯︽湁 6 涓湴鏍囧拰澶氫汉鑴告敮鎸併€傚畠鍩轰簬 BlazeFace锛岃繖鏄竴绉嶈交閲忕骇涓旀€ц兘鑹ソ鐨勪汉鑴告娴嬪櫒锛屼笓涓虹Щ鍔?GPU 鎺ㄧ悊閲忚韩瀹氬埗銆傛娴嬪櫒鐨勮秴瀹炴椂鎬ц兘浣垮叾鑳藉搴旂敤浜庝换浣曢渶瑕佸噯纭殑闈㈤儴鎰熷叴瓒e尯鍩熶綔涓哄叾浠栦换鍔$壒瀹氭ā鍨嬭緭鍏ョ殑瀹炴椂鍙栨櫙鍣ㄤ綋楠岋紝渚嬪 3D 闈㈤儴鍏抽敭鐐规垨鍑犱綍浼拌锛堜緥濡?MediaPipe Face Mesh锛夛紝闈㈤儴鐗瑰緛鎴栬〃鎯呭垎绫伙紝浠ュ強闈㈤儴鍖哄煙鍒嗗壊銆?BlazeFace 浣跨敤浜嗕竴涓交閲忕骇鐗瑰緛鎻愬彇缃戠粶锛屽叾鐏垫劅鏉ヨ嚜 MobileNetV1/V2锛屼絾涓?MobileNetV1/V2 涓嶅悓锛屽畠鏄竴绉嶄粠 Single Shot MultiBox Detector (SSD) 淇敼鑰屾潵鐨?GPU 鍙嬪ソ閿氱偣鏂规锛屼互鍙婁竴绉嶆浛浠i潪鏋佸ぇ鍊兼姂鍒剁殑鏀硅繘鐨?tie 鍒嗚鲸鐜囩瓥鐣ャ€?/p>
<font color=BlueViolet>璁烘枃鍚嶇О锛?/strong></font>SSD: Single Shot MultiBox Detector
<font color=red>鍘熸枃鍦板潃锛?/strong></font>Single Shot
閰嶇疆妯″瀷鍙傛暟
with mp_face_detection.FaceDetection(
model_selection=1, min_detection_confidence=0.5) as face_detection:
- model_selection锛氫娇鐢?0 閫夋嫨鏈€閫傚悎璺濈鐩告満 2 绫充互鍐呯殑浜鸿劯鐨勭煭璺濈妯″瀷锛屼娇鐢?1 閫夋嫨鏈€閫傚悎璺濈鐩告満 5 绫充互鍐呯殑浜鸿劯鐨勫叏璺濈妯″瀷銆?/li>
- min_detection_confidence锛氫汉鑴告娴嬫ā鍨嬬殑鏈€灏忕疆淇″€?([0.0, 1.0])锛屼互渚垮皢妫€娴嬭涓烘垚鍔熴€傞粯璁や负 0.5銆?/li>
浜鸿劯鍦版爣
妫€娴嬪埌鐨勪汉鑴哥殑闆嗗悎锛屽叾涓瘡涓汉鑴搁兘琛ㄧず涓轰竴涓娴嬮泦鍚堬紝鍏朵腑鍖呭惈涓€涓竟鐣屾鍜?6 涓叧閿偣锛堝彸鐪笺€佸乏鐪笺€侀蓟灏栥€佸槾宸翠腑蹇冦€佸彸鑰冲拰宸﹁€筹級銆?/p>
杈圭晫妗嗙敱 xmin 鍜屽搴﹀拰 ymin 鍜岄珮搴︾粍鎴愩€傛瘡涓叧閿偣鐢?x 鍜?y 缁勬垚锛屽垎鍒€氳繃鍥惧儚瀹藉害鍜岄珮搴﹀綊涓€鍖栦负 [0.0, 1.0]銆?/p>
if results.detections:
for detection in results.detections: # 鑾峰彇浜鸿劯鍦版爣
people += 1
mp_drawing.draw_detection(image, detection)
閮ㄥ垎浠g爜
鏈」鐩彲浠ヤ娇鐢ㄦ枃浠惰緭鍏ュ拰鎽勫儚澶磋繘琛岃緭鍏ワ紝涓嬮潰浠g爜閲囩敤鐨勬槸鏂囦欢杈撳叆锛屽鏋滈渶瑕佷娇鐢ㄦ憚鍍忓ご浣滀负杈撳叆婧愶紝鍙渶瑕佸皢 cap = cv2.VideoCapture("video/finger3.MP4")
鍐呴儴鍙傛暟缃负0鍗冲彲锛屼笉杩囪繕闇€瑕佽皟鏁翠竴涓嬪叾瀹冧綅缃紝杩欓噷涓嶅仛杩囧鍙欒堪銆?/p>
銆怭yTorch娣卞害瀛︿範椤圭洰瀹炴垬100渚嬨€戔€斺€?Python+OpenCV+MediaPipe瀹炴椂浜烘祦妫€娴?| 绗?渚?em>鍜?鍢熺殑鍗氬-CSDN鍗氬浜烘祦棰勬祴娣卞害瀛︿範