{"id":73338,"date":"2026-02-07T15:09:15","date_gmt":"2026-02-07T07:09:15","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/73338.html"},"modified":"2026-02-07T15:09:15","modified_gmt":"2026-02-07T07:09:15","slug":"%e3%80%90opencv%e5%85%a5%e9%97%a8%e3%80%91%e8%bd%bb%e6%9d%be%e6%8e%8c%e6%8f%a1%e4%ba%ba%e8%84%b8%e8%af%86%e5%88%ab%ef%bc%9a%e4%bb%8e%e5%9b%be%e7%89%87%e5%88%b0%e8%a7%86%e9%a2%91%e7%9a%84haar%e7%ba%a7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/73338.html","title":{"rendered":"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218"},"content":{"rendered":"<h3>&#x1f680; \u524d\u8a00<\/h3>\n<p>\u5728\u5f53\u4eca\u8fd9\u4e2aAI\u6280\u672f\u65e0\u5904\u4e0d\u5728\u7684\u65f6\u4ee3&#xff0c;\u4eba\u8138\u8bc6\u522b\u5df2\u7ecf\u6210\u4e3a\u4e00\u9879\u975e\u5e38\u666e\u53ca\u7684\u5e94\u7528&#xff0c;\u4ece\u624b\u673a\u89e3\u9501\u3001\u79fb\u52a8\u652f\u4ed8\u5230\u5b89\u9632\u76d1\u63a7&#xff0c;\u6211\u4eec\u6bcf\u5929\u90fd\u5728\u4e0e\u4e4b\u6253\u4ea4\u9053\u3002\u4f5c\u4e3a\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u6700\u7ecf\u5178\u7684\u5165\u95e8\u6848\u4f8b\u4e4b\u4e00&#xff0c;\u4f7f\u7528 OpenCV \u5b9e\u73b0\u4eba\u8138\u8bc6\u522b\u4e0d\u4ec5\u80fd\u8ba9\u6211\u4eec\u5feb\u901f\u4f53\u9a8c\u5230AI\u7684\u9b45\u529b&#xff0c;\u66f4\u80fd\u4e3a\u6df1\u5165\u5b66\u4e60\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5e26\u9886\u5927\u5bb6\u4e00\u6b65\u6b65\u4e86\u89e3 OpenCV \u4e2d\u57fa\u4e8e Haar\u7279\u5f81\u7684\u7ea7\u8054\u5206\u7c7b\u5668 \u8fdb\u884c\u4eba\u8138\u68c0\u6d4b\u7684\u5b8c\u6574\u6d41\u7a0b\u3002\u6211\u4eec\u5c06\u4ece\u6838\u5fc3\u539f\u7406\u8bb2\u8d77&#xff0c;\u7136\u540e\u901a\u8fc7\u4e24\u4e2a\u5b9e\u6218\u6848\u4f8b\u2014\u2014\u56fe\u7247\u4eba\u8138\u68c0\u6d4b\u548c\u5b9e\u65f6\u89c6\u9891\u4eba\u8138\u68c0\u6d4b\u2014\u2014\u6765\u5de9\u56fa\u6240\u5b66\u77e5\u8bc6\u3002<\/p>\n<hr \/>\n<h3>&#x1f4a1; \u4e00\u3001\u6838\u5fc3\u539f\u7406\u7b80\u4ecb<\/h3>\n<p>\u5728\u6211\u4eec\u6df1\u5165\u4ee3\u7801\u4e4b\u524d&#xff0c;\u5148\u82b1\u51e0\u5206\u949f\u7406\u89e3\u4e00\u4e0b\u5176\u80cc\u540e\u7684\u4e09\u5927\u6838\u5fc3\u6982\u5ff5&#xff1a;Haar\u7279\u5f81\u3001AdaBoost\u7b97\u6cd5 \u548c \u7ea7\u8054\u5206\u7c7b\u5668\u3002<\/p>\n<h4>1. Haar \u7279\u5f81 (Haar Features)<\/h4>\n<p>\u8ba1\u7b97\u673a\u5982\u4f55\u50cf\u4eba\u4e00\u6837\u201c\u770b\u201d\u5230\u4eba\u8138\u7684\u7279\u5f81&#xff1f;Haar \u7279\u5f81\u5c31\u662f\u4e00\u79cd\u7b80\u5355\u800c\u9ad8\u6548\u7684\u65b9\u5f0f\u3002\u5b83\u672c\u8d28\u4e0a\u662f\u4e00\u7cfb\u5217\u9884\u5b9a\u4e49\u7684\u201c\u6a21\u677f\u201d&#xff0c;\u8fd9\u4e9b\u6a21\u677f\u7531\u9ed1\u767d\u4e24\u79cd\u77e9\u5f62\u7ec4\u6210\u3002<\/p>\n<p>\u8ba1\u7b97\u4e00\u4e2a Haar \u7279\u5f81\u503c\u7684\u8fc7\u7a0b\u5f88\u7b80\u5355&#xff1a;\u7528\u767d\u8272\u77e9\u5f62\u533a\u57df\u5185\u7684\u50cf\u7d20\u503c\u4e4b\u548c\u51cf\u53bb\u9ed1\u8272\u77e9\u5f62\u533a\u57df\u5185\u7684\u50cf\u7d20\u503c\u4e4b\u548c\u3002<\/p>\n<p>\u8fd9\u4e2a\u5dee\u503c\u53cd\u6620\u4e86\u56fe\u50cf\u5c40\u90e8\u7684\u7070\u5ea6\u53d8\u5316\u60c5\u51b5\u3002\u5bf9\u4e8e\u4eba\u8138\u800c\u8a00&#xff0c;\u5b58\u5728\u4e00\u4e9b\u666e\u904d\u7684\u7279\u5f81&#xff1a;<\/p>\n<ul>\n<li>\u773c\u775b\u533a\u57df&#xff1a;\u773c\u775b\u901a\u5e38\u6bd4\u5468\u56f4\u7684\u8138\u988a\u989c\u8272\u6df1&#xff0c;\u53ef\u4ee5\u7528\u4e00\u4e2a\u6c34\u5e73\u65b9\u5411\u7684\u201c\u9ed1-\u767d-\u9ed1\u201d\u6a21\u677f\u6765\u6355\u6349\u3002<\/li>\n<li>\u9f3b\u6881\u533a\u57df&#xff1a;\u9f3b\u6881\u4e24\u4fa7\u901a\u5e38\u6bd4\u9f3b\u6881\u672c\u8eab\u989c\u8272\u6df1&#xff0c;\u53ef\u4ee5\u7528\u4e00\u4e2a\u5782\u76f4\u65b9\u5411\u7684\u201c\u767d-\u9ed1-\u767d\u201d\u6a21\u677f\u6765\u6355\u6349\u3002<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u5728\u56fe\u50cf\u4e0a\u6ed1\u52a8\u4e0d\u540c\u5927\u5c0f\u548c\u7c7b\u578b\u7684Haar\u6a21\u677f&#xff0c;\u6211\u4eec\u5c31\u80fd\u63d0\u53d6\u51fa\u6210\u5343\u4e0a\u4e07\u4e2a\u7279\u5f81&#xff0c;\u8fd9\u4e9b\u7279\u5f81\u5171\u540c\u6784\u6210\u4e86\u63cf\u8ff0\u56fe\u50cf\u7684\u57fa\u7840\u3002<\/p>\n<h4>2. AdaBoost \u7b97\u6cd5<\/h4>\n<p>\u6709\u4e86\u6d77\u91cf\u7684Haar\u7279\u5f81&#xff0c;\u6211\u4eec\u5982\u4f55\u7b5b\u9009\u51fa\u90a3\u4e9b\u6700\u80fd\u8bc6\u522b\u4eba\u8138\u7684\u201c\u5173\u952e\u7279\u5f81\u201d\u5462&#xff1f;\u8fd9\u5c31\u662f AdaBoost \u7b97\u6cd5\u7684\u4f5c\u7528\u3002<\/p>\n<p>AdaBoost \u662f\u4e00\u79cd\u96c6\u6210\u5b66\u4e60\u7b97\u6cd5&#xff0c;\u5b83\u7684\u601d\u60f3\u662f\u201c\u4e09\u4e2a\u81ed\u76ae\u5320&#xff0c;\u9876\u4e2a\u8bf8\u845b\u4eae\u201d\u3002\u5b83\u4f1a\u4ece\u6240\u6709\u7279\u5f81\u4e2d\u6311\u9009\u51fa\u4e00\u4e2a\u6700\u80fd\u533a\u5206\u4eba\u8138\u548c\u975e\u4eba\u8138\u7684\u201c\u5f31\u5206\u7c7b\u5668\u201d&#xff08;\u6bd4\u5982&#xff0c;\u5224\u65ad\u9f3b\u6881\u533a\u57df\u662f\u5426\u6bd4\u4e24\u4fa7\u4eae&#xff09;\u3002\u7136\u540e&#xff0c;\u5b83\u4f1a\u91cd\u70b9\u5173\u6ce8\u88ab\u8fd9\u4e2a\u5f31\u5206\u7c7b\u5668\u9519\u8bef\u5206\u7c7b\u7684\u6837\u672c&#xff0c;\u5728\u4e0b\u4e00\u8f6e\u4e2d\u6311\u9009\u53e6\u4e00\u4e2a\u5f31\u5206\u7c7b\u5668\u6765\u5f25\u8865\u524d\u4e00\u4e2a\u7684\u4e0d\u8db3\u3002\u5982\u6b64\u53cd\u590d\u8fed\u4ee3&#xff0c;\u6700\u7ec8\u5c06\u6210\u767e\u4e0a\u5343\u4e2a\u201c\u5f31\u5206\u7c7b\u5668\u201d\u52a0\u6743\u7ec4\u5408\u6210\u4e00\u4e2a\u5f3a\u5927\u7684\u201c\u5f3a\u5206\u7c7b\u5668\u201d\u3002<\/p>\n<h4>3. \u7ea7\u8054\u5206\u7c7b\u5668 (Cascade Classifier)<\/h4>\n<p>\u5373\u4f7f\u6709\u4e86\u5f3a\u5206\u7c7b\u5668&#xff0c;\u5728\u6574\u5f20\u56fe\u7247\u4e0a\u9010\u50cf\u7d20\u5730\u8fdb\u884c\u68c0\u6d4b\u4f9d\u7136\u975e\u5e38\u8017\u65f6\u3002\u4e3a\u4e86\u63d0\u9ad8\u6548\u7387&#xff0c;OpenCV \u91c7\u7528\u4e86\u7ea7\u8054\u5206\u7c7b\u5668\u7684\u7ed3\u6784&#xff0c;\u5b83\u50cf\u4e00\u4e2a\u591a\u5c42\u7b5b\u9009\u7684\u5173\u5361\u3002<\/p>\n<ul>\n<li>\u7b2c\u4e00\u5173&#xff1a;\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u5feb\u901f\u7684\u5206\u7c7b\u5668&#xff0c;\u5b83\u4f1a\u8fc5\u901f\u6392\u9664\u6389\u56fe\u7247\u4e2d\u5927\u91cf\u660e\u663e\u4e0d\u662f\u4eba\u8138\u7684\u533a\u57df&#xff08;\u5982\u5929\u7a7a\u3001\u5899\u58c1&#xff09;\u3002<\/li>\n<li>\u7b2c\u4e8c\u5173&#xff1a;\u4e00\u4e2a\u7a0d\u590d\u6742\u7684\u5206\u7c7b\u5668&#xff0c;\u5bf9\u901a\u8fc7\u7b2c\u4e00\u5173\u7684\u533a\u57df\u8fdb\u884c\u8fdb\u4e00\u6b65\u7b5b\u9009\u3002<\/li>\n<li>\u2026\u4ee5\u6b64\u7c7b\u63a8&#xff0c;\u540e\u7eed\u7684\u5173\u5361\u8d8a\u6765\u8d8a\u590d\u6742&#xff0c;\u4e5f\u8d8a\u6765\u8d8a\u4e25\u683c\u3002<\/li>\n<\/ul>\n<p>\u53ea\u6709\u5f53\u4e00\u4e2a\u56fe\u50cf\u533a\u57df\u6210\u529f\u901a\u8fc7\u4e86\u6240\u6709\u5173\u5361&#xff0c;\u5b83\u624d\u4f1a\u88ab\u6700\u7ec8\u5224\u5b9a\u4e3a\u201c\u4eba\u8138\u201d\u3002\u8fd9\u79cd\u8bbe\u8ba1\u6781\u5927\u5730\u63d0\u5347\u4e86\u68c0\u6d4b\u901f\u5ea6&#xff0c;\u56e0\u4e3a\u7edd\u5927\u591a\u6570\u80cc\u666f\u533a\u57df\u5728\u6700\u521d\u51e0\u5173\u5c31\u88ab\u6dd8\u6c70\u4e86\u3002<\/p>\n<p>OpenCV \u5df2\u7ecf\u4e3a\u6211\u4eec\u8bad\u7ec3\u597d\u4e86\u8fd9\u4e9b\u5206\u7c7b\u5668&#xff0c;\u5e76\u4ee5 .xml \u6587\u4ef6\u7684\u5f62\u5f0f\u63d0\u4f9b&#xff0c;\u6211\u4eec\u76f4\u63a5\u52a0\u8f7d\u4f7f\u7528\u5373\u53ef\u3002<\/p>\n<hr \/>\n<h3>&#x1f527; \u4e8c\u3001\u51c6\u5907\u5de5\u4f5c<\/h3>\n<p>\u5728\u5f00\u59cb\u7f16\u7801\u524d&#xff0c;\u8bf7\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86\u5fc5\u8981\u7684\u5e93&#xff0c;\u5e76\u77e5\u9053\u5982\u4f55\u627e\u5230\u5206\u7c7b\u5668\u6587\u4ef6\u3002<\/p>\n<h4>1. \u5b89\u88c5\u5e93<\/h4>\n<p>pip <span class=\"token function\">install<\/span> opencv-python<br \/>\npip <span class=\"token function\">install<\/span> matplotlib<\/p>\n<h4>2. \u5b9a\u4f4d Haar \u5206\u7c7b\u5668 XML \u6587\u4ef6<\/h4>\n<p>OpenCV \u81ea\u5e26\u4e86\u5f88\u591a\u9884\u8bad\u7ec3\u597d\u7684\u5206\u7c7b\u5668&#xff0c;\u7528\u4e8e\u68c0\u6d4b\u4eba\u8138\u3001\u773c\u775b\u3001\u5fae\u7b11\u3001\u732b\u8138\u7b49\u3002\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e OpenCV \u5e93\u7684\u5b89\u88c5\u76ee\u5f55\u4e2d\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b Python \u4ee3\u7801\u627e\u5230\u5b83\u4eec\u7684\u5177\u4f53\u4f4d\u7f6e&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> cv2 <span class=\"token keyword\">as<\/span> cv<br \/>\n<span class=\"token keyword\">import<\/span> os<\/p>\n<p><span class=\"token comment\"># \u6253\u5370cv2\u7684\u5b89\u88c5\u8def\u5f84<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>cv<span class=\"token punctuation\">.<\/span>__file__<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u6784\u9020haarcascades\u6587\u4ef6\u5939\u7684\u8def\u5f84<\/span><br \/>\ncascades_path <span class=\"token operator\">&#061;<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>join<span class=\"token punctuation\">(<\/span>os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>dirname<span class=\"token punctuation\">(<\/span>cv<span class=\"token punctuation\">.<\/span>__file__<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;data&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Haar aascades \u6587\u4ef6\u5939\u8def\u5f84: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>cascades_path<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd0\u884c\u540e&#xff0c;\u4f60\u4f1a\u5f97\u5230\u4e00\u4e2a\u7c7b\u4f3c &#8230;\/site-packages\/cv2\/data \u7684\u8def\u5f84\u3002\u6211\u4eec\u63a5\u4e0b\u6765\u8981\u7528\u5230\u7684 haarcascade_frontalface_default.xml \u548c haarcascade_eye.xml \u6587\u4ef6\u5c31\u5728\u8fd9\u4e2a\u76ee\u5f55\u91cc\u3002\u5728\u4ee3\u7801\u4e2d&#xff0c;\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84&#xff0c;\u6216\u8005\u5c06\u5b83\u4eec\u590d\u5236\u5230\u4f60\u7684\u9879\u76ee\u5de5\u4f5c\u76ee\u5f55\u4e0b\u3002<\/p>\n<hr \/>\n<h3>&#x1f468;\u200d&#x1f4bb; \u4e09\u3001\u5b9e\u6218\u4e00&#xff1a;\u56fe\u7247\u4e2d\u7684\u4eba\u8138\u4e0e\u773c\u775b\u68c0\u6d4b<\/h3>\n<p>\u8ba9\u6211\u4eec\u4ece\u4e00\u4e2a\u9759\u6001\u56fe\u7247\u68c0\u6d4b\u7684\u4f8b\u5b50\u5f00\u59cb\u3002<\/p>\n<h4>\u5b8c\u6574\u4ee3\u7801<\/h4>\n<p><span class=\"token keyword\">import<\/span> cv2 <span class=\"token keyword\">as<\/span> cv<br \/>\n<span class=\"token keyword\">import<\/span> matplotlib<span class=\"token punctuation\">.<\/span>pyplot <span class=\"token keyword\">as<\/span> plt<\/p>\n<p><span class=\"token comment\"># &#8212; 1. \u8bfb\u53d6\u56fe\u7247\u5e76\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe &#8212;<\/span><br \/>\n<span class=\"token comment\"># \u4ee5\u5f69\u8272\u6a21\u5f0f\u8bfb\u53d6\u56fe\u7247<\/span><br \/>\nimg <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>imread<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;16.jpg&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\"># \u5c06BGR\u56fe\u50cf\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe&#xff0c;\u56e0\u4e3a\u4eba\u8138\u68c0\u6d4b\u901a\u5e38\u5728\u7070\u5ea6\u56fe\u4e0a\u8fdb\u884c&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u8ba1\u7b97\u91cf<\/span><br \/>\ngray <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>cvtColor<span class=\"token punctuation\">(<\/span>img<span class=\"token punctuation\">,<\/span> cv<span class=\"token punctuation\">.<\/span>COLOR_BGR2GRAY<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212; 2. \u52a0\u8f7dOpenCV\u9884\u8bad\u7ec3\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668 &#8212;<\/span><br \/>\n<span class=\"token comment\"># \u786e\u4fddXML\u6587\u4ef6\u8def\u5f84\u6b63\u786e&#xff0c;\u5982\u679c\u6587\u4ef6\u5728\u540c\u7ea7\u76ee\u5f55\u4e0b&#xff0c;\u76f4\u63a5\u5199\u6587\u4ef6\u540d\u5373\u53ef<\/span><br \/>\nface_cas_path <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;haarcascade_frontalface_default.xml&#034;<\/span><br \/>\neye_cas_path <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;haarcascade_eye.xml&#034;<\/span><\/p>\n<p>face_cas <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>CascadeClassifier<span class=\"token punctuation\">(<\/span>face_cas_path<span class=\"token punctuation\">)<\/span><br \/>\neye_cas <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>CascadeClassifier<span class=\"token punctuation\">(<\/span>eye_cas_path<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212; 3. \u6267\u884c\u4eba\u8138\u68c0\u6d4b &#8212;<\/span><br \/>\n<span class=\"token comment\"># detectMultiScale\u662f\u6838\u5fc3\u68c0\u6d4b\u51fd\u6570<\/span><br \/>\n<span class=\"token comment\"># scaleFactor: \u56fe\u50cf\u5c3a\u5bf8\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u503c\u8d8a\u5c0f&#xff0c;\u68c0\u6d4b\u8d8a\u6162\u4f46\u53ef\u80fd\u66f4\u51c6<\/span><br \/>\n<span class=\"token comment\"># minNeighbors: \u6bcf\u4e2a\u5019\u9009\u77e9\u5f62\u6846\u81f3\u5c11\u9700\u8981\u88ab\u591a\u5c11\u4e2a\u90bb\u8fd1\u77e9\u5f62\u652f\u6301\u624d\u88ab\u4fdd\u7559&#xff0c;\u503c\u8d8a\u5927&#xff0c;\u68c0\u6d4b\u8d8a\u4e25\u683c<\/span><br \/>\n<span class=\"token comment\"># minSize: \u76ee\u6807\u7684\u6700\u5c0f\u5c3a\u5bf8<\/span><br \/>\nfaceRects <span class=\"token operator\">&#061;<\/span> face_cas<span class=\"token punctuation\">.<\/span>detectMultiScale<span class=\"token punctuation\">(<\/span>gray<span class=\"token punctuation\">,<\/span> scaleFactor<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1.2<\/span><span class=\"token punctuation\">,<\/span> minNeighbors<span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> minSize<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">32<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">32<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212; 4. \u904d\u5386\u68c0\u6d4b\u5230\u7684\u4eba\u8138&#xff0c;\u5e76\u5728\u4eba\u8138\u533a\u57df\u5185\u68c0\u6d4b\u773c\u775b &#8212;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token builtin\">len<\/span><span class=\"token punctuation\">(<\/span>faceRects<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> w<span class=\"token punctuation\">,<\/span> h<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">in<\/span> faceRects<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u5728\u539f\u56fe\u4e0a\u6846\u51fa\u4eba\u8138<\/span><br \/>\n        <span class=\"token comment\"># (x,y)\u662f\u77e9\u5f62\u5de6\u4e0a\u89d2\u5750\u6807, (x&#043;w, y&#043;h)\u662f\u53f3\u4e0b\u89d2\u5750\u6807<\/span><br \/>\n        cv<span class=\"token punctuation\">.<\/span>rectangle<span class=\"token punctuation\">(<\/span>img<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#043;<\/span> w<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#043;<\/span> h<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">255<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u5728\u8bc6\u522b\u51fa\u7684\u4eba\u8138\u533a\u57df&#xff08;ROI, Region of Interest&#xff09;\u5185\u8fdb\u884c\u773c\u775b\u68c0\u6d4b&#xff0c;\u4ee5\u63d0\u9ad8\u6548\u7387\u548c\u51c6\u786e\u6027<\/span><br \/>\n        roi_gray <span class=\"token operator\">&#061;<\/span> gray<span class=\"token punctuation\">[<\/span>y<span class=\"token punctuation\">:<\/span>y<span class=\"token operator\">&#043;<\/span>h<span class=\"token punctuation\">,<\/span> x<span class=\"token punctuation\">:<\/span>x<span class=\"token operator\">&#043;<\/span>w<span class=\"token punctuation\">]<\/span><br \/>\n        roi_color <span class=\"token operator\">&#061;<\/span> img<span class=\"token punctuation\">[<\/span>y<span class=\"token punctuation\">:<\/span>y<span class=\"token operator\">&#043;<\/span>h<span class=\"token punctuation\">,<\/span> x<span class=\"token punctuation\">:<\/span>x<span class=\"token operator\">&#043;<\/span>w<span class=\"token punctuation\">]<\/span><\/p>\n<p>        eyes <span class=\"token operator\">&#061;<\/span> eye_cas<span class=\"token punctuation\">.<\/span>detectMultiScale<span class=\"token punctuation\">(<\/span>roi_gray<span class=\"token punctuation\">,<\/span> scaleFactor<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1.1<\/span><span class=\"token punctuation\">,<\/span> minNeighbors<span class=\"token operator\">&#061;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span>ex<span class=\"token punctuation\">,<\/span> ey<span class=\"token punctuation\">,<\/span> ew<span class=\"token punctuation\">,<\/span> eh<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">in<\/span> eyes<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token comment\"># \u6ce8\u610f&#xff1a;\u773c\u775b\u7684\u5750\u6807\u662f\u76f8\u5bf9\u4e8e\u4eba\u8138ROI\u7684&#xff0c;\u6240\u4ee5\u7ed8\u5236\u65f6\u8981\u5728ROI\u4e0a\u8fdb\u884c<\/span><br \/>\n            cv<span class=\"token punctuation\">.<\/span>rectangle<span class=\"token punctuation\">(<\/span>roi_color<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>ex<span class=\"token punctuation\">,<\/span> ey<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>ex <span class=\"token operator\">&#043;<\/span> ew<span class=\"token punctuation\">,<\/span> ey <span class=\"token operator\">&#043;<\/span> eh<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">255<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212; 5. \u663e\u793a\u6700\u7ec8\u7684\u68c0\u6d4b\u7ed3\u679c &#8212;<\/span><br \/>\n<span class=\"token comment\"># OpenCV\u8bfb\u53d6\u7684\u56fe\u50cf\u662fBGR\u683c\u5f0f&#xff0c;\u800cMatplotlib\u663e\u793a\u662fRGB\u683c\u5f0f&#xff0c;\u9700\u8981\u8f6c\u6362<\/span><br \/>\nimg_rgb <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>cvtColor<span class=\"token punctuation\">(<\/span>img<span class=\"token punctuation\">,<\/span> cv<span class=\"token punctuation\">.<\/span>COLOR_BGR2RGB<span class=\"token punctuation\">)<\/span><\/p>\n<p>plt<span class=\"token punctuation\">.<\/span>figure<span class=\"token punctuation\">(<\/span>figsize<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">8<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">6<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> dpi<span class=\"token operator\">&#061;<\/span><span class=\"token number\">100<\/span><span class=\"token punctuation\">)<\/span><br \/>\nplt<span class=\"token punctuation\">.<\/span>imshow<span class=\"token punctuation\">(<\/span>img_rgb<span class=\"token punctuation\">)<\/span><br \/>\nplt<span class=\"token punctuation\">.<\/span>title<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;Detection Result&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nplt<span class=\"token punctuation\">.<\/span>xticks<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\"># \u9690\u85cfX\u8f74\u5750\u6807<\/span><br \/>\nplt<span class=\"token punctuation\">.<\/span>yticks<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\"># \u9690\u85cfY\u8f74\u5750\u6807<\/span><br \/>\nplt<span class=\"token punctuation\">.<\/span>show<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>\u7ed3\u679c\u5c55\u793a<\/h4>\n<hr \/>\n<h3>&#x1f3a5; \u56db\u3001\u5b9e\u6218\u4e8c&#xff1a;\u5b9e\u65f6\u89c6\u9891\u4eba\u8138\u68c0\u6d4b<\/h3>\n<p>\u638c\u63e1\u4e86\u56fe\u7247\u68c0\u6d4b\u540e&#xff0c;\u89c6\u9891\u68c0\u6d4b\u5c31\u53d8\u5f97\u975e\u5e38\u7b80\u5355\u4e86\u3002\u6211\u4eec\u53ea\u9700\u8981\u5bf9\u89c6\u9891\u7684\u6bcf\u4e00\u5e27\u91cd\u590d\u4e0a\u8ff0\u8fc7\u7a0b\u5373\u53ef\u3002<\/p>\n<h4>\u6027\u80fd\u4f18\u5316\u63d0\u793a<\/h4>\n<p>\u5728 while \u5faa\u73af\u4e2d&#xff0c;\u6ca1\u6709\u5fc5\u8981\u53cd\u590d\u52a0\u8f7d\u5206\u7c7b\u5668\u3002\u5206\u7c7b\u5668\u53ea\u9700\u8981\u5728\u5faa\u73af\u5f00\u59cb\u524d\u52a0\u8f7d\u4e00\u6b21&#xff0c;\u8fd9\u6837\u53ef\u4ee5\u5927\u5927\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\u3002<\/p>\n<h4>\u5b8c\u6574\u4ee3\u7801<\/h4>\n<p><span class=\"token keyword\">import<\/span> cv2 <span class=\"token keyword\">as<\/span> cv<\/p>\n<p><span class=\"token comment\"># &#8212; 1. \u52a0\u8f7d\u5206\u7c7b\u5668&#xff08;\u5728\u5faa\u73af\u5916\u6267\u884c&#xff0c;\u63d0\u9ad8\u6548\u7387&#xff09; &#8212;<\/span><br \/>\nface_cas_path <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;haarcascade_frontalface_default.xml&#034;<\/span><br \/>\nface_cas <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>CascadeClassifier<span class=\"token punctuation\">(<\/span>face_cas_path<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212; 2. \u6253\u5f00\u89c6\u9891\u6587\u4ef6\u6216\u6444\u50cf\u5934 &#8212;<\/span><br \/>\n<span class=\"token comment\"># \u5982\u679c\u8981\u4f7f\u7528\u6444\u50cf\u5934&#xff0c;\u5c06\u6587\u4ef6\u540d\u66ff\u6362\u4e3a 0<\/span><br \/>\ncap <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>VideoCapture<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;movie.mp4&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212; 3. \u5faa\u73af\u5904\u7406\u89c6\u9891\u7684\u6bcf\u4e00\u5e27 &#8212;<\/span><br \/>\n<span class=\"token keyword\">while<\/span> cap<span class=\"token punctuation\">.<\/span>isOpened<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># ret \u662f\u4e00\u4e2a\u5e03\u5c14\u503c&#xff0c;\u8868\u793a\u662f\u5426\u6210\u529f\u8bfb\u53d6\u5230\u5e27<\/span><br \/>\n    <span class=\"token comment\"># frame \u662f\u8bfb\u53d6\u5230\u7684\u5f53\u524d\u5e27\u56fe\u50cf<\/span><br \/>\n    ret<span class=\"token punctuation\">,<\/span> frame <span class=\"token operator\">&#061;<\/span> cap<span class=\"token punctuation\">.<\/span>read<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token comment\"># \u5982\u679c\u89c6\u9891\u8bfb\u53d6\u5b8c\u6bd5\u6216\u8bfb\u53d6\u5931\u8d25&#xff0c;\u5219\u9000\u51fa\u5faa\u73af<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> ret<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">break<\/span><\/p>\n<p>    <span class=\"token comment\"># \u5c06\u5f53\u524d\u5e27\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe<\/span><br \/>\n    gray <span class=\"token operator\">&#061;<\/span> cv<span class=\"token punctuation\">.<\/span>cvtColor<span class=\"token punctuation\">(<\/span>frame<span class=\"token punctuation\">,<\/span> cv<span class=\"token punctuation\">.<\/span>COLOR_BGR2GRAY<span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token comment\"># &#8212; 4. \u5728\u5f53\u524d\u5e27\u4e0a\u8fdb\u884c\u4eba\u8138\u68c0\u6d4b &#8212;<\/span><br \/>\n    faceRects <span class=\"token operator\">&#061;<\/span> face_cas<span class=\"token punctuation\">.<\/span>detectMultiScale<span class=\"token punctuation\">(<\/span>gray<span class=\"token punctuation\">,<\/span> scaleFactor<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1.2<\/span><span class=\"token punctuation\">,<\/span> minNeighbors<span class=\"token operator\">&#061;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span> minSize<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">32<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">32<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token builtin\">len<\/span><span class=\"token punctuation\">(<\/span>faceRects<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> w<span class=\"token punctuation\">,<\/span> h<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">in<\/span> faceRects<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token comment\"># \u5728\u539f\u59cb\u5f69\u8272\u5e27\u4e0a\u6846\u51fa\u4eba\u8138<\/span><br \/>\n            cv<span class=\"token punctuation\">.<\/span>rectangle<span class=\"token punctuation\">(<\/span>frame<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#043;<\/span> w<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#043;<\/span> h<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">255<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token comment\"># &#8212; 5. \u663e\u793a\u5904\u7406\u540e\u7684\u5e27 &#8212;<\/span><br \/>\n    cv<span class=\"token punctuation\">.<\/span>imshow<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Face Detection in Video&#034;<\/span><span class=\"token punctuation\">,<\/span> frame<span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token comment\"># &#8212; 6. \u8bbe\u7f6e\u9000\u51fa\u952e &#8212;<\/span><br \/>\n    <span class=\"token comment\"># \u7b49\u5f851\u6beb\u79d2&#xff0c;\u5982\u679c\u6309\u4e0b &#039;q&#039; \u952e&#xff0c;\u5219\u9000\u51fa\u5faa\u73af<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> cv<span class=\"token punctuation\">.<\/span>waitKey<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&amp;<\/span> <span class=\"token number\">0xFF<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token builtin\">ord<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;q&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">break<\/span><\/p>\n<p><span class=\"token comment\"># &#8212; 7. \u91ca\u653e\u8d44\u6e90 &#8212;<\/span><br \/>\ncap<span class=\"token punctuation\">.<\/span>release<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>          <span class=\"token comment\"># \u91ca\u653e\u89c6\u9891\u6355\u83b7\u5bf9\u8c61<\/span><br \/>\ncv<span class=\"token punctuation\">.<\/span>destroyAllWindows<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\"># \u5173\u95ed\u6240\u6709OpenCV\u521b\u5efa\u7684\u7a97\u53e3<\/span><\/p>\n<p><span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u89c6\u9891\u5904\u7406\u5b8c\u6210&#xff0c;\u8d44\u6e90\u5df2\u91ca\u653e\u3002&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<hr \/>\n<h3>&#x1f4dd; \u4e94\u3001\u603b\u7ed3\u4e0e\u5c55\u671b<\/h3>\n<p>\u901a\u8fc7\u672c\u6587&#xff0c;\u6211\u4eec\u5b66\u4e60\u4e86\u4f7f\u7528 OpenCV \u7684 Haar \u7ea7\u8054\u5206\u7c7b\u5668\u8fdb\u884c\u4eba\u8138\u68c0\u6d4b\u7684\u5b8c\u6574\u6d41\u7a0b&#xff1a;<\/p>\n<li>\u52a0\u8f7d\u56fe\u50cf\/\u89c6\u9891\u5e27 \u5e76\u5c06\u5176\u8f6c\u6362\u4e3a \u7070\u5ea6\u56fe\u3002<\/li>\n<li>\u5b9e\u4f8b\u5316 cv.CascadeClassifier \u5e76\u52a0\u8f7d\u9884\u8bad\u7ec3\u7684 .xml \u6a21\u578b\u6587\u4ef6\u3002<\/li>\n<li>\u8c03\u7528 detectMultiScale() \u65b9\u6cd5\u6267\u884c\u68c0\u6d4b&#xff0c;\u5e76\u8c03\u6574\u53c2\u6570\u4ee5\u5e73\u8861\u901f\u5ea6\u548c\u51c6\u786e\u7387\u3002<\/li>\n<li>\u904d\u5386\u68c0\u6d4b\u7ed3\u679c&#xff0c;\u5e76\u4f7f\u7528 cv.rectangle() \u5c06\u4eba\u8138\u6846\u9009\u51fa\u6765\u3002<\/li>\n<li>\u5728\u89c6\u9891\u5904\u7406\u4e2d&#xff0c;\u5faa\u73af\u5904\u7406\u6bcf\u4e00\u5e27 \u5e76\u8bb0\u5f97\u6700\u540e\u91ca\u653e\u8d44\u6e90\u3002<\/li>\n<p>\u867d\u7136 Haar \u7ea7\u8054\u5206\u7c7b\u5668\u901f\u5ea6\u5feb\u3001\u6613\u4e8e\u4f7f\u7528&#xff0c;\u4f46\u5b83\u4e5f\u6709\u4e00\u4e9b\u5c40\u9650\u6027&#xff0c;\u6bd4\u5982\u5bf9\u5149\u7167\u53d8\u5316\u3001\u4eba\u8138\u59ff\u6001\u548c\u906e\u6321\u6bd4\u8f83\u654f\u611f\u3002\u5728\u8ffd\u6c42\u66f4\u9ad8\u51c6\u786e\u7387\u7684\u573a\u666f\u4e0b&#xff0c;\u53ef\u4ee5\u63a2\u7d22\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u4eba\u8138\u68c0\u6d4b\u65b9\u6cd5&#xff0c;\u5982 MTCNN\u3001Dlib \u7684 HOG \u7279\u5f81\u68c0\u6d4b\u5668\u6216 OpenCV DNN \u6a21\u5757\u52a0\u8f7d\u7684\u9884\u8bad\u7ec3\u6a21\u578b&#xff08;\u5982 Caffe\u3001TensorFlow \u6a21\u578b&#xff09;&#xff0c;\u5b83\u4eec\u901a\u5e38\u80fd\u63d0\u4f9b\u66f4\u9c81\u68d2\u7684\u68c0\u6d4b\u6548\u679c\u3002<\/p>\n<h3>&#x1f4a1;\u516d\u3001\u53c2\u8003\u8d44\u6599<\/h3>\n<p>\u9ed1\u9a6c\u7a0b\u5e8f\u5458\u4eba\u5de5\u667a\u80fd\u6559\u7a0b_10\u5c0f\u65f6\u5b66\u4f1a\u56fe\u50cf\u5904\u7406OpenCV\u5165\u95e8\u6559\u7a0b<\/p>\n<hr \/>\n<p>\u611f\u8c22\u9605\u8bfb&#xff01;\u5982\u679c\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u6b22\u8fce\u70b9\u8d5e\u3001\u6536\u85cf\u5e76\u5173\u6ce8\u6211&#xff0c;\u6211\u4eec\u4e0b\u671f\u518d\u89c1&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f680; \u524d\u8a00<br \/>\n\u5728\u5f53\u4eca\u8fd9\u4e2aAI\u6280\u672f\u65e0\u5904\u4e0d\u5728\u7684\u65f6\u4ee3&#xff0c;\u4eba\u8138\u8bc6\u522b\u5df2\u7ecf\u6210\u4e3a\u4e00\u9879\u975e\u5e38\u666e\u53ca\u7684\u5e94\u7528&#xff0c;\u4ece\u624b\u673a\u89e3\u9501\u3001\u79fb\u52a8\u652f\u4ed8\u5230\u5b89\u9632\u76d1\u63a7&#xff0c;\u6211\u4eec\u6bcf\u5929\u90fd\u5728\u4e0e\u4e4b\u6253\u4ea4\u9053\u3002\u4f5c\u4e3a\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u6700\u7ecf\u5178\u7684\u5165\u95e8\u6848\u4f8b\u4e4b\u4e00&#xff0c;\u4f7f\u7528 OpenCV \u5b9e\u73b0\u4eba\u8138\u8bc6\u522b\u4e0d\u4ec5\u80fd\u8ba9\u6211\u4eec\u5feb\u901f\u4f53\u9a8c\u5230AI\u7684\u9b45\u529b&#xff0c;\u66f4\u80fd\u4e3a\u6df1\u5165\u5b66\u4e60\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002<br \/>\n\u672c\u6587\u5c06\u5e26\u9886\u5927\u5bb6\u4e00\u6b65\u6b65\u4e86\u89e3 OpenCV \u4e2d\u57fa\u4e8e Haar\u7279\u5f81\u7684\u7ea7\u8054\u5206\u7c7b\u5668 \u8fdb\u884c\u4eba\u8138\u68c0\u6d4b\u7684\u5b8c\u6574\u6d41\u7a0b\u3002\u6211\u4eec\u5c06\u4ece\u6838\u5fc3\u539f\u7406\u8bb2<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1460,50,523],"topic":[],"class_list":["post-73338","post","type-post","status-publish","format-standard","hentry","category-server","tag-opencv","tag-50","tag-523"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/73338.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f680; \u524d\u8a00 \u5728\u5f53\u4eca\u8fd9\u4e2aAI\u6280\u672f\u65e0\u5904\u4e0d\u5728\u7684\u65f6\u4ee3&#xff0c;\u4eba\u8138\u8bc6\u522b\u5df2\u7ecf\u6210\u4e3a\u4e00\u9879\u975e\u5e38\u666e\u53ca\u7684\u5e94\u7528&#xff0c;\u4ece\u624b\u673a\u89e3\u9501\u3001\u79fb\u52a8\u652f\u4ed8\u5230\u5b89\u9632\u76d1\u63a7&#xff0c;\u6211\u4eec\u6bcf\u5929\u90fd\u5728\u4e0e\u4e4b\u6253\u4ea4\u9053\u3002\u4f5c\u4e3a\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u6700\u7ecf\u5178\u7684\u5165\u95e8\u6848\u4f8b\u4e4b\u4e00&#xff0c;\u4f7f\u7528 OpenCV \u5b9e\u73b0\u4eba\u8138\u8bc6\u522b\u4e0d\u4ec5\u80fd\u8ba9\u6211\u4eec\u5feb\u901f\u4f53\u9a8c\u5230AI\u7684\u9b45\u529b&#xff0c;\u66f4\u80fd\u4e3a\u6df1\u5165\u5b66\u4e60\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002 \u672c\u6587\u5c06\u5e26\u9886\u5927\u5bb6\u4e00\u6b65\u6b65\u4e86\u89e3 OpenCV \u4e2d\u57fa\u4e8e Haar\u7279\u5f81\u7684\u7ea7\u8054\u5206\u7c7b\u5668 \u8fdb\u884c\u4eba\u8138\u68c0\u6d4b\u7684\u5b8c\u6574\u6d41\u7a0b\u3002\u6211\u4eec\u5c06\u4ece\u6838\u5fc3\u539f\u7406\u8bb2\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/73338.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-07T07:09:15+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/73338.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/73338.html\",\"name\":\"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-07T07:09:15+00:00\",\"dateModified\":\"2026-02-07T07:09:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/73338.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/73338.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/73338.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/73338.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f680; \u524d\u8a00 \u5728\u5f53\u4eca\u8fd9\u4e2aAI\u6280\u672f\u65e0\u5904\u4e0d\u5728\u7684\u65f6\u4ee3&#xff0c;\u4eba\u8138\u8bc6\u522b\u5df2\u7ecf\u6210\u4e3a\u4e00\u9879\u975e\u5e38\u666e\u53ca\u7684\u5e94\u7528&#xff0c;\u4ece\u624b\u673a\u89e3\u9501\u3001\u79fb\u52a8\u652f\u4ed8\u5230\u5b89\u9632\u76d1\u63a7&#xff0c;\u6211\u4eec\u6bcf\u5929\u90fd\u5728\u4e0e\u4e4b\u6253\u4ea4\u9053\u3002\u4f5c\u4e3a\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u6700\u7ecf\u5178\u7684\u5165\u95e8\u6848\u4f8b\u4e4b\u4e00&#xff0c;\u4f7f\u7528 OpenCV \u5b9e\u73b0\u4eba\u8138\u8bc6\u522b\u4e0d\u4ec5\u80fd\u8ba9\u6211\u4eec\u5feb\u901f\u4f53\u9a8c\u5230AI\u7684\u9b45\u529b&#xff0c;\u66f4\u80fd\u4e3a\u6df1\u5165\u5b66\u4e60\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002 \u672c\u6587\u5c06\u5e26\u9886\u5927\u5bb6\u4e00\u6b65\u6b65\u4e86\u89e3 OpenCV \u4e2d\u57fa\u4e8e Haar\u7279\u5f81\u7684\u7ea7\u8054\u5206\u7c7b\u5668 \u8fdb\u884c\u4eba\u8138\u68c0\u6d4b\u7684\u5b8c\u6574\u6d41\u7a0b\u3002\u6211\u4eec\u5c06\u4ece\u6838\u5fc3\u539f\u7406\u8bb2","og_url":"https:\/\/www.wsisp.com\/helps\/73338.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-07T07:09:15+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/73338.html","url":"https:\/\/www.wsisp.com\/helps\/73338.html","name":"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-07T07:09:15+00:00","dateModified":"2026-02-07T07:09:15+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/73338.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/73338.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/73338.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010OpenCV\u5165\u95e8\u3011\u8f7b\u677e\u638c\u63e1\u4eba\u8138\u8bc6\u522b\uff1a\u4ece\u56fe\u7247\u5230\u89c6\u9891\u7684Haar\u7ea7\u8054\u5206\u7c7b\u5668\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/73338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=73338"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/73338\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=73338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=73338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=73338"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=73338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}