当前位置: 首页>大数据>正文

【PyTorch深度学习项目实战100例】—— Python+OpenCV+MediaPipe实时人流检测 - 第3例

鍓嶈█

澶у濂斤紝鎴戞槸闃垮厜銆?/p>

鏈笓鏍忔暣鐞嗕簡銆奝yTorch娣卞害瀛︿範椤圭洰瀹炴垬100渚嬨€嬶紝鍐呭寘鍚簡鍚勭涓嶅悓鐨勬繁搴﹀涔犻」鐩紝鍖呭惈椤圭洰鍘熺悊浠ュ強婧愮爜锛屾瘡涓€涓」鐩疄渚嬮兘闄勫甫鏈夊畬鏁寸殑浠g爜+鏁版嵁闆嗐€?/p>

姝e湪鏇存柊涓瓇 鉁?/p>

馃毃 鎴戠殑椤圭洰鐜锛?/p>

  • 骞冲彴锛歐indows10
  • 璇█鐜锛歱ython3.7
  • 缂栬瘧鍣細PyCharm
  • PyTorch鐗堟湰锛?.8.1

馃挜 椤圭洰涓撴爮锛氥€怭yTorch娣卞害瀛︿範椤圭洰瀹炴垬100渚嬨€?/p>

【PyTorch深度学习项目实战100例】—— Python+OpenCV+MediaPipe实时人流检测 - 第3例,第1张

瀹夎鎵€闇€妯″潡锛?/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>

【PyTorch深度学习项目实战100例】—— Python+OpenCV+MediaPipe实时人流检测 - 第3例,第2张

<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)
【PyTorch深度学习项目实战100例】—— Python+OpenCV+MediaPipe实时人流检测 - 第3例,第3张

閮ㄥ垎浠g爜

鏈」鐩彲浠ヤ娇鐢ㄦ枃浠惰緭鍏ュ拰鎽勫儚澶磋繘琛岃緭鍏ワ紝涓嬮潰浠g爜閲囩敤鐨勬槸鏂囦欢杈撳叆锛屽鏋滈渶瑕佷娇鐢ㄦ憚鍍忓ご浣滀负杈撳叆婧愶紝鍙渶瑕佸皢 cap = cv2.VideoCapture("video/finger3.MP4") 鍐呴儴鍙傛暟缃负0鍗冲彲锛屼笉杩囪繕闇€瑕佽皟鏁翠竴涓嬪叾瀹冧綅缃紝杩欓噷涓嶅仛杩囧鍙欒堪銆?/p>

銆怭yTorch娣卞害瀛︿範椤圭洰瀹炴垬100渚嬨€戔€斺€?Python+OpenCV+MediaPipe瀹炴椂浜烘祦妫€娴?| 绗?渚?em>鍜?鍢熺殑鍗氬-CSDN鍗氬浜烘祦棰勬祴娣卞害瀛︿範


https://www.xamrdz.com/bigdata/7ya1994985.html

相关文章: