{"id":3888,"date":"2017-08-31T21:37:01","date_gmt":"2017-08-31T12:37:01","guid":{"rendered":"https:\/\/www.chihayafuru.jp\/etrobo\/?p=3888"},"modified":"2017-08-31T22:13:53","modified_gmt":"2017-08-31T13:13:53","slug":"%e3%82%bf%e3%83%9f%e3%83%a4-%e3%82%ab%e3%83%a0%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0%e3%83%ad%e3%83%9c%e3%83%83%e3%83%88%e5%b7%a5%e4%bd%9c%e3%82%bb%e3%83%83%e3%83%88-machine-vision%e6%94%b9","status":"publish","type":"post","link":"https:\/\/www.chihayafuru.jp\/etrobo\/?p=3888","title":{"rendered":"\u30bf\u30df\u30e4 \u30ab\u30e0\u30d7\u30ed\u30b0\u30e9\u30e0\u30ed\u30dc\u30c3\u30c8\u5de5\u4f5c\u30bb\u30c3\u30c8 Machine Vision\u6539\u9020\u7de8"},"content":{"rendered":"<table>\n<tbody>\n<tr>\n<td><img decoding=\"async\" src=\"\/etrobo\/wp-content\/uploads\/2017\/08\/EyeRobot1.jpg\" alt=\"Eye Robot\"\/><\/td>\n<td><img decoding=\"async\" src=\"\/etrobo\/wp-content\/uploads\/2017\/08\/EyeRobot2.jpg\" alt=\"Eye Robot\"\/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"\/etrobo\/?p=3856\">\u524d\u56de<\/a>\u306fArduino Uno\u3092\u642d\u8f09\u3057\u30de\u30a4\u30b3\u30f3\u5316\u3092\u679c\u305f\u3057\u305f\u30ab\u30e0\u30d7\u30ed\u30b0\u30e9\u30e0\u30ed\u30dc\u30c3\u30c8\u3002<\/p>\n<p>\u3057\u304b\u3057\u30bf\u30a4\u30de\u30fc\u3092\u4f7f\u3063\u3066\u30b8\u30bf\u30d0\u30bf\u3055\u305b\u3066\u3044\u308b\u3060\u3051\u3067\u306f\u9000\u5c48\u3002\u305d\u3053\u3067\u3001\u30ed\u30dc\u30c3\u30c8\u306b\u3055\u3089\u306a\u308b\u9ad8\u5ea6\u306a\u6a5f\u80fd\u3092\u4ed8\u3051\u52a0\u3048\u307e\u3057\u305f\u3002<\/p>\n<p>\u6211\u3001\u30ed\u30dc\u30c3\u30c8\u306b\u300e\u6a5f\u68b0\u306e\u773c(Machine Vision)\u300f\u3092\u4e0e\u3048\u3093\uff01<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"\/etrobo\/wp-content\/uploads\/2017\/08\/OpenMV.jpg\" alt=\"OpenMV\"\/><\/p>\n<p>\u3042\u3089\u305f\u306b\u5165\u624b\u3057\u305f\u30e6\u30cb\u30c3\u30c8\u306f &quot;<a href=\"https:\/\/openmv.io\">OpenMV Cam M7<\/a>&quot; \uff01<\/p>\n<p>\u5927\u4eba\u306e\u590f\u4f11\u307f\u306e\u5de5\u4f5c\u306f\u8ca1\u306b\u7269\u3092\u8a00\u308f\u305b\u307e\u3059\u3002\u56fd\u5185\u4ee3\u7406\u5e97(<a href=\"https:\/\/www.switch-science.com\">\u30b9\u30a4\u30c3\u30c1\u30b5\u30a4\u30a8\u30f3\u30b9<\/a>)\u3055\u3093\u304b\u3089\u3001\u9001\u6599\u8fbc\u307f\u30679,750\u5186\uff01<\/p>\n<p>\u3057\u304b\u3057\u3001\u3053\u306e\u30ad\u30e3\u30e9\u30e1\u30eb\u7bb1\u304f\u3089\u3044\u306e\u5927\u304d\u3055\u306e\u30de\u30a4\u30b3\u30f3\u30e6\u30cb\u30c3\u30c8\u304c\u512a\u308c\u3082\u306e\u3067\u3059\u3002\u305f\u3060\u306e\u30c7\u30b8\u30bf\u30eb\u30ab\u30e1\u30e9\u30fb\u30e6\u30cb\u30c3\u30c8\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3053\u306e\u5c0f\u3055\u306a\u57fa\u677f\u306e\u4e0a\u3067\u56f3\u5f62\u8a8d\u8b58\u3084\u9854\u8a8d\u8b58\u3068\u3044\u3063\u305f\u9ad8\u5ea6\u306a\u753b\u50cf\u51e6\u7406\u3092\u5b9f\u884c\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p><a href=\"\/etrobo\/wp-content\/uploads\/2017\/08\/OpenMV_IDE.png\"><br \/>\n<img decoding=\"async\" src=\"\/etrobo\/wp-content\/uploads\/2017\/08\/OpenMV_IDE.png\" width=\"360px\" alt=\"OpenMV IDE\"\/><br \/>\n<\/a><\/p>\n<p>\u3053\u3061\u3089\u304c\u30d1\u30bd\u30b3\u30f3(Mac)\u3067\u5b9f\u884c\u3057\u305f\u958b\u767a\u74b0\u5883(OpenMV IDE)\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30ad\u30e3\u30d7\u30c1\u30e3\u30fc\u753b\u9762\u3067\u3059\u3002<\/p>\n<p>USB\u3067OpenMV\u3068\u63a5\u7d9a\u3057\u3066IDE\u304b\u3089\u30c7\u30d0\u30c3\u30b0\u5b9f\u884c\u3059\u308b\u3068\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u753b\u50cf\u51e6\u7406\u306e\u7d50\u679c\u304c\u898b\u3066\u53d6\u308c\u307e\u3059\u3002\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u5fae\u5999\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u8abf\u6574\u306f\u3053\u308c\u3067\u30d0\u30c3\u30c1\u30ea\u3002\u5b9f\u306fOpenMV\u306f\u30aa\u30fc\u30c8\u30d5\u30a9\u30fc\u30ab\u30b9\u6a5f\u80fd\u3092\u5099\u3048\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u3053\u306eIDE\u306e\u753b\u9762\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089\u30d4\u30f3\u30c8\u306e\u8abf\u6574\u3082\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/1tgD9vBAVPo?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>\u3053\u306eOpenMV Cam\u3092Arduino Uno\u3068GPIO\u3067\u63a5\u7d9a\u3057\u3066\u6a5f\u68b0\u306e\u773c\u3067\u4e8c\u6b21\u5143\u30de\u30fc\u30ab\u30fc\u3092\u8ffd\u8de1\u3059\u308b\u3088\u3046\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3057\u305f\u30c7\u30e2\u304c\u3053\u3061\u3089\u306e\u52d5\u753b\u306b\u306a\u308a\u307e\u3059\u3002\u4e8c\u6b21\u5143\u30de\u30fc\u30ab\u30fc\u3092\u30ed\u30dc\u30c3\u30c8\u306e\u30ab\u30e1\u30e9\u3067\u8a8d\u8b58\u3055\u305b\u3066\u3001\u5e38\u306b\u30ab\u30e1\u30e9\u306e\u4e2d\u592e\u306b\u30de\u30fc\u30ab\u30fc\u306e\u4f4d\u7f6e\u304c\u6765\u308b\u3088\u3046\u306b\u30ed\u30dc\u30c3\u30c8\u3092\u53f3\u3078\u5de6\u3078\u3068\u65cb\u56de\u3055\u305b\u3066\u3044\u307e\u3059\u3002\u306a\u306e\u3067\u4e00\u65e6\u30ed\u30dc\u30c3\u30c8\u306e\u30ab\u30e1\u30e9\u306e\u8996\u754c\u304b\u3089\u30de\u30fc\u30ab\u30fc\u304c\u5916\u308c\u3066\u3057\u307e\u3046\u3068\u8ffd\u3044\u304b\u3051\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u304f\u306a\u308b\u306e\u3067\u3059\u304c\u3001\u30de\u30fc\u30ab\u30fc\u304c\u30ab\u30e1\u30e9\u306b\u5199\u3063\u3066\u3044\u308b\u9593\u306f\u5e38\u306b\u8ffd\u3044\u7d9a\u3051\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306bOpenMV\u306fPWM\u51fa\u529b\u3082\u5099\u3048\u3066\u3044\u308b\u306e\u3067\u3001Arduino\u3092\u4ecb\u3055\u305a\u306b\u76f4\u63a5\u30e2\u30fc\u30bf\u30fc\u30c9\u30e9\u30a4\u30d0\u30fc\u3092\u99c6\u52d5\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u5f8c\u304b\u3089\u5f8c\u304b\u3089\u90e8\u54c1\u3092\u8ffd\u52a0\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u82e5\u5e72\u30d6\u30b5\u30a4\u30af\u306a\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3067\u3082\u30b1\u30fc\u30d6\u30eb\u304c\u7121\u99c4\u306b\u30af\u30cd\u30af\u30cd\u3057\u3066\u3044\u308b\u59ff\u3082\u88fd\u4f5c\u8005\u7684\u306b\u306f\u306a\u304b\u306a\u304b\u6c17\u306b\u5165\u3063\u3066\u3044\u307e\u3059\u3002 \ud83d\ude09<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:python decode:true \" title=\"tag_follower.py\" >import sensor, image, time, math\r\nfrom pyb import LED\r\nfrom pyb import Pin\r\n\r\nled_r = LED(1)\r\nled_g = LED(2)\r\nled_b = LED(3)\r\n\r\nsensor.reset()\r\nsensor.set_pixformat(sensor.RGB565)\r\nsensor.set_framesize(sensor.QQVGA) # we run out of memory if the resolution is much bigger...\r\nsensor.skip_frames(time = 2000)\r\nsensor.set_auto_gain(False)  # must turn this off to prevent image washout...\r\nsensor.set_auto_whitebal(False)  # must turn this off to prevent image washout...\r\nclock = time.clock()\r\n\r\nf_x = (2.8 \/ 3.984) * 160 # find_apriltags defaults to this if not set\r\nf_y = (2.8 \/ 2.952) * 120 # find_apriltags defaults to this if not set\r\nc_x = 160 * 0.5 # find_apriltags defaults to this if not set (the image.w * 0.5)\r\nc_y = 120 * 0.5 # find_apriltags defaults to this if not set (the image.h * 0.5)\r\n\r\ndef light_red():\r\n    led_r.on()\r\n    led_g.off()\r\n    led_b.off()\r\n\r\ndef light_green():\r\n    led_r.off()\r\n    led_g.on()\r\n    led_b.off()\r\n\r\ndef light_white():\r\n    led_r.on()\r\n    led_g.on()\r\n    led_b.on()\r\n\r\ndef light_off():\r\n    led_r.off()\r\n    led_g.off()\r\n    led_b.off()\r\n\r\npin_out_right = Pin('P0', Pin.OUT_PP)\r\npin_out_left  = Pin('P1', Pin.OUT_PP)\r\n\r\nwhile(True):\r\n    clock.tick()\r\n    img = sensor.snapshot()\r\n    num_of_tag = 0\r\n\r\n    for tag in img.find_apriltags(fx=f_x, fy=f_y, cx=c_x, cy=c_y): # defaults to TAG36H11\r\n        num_of_tag = num_of_tag + 1\r\n        img.draw_rectangle(tag.rect(), color = (255, 0, 0))\r\n        img.draw_cross(tag.cx(), tag.cy(), color = (0, 255, 0))\r\n        position = (tag.x_translation(), tag.y_translation(), -tag.z_translation())\r\n        print(\"x: %f, y %f, z %f\" % position)\r\n        x = tag.x_translation()\r\n        if (x &gt; 0.5):\r\n            light_red()\r\n            pin_out_right.low()\r\n            pin_out_left.high()\r\n        elif (x &gt; -0.5):\r\n            light_white()\r\n            pin_out_right.high()\r\n            pin_out_left.high()\r\n        else:\r\n            light_green()\r\n            pin_out_right.high()\r\n            pin_out_left.low()\r\n\r\n    if num_of_tag == 0:\r\n        light_off()\r\n        pin_out_right.high()\r\n        pin_out_left.high()\r\n<\/pre>\n<p>\u3053\u3061\u3089\u304cOpenMV\u306b\u66f8\u304d\u8fbc\u3093\u3060\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u3046\uff01 OpenMV\u306f MicroPython \u3067\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u958b\u767a\u3057\u307e\u3059\u3002<\/p>\n<p>IDE\u3067\u30c7\u30d0\u30c3\u30b0\u3059\u308b\u3068\u304d\u306f\u30b7\u30ea\u30a2\u30eb\u30fb\u30d7\u30ed\u30c8\u30b3\u30eb\u3067PC\u3068OpenMV\u304c\u63a5\u7d9a\u3055\u308c\u308b\u306e\u3067\u3059\u304c\u3001\u4e00\u65b9\u3067OpenMV\u306fUSB\u30b9\u30c8\u30ec\u30fc\u30b8\u3068\u3057\u3066\u3082\u30d1\u30bd\u30b3\u30f3\u304b\u3089\u898b\u3048\u3066\u3044\u307e\u3059\u3002\u3053\u306eUSB\u30b9\u30c8\u30ec\u30fc\u30b8\u306bmbed\u3068\u540c\u3058\u8981\u9818\u3067Python\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4fdd\u5b58\u3059\u308b\u3068\u3001\u30d1\u30bd\u30b3\u30f3\u3068\u5207\u308a\u96e2\u3057\u305f\u3068\u304dOpenMV\u5358\u4f53\u3067\u52d5\u4f5c\u3057\u307e\u3059\u3002<\/p>\n<p>\u968f\u5206\u3068\u7acb\u6d3e\uff1f\u306aPython\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u3044\u308b\u3088\u3046\u306b\u8aa4\u89e3\u3059\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001Python\u521d\u5fc3\u8005\u306e\u79c1\u304c\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3061\u3087\u3053\u3061\u3087\u3053\u3063\u3068\u624b\u76f4\u3057\u3057\u305f\u3060\u3051\u306e\u7c21\u5358\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002\u753b\u50cf\u51e6\u7406\uff08\u4e8c\u6b21\u5143\u30de\u30fc\u30ab\u30fc:AprilTag\uff09\u306e\u90e8\u5206\u306fOpenMV\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u96a0\u853d\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u79c1\u306f\u4f55\u306e\u77e5\u8b58\u3082\u306a\u304f\u3066\u3082\u5927\u4e08\u592b\u3067\u3057\u305f\u3002\u30ab\u30e1\u30e9\u306b\u5bfe\u3057\u3066\u4e8c\u6b21\u5143\u30de\u30fc\u30ab\u30fc\u306e\u4f4d\u7f6e\u304cXYZ\u8ef8\u3067\u8fd4\u3055\u308c\u3066\u6765\u308b\u306e\u3067\u3001X\u8ef8\uff08\u6c34\u5e73\u65b9\u5411\uff09\u306b\u5bfe\u3057\u3066\u30de\u30fc\u30ab\u30fc\u304c\u53f3\u306b\u3042\u308b\u306e\u304b\u5de6\u306b\u3042\u308b\u306e\u304b\u3060\u3051\u3092\u5358\u7d14\u306b\u6bd4\u8f03\u3057\u3066\u30ed\u30dc\u30c3\u30c8\u3092\u65cb\u56de\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5965\u884c\u304d\u306e\u60c5\u5831\uff08\u30ab\u30e1\u30e9\u3068\u30de\u30fc\u30ab\u30fc\u306e\u8ddd\u96e2\uff09\u3082\u53d6\u5f97\u3067\u304d\u3066\u3044\u308b\u306e\u3067\u3001\u30de\u30fc\u30ab\u30fc\u306b\u3064\u3044\u3066\u3044\u304f\u3053\u3068\u3082\u53ef\u80fd\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30c7\u30e2\u304c\u5374\u3063\u3066\u5927\u5909\u305d\u3046\u306a\u306e\u3067\u3001\u5b9a\u4f4d\u7f6e\u3067\u5de6\u53f3\u306b\u65cb\u56de\u3055\u305b\u3066\u3044\u307e\u3059\u3002\u3067\u3082\u3001\u3053\u308c\u3060\u3051\u306e\u52d5\u4f5c\u3067\u3082\u30da\u30c3\u30c8\u306e\u3088\u3046\u306a\u52d5\u304d\u3067\u611b\u7740\u304c\u6e67\u3044\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3072\u3068\u307e\u305a\uff18\u6708\uff13\uff11\u65e5\u306b\u9593\u306b\u5408\u3063\u305f\u5927\u4eba\u306e\u81ea\u7531\u7814\u7a76\u306e\u5831\u544a\u3067\u3059\u3002 \ud83d\ude00<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306fArduino Uno\u3092\u642d\u8f09\u3057\u30de\u30a4\u30b3\u30f3\u5316\u3092\u679c\u305f\u3057\u305f\u30ab\u30e0\u30d7\u30ed\u30b0\u30e9\u30e0\u30ed\u30dc\u30c3\u30c8\u3002 \u3057\u304b\u3057\u30bf\u30a4\u30de\u30fc\u3092\u4f7f\u3063\u3066\u30b8\u30bf\u30d0\u30bf\u3055\u305b\u3066\u3044\u308b\u3060\u3051\u3067\u306f\u9000\u5c48\u3002\u305d\u3053\u3067\u3001\u30ed\u30dc\u30c3\u30c8\u306b\u3055\u3089\u306a\u308b\u9ad8\u5ea6\u306a\u6a5f\u80fd\u3092\u4ed8\u3051\u52a0\u3048\u307e\u3057\u305f\u3002 \u6211\u3001\u30ed\u30dc\u30c3\u30c8\u306b\u300e\u6a5f\u68b0\u306e\u773c(M &hellip; <a href=\"https:\/\/www.chihayafuru.jp\/etrobo\/?p=3888\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[36],"class_list":["post-3888","post","type-post","status-publish","format-standard","hentry","category-technical","tag-openmv"],"_links":{"self":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts\/3888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3888"}],"version-history":[{"count":33,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts\/3888\/revisions"}],"predecessor-version":[{"id":3921,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=\/wp\/v2\/posts\/3888\/revisions\/3921"}],"wp:attachment":[{"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/etrobo\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}