{"id":6250,"date":"2020-03-20T01:52:55","date_gmt":"2020-03-19T16:52:55","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=6250"},"modified":"2020-03-20T08:00:53","modified_gmt":"2020-03-19T23:00:53","slug":"python%e3%81%ae%e6%a9%9f%e6%a2%b0%e5%ad%a6%e7%bf%92%e3%81%a7%e7%89%a9%e4%bd%93%e3%82%92%e6%8e%a2%e3%81%97%e5%87%ba%e3%81%99%e3%80%90%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89%e5%8f%af","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=6250","title":{"rendered":"Python\u306e\u6a5f\u68b0\u5b66\u7fd2\u3067\u7269\u4f53\u3092\u63a2\u3057\u51fa\u3059\u3010\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\u3011"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3053\u308c\u307e\u3067\u79c1\u304c\u7d4c\u9a13\u3057\u3066\u304d\u305f\u5185\u5bb9\u3092\u591a\u304f\u516c\u958b\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u30b9\u30ad\u30eb\u30a2\u30c3\u30d7\u306e\u305f\u3081\u306b\u3042\u307e\u308a\u7d4c\u9a13\u304c\u306a\u3044\u5206\u91ce\u3082\u53d6\u308a\u6271\u3046\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u306f\u305d\u306e\u4e2d\u304b\u3089\u3042\u308b\u4e8b\u306b\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u5185\u5bb9\u306f\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u5199\u771f\u306e\u4e2d\u304b\u3089\u7279\u5b9a\u306e\u7269\u4f53\u3092\u63a2\u3057\u51fa\u3059\u300c\u7269\u4f53\u691c\u51fa\u300d<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u300c<strong>\u7269\u4f53\u691c\u51fa<\/strong>\u300d\u3068\u3044\u3046\u3068\u3061\u3087\u3063\u3068\u96e3\u3057\u304f\u805e\u3053\u3048\u307e\u3059\u304c\u3001\u7c21\u5358\u306b\u8a00\u3046\u3068\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">\u3053\u306e\u5199\u771f\u306b\u300c\u30a2\u30ec\u300d\u5199\u3063\u3066\u308b\u2753\u2753<\/strong><\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u300c<strong>\u30a2\u30ec<\/strong>\u300d\u306f\u4f55\u3067\u3082OK\u3067\u3001\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u72ac<\/li>\n<li>\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad<\/li>\n<li>\u4f1a\u793e\u306e\u30ed\u30b4<\/li>\n<\/ul>\n<p>\u306a\u3069\u306a\u3069\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u79c1\u304c\u597d\u304d\u306a\u300c\u30d3\u30fc\u30eb\ud83c\udf7a\u300d\u3092\u4f8b\u306b\u3057\u3066\u6a5f\u68b0\u5b66\u7fd2\u3092\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728\uff08\u6700\u5f8c\u306b\u4eca\u56de\u306b\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u6a5f\u68b0\u5b66\u7fd2\u306b\u5fc5\u8981\u306a\u753b\u50cf\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2173 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png\" alt=\"\" width=\"300\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24-281x300.png 281w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Python 2.7<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u3044\u304f\u3064\u304b\u7528\u610f\u3057\u305f\u5199\u771f\u306e\u4e2d\u304b\u3089\u3001\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u304c\u5199\u3063\u3066\u3044\u308b\u304b\u3092\u8abf\u3079\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3082\u3057\u767a\u898b\u3057\u305f\u3089\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u306e\u90e8\u5206\u3092\u5207\u308a\u629c\u3044\u3066\u300c<strong>lets-drink-*.jpg<\/strong>\u300d\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u3084\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>\u7269\u4f53\u691c\u51fa\u3059\u308b\u624b\u9806<\/h1>\n<p>\u7269\u4f53\u691c\u51fa\u3092\u3059\u308b\u306b\u306f\u3001\u6a5f\u68b0\u5b66\u7fd2\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001\u4eca\u56de\u306e\u624b\u9806\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u304c\u5199\u3063\u3066\u3044\u308b\u5199\u771f\u3092\u7528\u610f\u3059\u308b<\/li>\n<li>\u305d\u306e\u5199\u771f\u306e\u3069\u3053\u306b\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u304c\u3042\u308b\u304b\u3092\u6307\u5b9a\u3059\u308b<\/li>\n<li>\u6a5f\u68b0\u5b66\u7fd2\u3057\u3066\u300c\u5b66\u7fd2\u30c7\u30fc\u30bf\u300d\u3092\u3064\u304f\u308b<\/li>\n<\/ol>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u300c\u5b66\u7fd2\u30c7\u30fc\u30bf\u300d\u3092\u4f7f\u3063\u3066\uff08\u5168\u304f\u5225\u306e\uff09\u5199\u771f\u306e\u4e2d\u306b\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u304c\u5199\u3063\u3066\u3044\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<h1>\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u307e\u305a\u3001\u4eca\u56de\u306e\u6a5f\u80fd\u3067\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>pip install dlib\r\n<\/strong><\/pre>\n<pre><strong>pip install opencv-python<\/strong><\/pre>\n<p>\u203b\u3082\u3057<code>CMake must be installed to build the following extensions: dlib<\/code>\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u5834\u5408<code>cmake<\/code>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304b\u3089\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u6a5f\u68b0\u5b66\u7fd2\u3059\u308b<\/h1>\n<p>\u3067\u306f\u3001\u6a5f\u68b0\u5b66\u7fd2\u3067\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u3092\u691c\u51fa\u3059\u308b\u300c<strong>\u5b66\u7fd2\u30c7\u30fc\u30bf<\/strong>\u300d\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u5199\u771f\u3092\u7528\u610f\u3059\u308b<\/h2>\n<p>\u306f\u3058\u3081\u306b\u3001\u5b66\u7fd2\u3055\u305b\u308b\u5199\u771f\u3092\u7528\u610f\u3057\u3066\u3001<code>\/images\/train<\/code>\u30d5\u30a9\u30eb\u30c0\u306b\u8a2d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6264\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_10.png\" alt=\"\" width=\"520\" height=\"129\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_10.png 520w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_10-300x74.png 300w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/p>\n<p>\u3055\u3059\u304c\u306b\uff11\u679a\u3060\u3051\u3067\u306f\u6a5f\u68b0\u5b66\u7fd2\u3055\u305b\u308b\u306b\u306f\u5c11\u306a\u3059\u304e\u307e\u3059\u306e\u3067\u3001\u6700\u4f4e\u3067\u30825\u301c10\u679a\u7a0b\u5ea6\u306f\u7528\u610f\u3057\u305f\u65b9\u304c\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u3053\u3053\u306f\u6a5f\u68b0\u5b66\u7fd2\u306e\u96e3\u3057\u3044\u3068\u3053\u308d\u3067\u3059\u304c\u3001\u6570\u304c\u591a\u3051\u308c\u3070\u3044\u3044\u3068\u3044\u3046\u3082\u306e\u3067\u306f\u306a\u304f\u3001\u4f3c\u3066\u308b\u5199\u771f\u3070\u304b\u308a\u3060\u3068\u5b66\u7fd2\u304c\u504f\u3063\u3066\u3057\u307e\u3044\u300c<strong>\u3053\u308c\u3057\u304b\u30c0\u30e1\uff01<\/strong>\u300d\u3068\u3044\u3046\u3088\u3046\u306b\u300c<strong>\u9811\u56fa\u306a\u30c7\u30fc\u30bf<\/strong>\u300d\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u9069\u5ea6\u306a\u6570\u3001\u9069\u5ea6\u306a\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u5b66\u7fd2\u3059\u308b\u30c7\u30fc\u30bf\u304c\u63c3\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u306f<a href=\"#download\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/a>\u304b\u3089\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u306e\u753b\u50cf\u3082\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u306e\u3067\u3001\u305d\u3061\u3089\u3092\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u3069\u3053\u306b\u76ee\u7684\u306e\u7269\u4f53\u304c\u3042\u308b\u304b\u304c\u5206\u304b\u308b\u30c7\u30fc\u30bf\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3044\u308d\u3044\u308d\u3068\u65b9\u6cd5\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e0d\u8981\u3067\u6a5f\u68b0\u5b66\u7fd2\u306b\u5fc5\u8981\u306a<code>xml<\/code>\u3092\u3064\u304f\u308b\u3053\u3068\u304c\u3067\u304d\u308b<a href=\"https:\/\/imglab.in\/\" target=\"_blank\" rel=\"noopener noreferrer\">ImgLab<\/a>\u3068\u3044\u3046\u30b5\u30a4\u30c8\u3092\u4f7f\u308f\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002\uff08\u611f\u8b1d\ud83d\ude0a\u2728\uff09<\/p>\n<p>\u307e\u305a\u3053\u306e\u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u300c<strong>UUM! MAY BE NEXT TIME.<\/strong>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002\uff08\u52df\u91d1\u3057\u3066\u304f\u308c\u3001\u3068\u3044\u3046\u306e\u3092\u65ad\u3063\u3066\u3044\u307e\u3059\ud83d\ude05\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6261\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_1.png\" alt=\"\" width=\"640\" height=\"433\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_1.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_1-300x203.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u30da\u30fc\u30b8\u5de6\u4e0b\u306b\u753b\u50cf\u3092\u9078\u629e\u3059\u308b\u30a2\u30a4\u30b3\u30f3\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u3053\u3053\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6260\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_2.png\" alt=\"\" width=\"198\" height=\"215\" \/><\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3059\u308b\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001<code>\/images\/train<\/code>\u306b\u7528\u610f\u3057\u305f\u5168\u3066\u306e\u5199\u771f\u3092\u9078\u629e\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6259\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_3.png\" alt=\"\" width=\"600\" height=\"312\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_3.png 600w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_3-300x156.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u9078\u629e\u3057\u305f\u753b\u50cf\u304c\u30da\u30fc\u30b8\u4e0b\u90e8\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002\uff08\u30b5\u30e0\u30cd\u30a4\u30eb\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u753b\u50cf\u3092\u62e1\u5927\u8868\u793a\u3067\u304d\u307e\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6258\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_4.png\" alt=\"\" width=\"640\" height=\"65\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_4.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_4-300x30.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u6b21\u306b\u3001\u9078\u629e\u3057\u305f\u5199\u771f\u306e\u300c<strong>\u3069\u3053\u306b\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u304c\u6620\u3063\u3066\u3044\u308b\u304b\uff1f<\/strong>\u300d\u3092\u6307\u5b9a\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u30da\u30fc\u30b8\u5de6\u306b\u3042\u308b\u300c<strong>Rectangle<\/strong>\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30c9\u30e9\u30c3\u30b0\u30fb\u30a2\u30f3\u30c9\u30fb\u30c9\u30ed\u30c3\u30d7\u3067\u7bc4\u56f2\u6307\u5b9a\u3057\u307e\u3059\u3002\uff08\u306a\u304a\u3001\u753b\u50cf\u304c\u5927\u304d\u3059\u304e\u308b\u5834\u5408\u306f\u30ba\u30fc\u30e0\u3067\u5c0f\u3055\u304f\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6257\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_5.png\" alt=\"\" width=\"450\" height=\"547\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_5.png 450w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_5-247x300.png 247w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/p>\n<p>\u5168\u3066\u306e\u753b\u50cf\u306e\u7bc4\u56f2\u6307\u5b9a\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u30da\u30fc\u30b8\u5de6\u4e0a\u306b\u3042\u308b\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u30dc\u30bf\u30f3\u304b\u3089\u300c<strong>Save<\/strong>\u300d\u3092\u9078\u629e\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6256\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_6.png\" alt=\"\" width=\"195\" height=\"233\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306a\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u304c\u51fa\u308b\u306e\u3067\u300c<strong>Dlib XML<\/strong>\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6255\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_7.png\" alt=\"\" width=\"337\" height=\"354\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_7.png 337w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_7-286x300.png 286w\" sizes=\"auto, (max-width: 337px) 100vw, 337px\" \/><\/p>\n<p>\u6b21\u306b\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u300c<strong>beer.xml<\/strong>\u300d\u306b\u3057\u3066\u300c<strong>SAVE<\/strong>\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002\uff08\u3082\u3061\u308d\u3093\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u4f55\u3067\u3082OK\u3067\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6254\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_8.png\" alt=\"\" width=\"343\" height=\"151\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_8.png 343w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_8-300x132.png 300w\" sizes=\"auto, (max-width: 343px) 100vw, 343px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u300c<strong>beer.xml<\/strong>\u300d\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u308b\u306e\u3067\u3001<code>\/images\/train<\/code>\u30d5\u30a1\u30eb\u30c0\u306b\u8a2d\u7f6e\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6262\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_9.png\" alt=\"\" width=\"471\" height=\"126\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_9.png 471w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_9-300x80.png 300w\" sizes=\"auto, (max-width: 471px) 100vw, 471px\" \/><\/p>\n<h2>\u5b66\u7fd2\u7528\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3064\u304f\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u3001\u5b9f\u969b\u306b\u6a5f\u68b0\u5b66\u7fd2\u3092\u3059\u308b\u305f\u3081\u306e<code>Python<\/code>\u30b3\u30fc\u30c9\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n\u3068\u3044\u3063\u3066\u3082\u3001\u30b3\u30fc\u30c9\u81ea\u4f53\u306f\u3068\u3066\u3082\u7c21\u5358\u3067\u3059\u306e\u3067\u4ee5\u4e0b\u3092\u30b3\u30d4\u30da\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong><code>\/train.py<\/code><\/strong><\/p>\n<pre>import dlib\r\n\r\nif __name__ == \"__main__\":\r\n\r\n    train_xml = \".\/images\/train\/beer.xml\"\r\n    svm_file = \"beer.svm\"\r\n    options = dlib.simple_object_detector_training_options()\r\n    dlib.train_simple_object_detector(train_xml, svm_file, options)<\/pre>\n<h2>\u6a5f\u68b0\u5b66\u7fd2\u3092\u5b9f\u884c\u3059\u308b<\/h2>\n<p>\u3067\u306f\u3001<code>train.py<\/code>\u3092\u5b9f\u884c\u3057\u3066\u6a5f\u68b0\u5b66\u7fd2\u3092\u3057\u307e\u3057\u3087\u3046\uff01<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>python train.py<\/strong><\/pre>\n<p>\u5b9f\u884c\u304c\u5b8c\u4e86\u3059\u308b\u3068\u3001<code>beer.svm<\/code>\u3068\u3044\u3046\u5b66\u7fd2\u30c7\u30fc\u30bf\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6266\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_12.png\" alt=\"\" width=\"365\" height=\"119\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_12.png 365w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_12-300x98.png 300w\" sizes=\"auto, (max-width: 365px) 100vw, 365px\" \/><\/p>\n<h1>\u7269\u4f53\u691c\u51fa\u3059\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b66\u7fd2\u30c7\u30fc\u30bf\u3092\u3064\u304f\u3063\u305f\u306e\u3067\u3001\u3053\u3053\u304b\u3089\u306f\u5b9f\u969b\u306b\u7269\u4f53\u691c\u51fa\u3092\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u5199\u771f\u3092\u7528\u610f\u3059\u308b<\/h2>\n<p>\u4eca\u56de\u306f\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u306e\u5b66\u7fd2\u30c7\u30fc\u30bf\u306a\u306e\u3067\u3001\u6b63\u89e3\u306e\u5199\u771f\u3092\uff12\u679a\u3060\u3051\u7528\u610f\u3057\u3066<code>\/images\/detection<\/code>\u306b\u8a2d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6267\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_13.png\" alt=\"\" width=\"486\" height=\"228\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_13.png 486w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_13-300x141.png 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/p>\n<h2>\u7269\u4f53\u691c\u51fa\u3059\u308b\u30b3\u30fc\u30c9\u3092\u3064\u304f\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u3001<code>Python<\/code>\u30b3\u30fc\u30c9\u3067\u3059\u3002<br \/>\n\u3053\u3061\u3089\u3082\u30b3\u30d4\u30da\u3067OK\u3067\u3059\u3002<\/p>\n<p><strong><code>\/detection.py<\/code><\/strong><\/p>\n<pre>import dlib\r\nimport cv2\r\nimport sys\r\nimport glob\r\nimport os\r\n\r\nif __name__ == \"__main__\":\r\n\r\n    detector = dlib.simple_object_detector('beer.svm')\r\n    files = glob.glob('images\/detection\/*.jpg')\r\n\r\n    loop = 1\r\n    for file in files:\r\n        print('[Detecting]: '+ file)\r\n        img = cv2.imread(file)\r\n        rectangles = detector(img)\r\n        for rect in rectangles:\r\n            print('Found beer!')\r\n            print(rect);\r\n            x = rect.left()\r\n            y = rect.top()\r\n            w = rect.width()\r\n            h = rect.height()\r\n            cv2.imwrite('lets-drink-'+ str(loop) +'.jpg', img[y:y+h, x:x+w]);\r\n            loop += 1<\/pre>\n<p>\u5185\u5bb9\u3068\u3057\u3066\u306f\u3001\u300c<strong>\u5199\u771f\u306e\u4e2d\u306b\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u304c\u3042\u308b\u304b\uff1f<\/strong>\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3001\u3082\u3057\u5b58\u5728\u3057\u3066\u3044\u305f\u3089\u305d\u306e\u5ea7\u6a19\u90e8\u5206\u3092\u5207\u308a\u51fa\u3057\u3066\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u30d3\u30fc\u30eb\u304c\u5199\u771f\u304c\u898b\u3064\u304b\u3063\u305f\u3089\u300c<strong>Found beer!<\/strong>\u300d\u3068\u8868\u793a\u3055\u308c\u307e\u3059\ud83d\ude0a\u2728<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b<code>detection.py<\/code>\u3092\u5b9f\u884c\u3057\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<pre><strong>python detection.py<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u306b\u306a\u308a\u307e\u3057\u305f\u3002\uff08\uff12\u3064\u3068\u3082\u691c\u51fa\u3067\u304d\u307e\u3057\u305f\uff09<\/p>\n<pre>[Detecting]: images\/detection\/akashiyaki.jpg\r\n[Detecting]: images\/detection\/sunflower_seeds.jpg\r\n[Detecting]: images\/detection\/beer_1.jpg\r\n<strong>Found beer!\r\n[(56, 56) (627, 841)]<\/strong>\r\n[Detecting]: images\/detection\/beer_2.jpg\r\n<strong>Found beer!\r\n[(206, 206) (2251, 3018)]<\/strong>\r\n[Detecting]: images\/detection\/hamburger.jpg\r\n[Detecting]: images\/detection\/bechstein_piano.jpg<\/pre>\n<p>\u305d\u3057\u3066\u3001\u691c\u51fa\u3057\u305f\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u304c\u5207\u308a\u51fa\u3055\u308c\u3066\u3053\u306e\u3088\u3046\u306b\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6270\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_14.png\" alt=\"\" width=\"367\" height=\"122\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_14.png 367w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/object_detection_14-300x100.png 300w\" sizes=\"auto, (max-width: 367px) 100vw, 367px\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\ud83d\ude0a\u2728<\/p>\n<h1 id=\"download\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u5b9f\u969b\u306b\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u753b\u50cf\u3082\u5168\u3066\u5165\u3063\u3066\u3044\u307e\u3059\uff09<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=6272&amp;tmstv=1777530780\" rel=\"nofollow\" id=\"download-link-6272\" data-redirect=\"false\" >\n\t\u3010Python\u3011\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u691c\u51fa<\/a>\n\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u6a5f\u68b0\u5b66\u7fd2\u3067\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u3092\u691c\u51fa\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5192\u982d\u3067\u3082\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u30d3\u30fc\u30eb\u30b8\u30e7\u30c3\u30ad\u306b\u9650\u3089\u305a\u3042\u306a\u305f\u304c\u597d\u304d\u306a\u7269\u4f53\u3067\u8a66\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u904e\u53bb\u306b\u306f\u3001\u3042\u308b\u4f1a\u793e\u306e\u5546\u54c1\u753b\u50cf\u306b\u30ed\u30b4\u304c\u5165\u3063\u3066\u3044\u308b\u3082\u306e\u3068\u5165\u3063\u3066\u3044\u306a\u3044\u3082\u306e\u304c\u5171\u5b58\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u6a5f\u68b0\u5b66\u7fd2\u3067\u5165\u3063\u3066\u3044\u306a\u3044\u3082\u306e\u3060\u3051\u63a2\u3057\u51fa\u3059\u3068\u3044\u3046\u8a18\u4e8b\u3092\u8aad\u3093\u3060\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300c<strong>\u306a\u308b\u307b\u3069\u3001\u305d\u3046\u3044\u3046\u4f7f\u3044\u65b9\u3082\u3042\u308b\u306e\u304b\uff01<\/strong>\u300d<\/p>\n<p>\u3068\u95a2\u5fc3\u3057\u305f\u306e\u3067\u3059\u304c\u3001AI\u3084\u6a5f\u68b0\u5b66\u7fd2\u3068\u3044\u3063\u3066\u3082\u7d50\u5c40\u306f\u4eba\u9593\u306e\u5de5\u592b\u304c\u5927\u4e8b\u3060\u3068\u3044\u3046\u3053\u3068\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u9762\u767d\u3044\u30a2\u30a4\u30c7\u30a2\u306b\u5fdc\u7528\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6070 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_5.png\" alt=\"\" width=\"260\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_5.png 260w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_5-244x300.png 244w\" sizes=\"auto, (max-width: 260px) 100vw, 260px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3053\u308c\u307e\u3067\u79c1\u304c\u7d4c\u9a13\u3057\u3066\u304d\u305f\u5185\u5bb9\u3092\u591a\u304f\u516c\u958b\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u30b9\u30ad\u30eb\u30a2\u30c3\u30d7\u306e\u305f\u3081\u306b\u3042\u307e\u308a\u7d4c\u9a13\u304c\u306a\u3044\u5206\u91ce\u3082\u53d6\u308a\u6271\u3046\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002 \u305d\u3057\u3066\u3001\u4eca &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=6250\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Python\u306e\u6a5f\u68b0\u5b66\u7fd2\u3067\u7269\u4f53\u3092\u63a2\u3057\u51fa\u3059\u3010\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\u3011&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":6280,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,97],"tags":[40],"class_list":["post-6250","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-97","tag-40"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6250"}],"version-history":[{"count":12,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6250\/revisions"}],"predecessor-version":[{"id":6284,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6250\/revisions\/6284"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/6280"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}