{"id":95,"date":"2021-06-16T08:05:13","date_gmt":"2021-06-15T23:05:13","guid":{"rendered":"https:\/\/chiguvacation.wordpress.com\/?p=95"},"modified":"2021-06-16T08:05:13","modified_gmt":"2021-06-15T23:05:13","slug":"opencv%e3%82%92%e7%94%a8%e3%81%84%e3%81%a6%e3%82%ab%e3%83%b3%e3%82%bf%e3%83%b3%e9%a1%94%e8%aa%8d%e8%ad%98%ef%bc%88python%ef%bc%89","status":"publish","type":"post","link":"https:\/\/smartlife123.tech\/?p=95","title":{"rendered":"OpenCV\u3092\u7528\u3044\u3066\u30ab\u30f3\u30bf\u30f3\u9854\u8a8d\u8b58\uff08Python\uff09"},"content":{"rendered":"\n<p>\u30e9\u30a4\u30d6\u30e9\u30ea\u300cOpenCV\u300d\u3092\u4f7f\u3063\u3066\u3001\u9854\u8a8d\u8b58\u3092\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport cv2\n\n# \u5165\u529b\u753b\u50cf\u306e\u8aad\u307f\u8fbc\u307f\nimage_file = &quot;cross.jpg&quot;\nimage_path = &quot;.\/inputs\/&quot; + image_file\noutput_path = &quot;.\/outputs\/&quot; + image_file\n\nimg = cv2.imread(image_path)\n\n# \u30ab\u30b9\u30b1\u30fc\u30c9\u578b\u8b58\u5225\u5668\u306e\u8aad\u307f\u8fbc\u307f\ncascade = cv2.CascadeClassifier(\n    &quot;~~\\lbpcascade_animeface.xml&quot;)\n\n# \u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u5909\u63db\ngray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n\n# \u30a2\u30cb\u30e1\u9854\u9818\u57df\u306e\u63a2\u7d22\nface = cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3, minSize=(30, 30))\n\n# \u9854\u9818\u57df\u3092\u8d64\u8272\u306e\u77e9\u5f62\u3067\u56f2\u3080\nfor (x, y, w, h) in face:\n    cv2.rectangle(img, (x, y), (x + w, y+h), (0, 0, 200), 3)\n\n# \u7d50\u679c\u3092\u51fa\u529b\ncv2.imwrite(output_path, img)\n<\/pre><\/div>\n\n\n<p>\u4eca\u56de\u306f\u30a4\u30e9\u30b9\u30c8\u304b\u3089\u9854\u3092\u8b58\u5225\u3059\u308b\u3053\u3068\u304b\u3089\u3001<a href=\"https:\/\/github.com\/nagadomi\/lbpcascade_animeface\">https:\/\/github.com\/nagadomi\/lbpcascade_animeface<\/a>\u306b\u3066\u516c\u958b\u3055\u308c\u3066\u3044\u308blbpcascade_animeface.xml\u3092\u7528\u3044\u3066\u691c\u51fa\u5668\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3000\u4ee5\u4e0b\u5b9f\u884c\u7d50\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1500\" height=\"1027\" src=\"http:\/\/smartlife123.tech\/wp-content\/uploads\/2021\/06\/summer-1.jpg?w=1024\" alt=\"\" class=\"wp-image-102\" \/><figcaption class=\"wp-element-caption\">\u9854\u691c\u51fa\uff11<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"868\" height=\"1280\" src=\"http:\/\/smartlife123.tech\/wp-content\/uploads\/2021\/06\/ab-1.png?w=694\" alt=\"\" class=\"wp-image-103\" \/><figcaption class=\"wp-element-caption\">\u9854\u691c\u51fa\uff12<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"990\" height=\"990\" data-id=\"98\" src=\"http:\/\/smartlife123.tech\/wp-content\/uploads\/2021\/06\/cross.jpg?w=990\" alt=\"\" class=\"wp-image-98\" \/><\/figure>\n<figcaption class=\"blocks-gallery-caption wp-element-caption\">\u9854\u691c\u51fa\uff13<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\u3044\u3044\u611f\u3058\uff01<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u53c2\u8003\u306b\u3055\u305b\u3066\u9802\u3044\u305f\u30b5\u30a4\u30c8\uff1a<a href=\"https:\/\/qiita.com\/mczkzk\/items\/fda37ac4f9ddab2d7f45\">https:\/\/qiita.com\/mczkzk\/items\/fda37ac4f9ddab2d7f45<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30e9\u30a4\u30d6\u30e9\u30ea\u300cOpenCV\u300d\u3092\u4f7f\u3063\u3066\u3001\u9854\u8a8d\u8b58\u3092\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u4eca\u56de\u306f\u30a4\u30e9\u30b9\u30c8\u304b\u3089\u9854\u3092\u8b58\u5225\u3059\u308b\u3053\u3068\u304b\u3089\u3001https:\/\/github.com\/nagadomi\/lbpcascade_animeface\u306b\u3066\u516c\u958b\u3055\u308c\u3066\u3044\u308blb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":101,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[3,6,10,12],"class_list":["post-95","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-3","tag-6","tag-10","tag-12"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/smartlife123.tech\/wp-content\/uploads\/2021\/06\/summer.jpg","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=95"}],"version-history":[{"count":0,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/media\/101"}],"wp:attachment":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}