Changes between Version 36 and Version 37 of VisionFramework
- Timestamp:
- Nov 25, 2017, 12:12:48 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
VisionFramework
v36 v37 1 1 = Vision Framework = 2 3 Mentors: Joy Cho 4 5 Students: Reid Huntley, Benji Albert, Nathan Misner 6 7 == Background == 8 In 2015-2017, team 2537 developed a machine vision platform for autonomous targeting and navigation. It was first used successfully during the 2016-2017 season and helped the team reach the finals at the world championship. The vision platform is based on the [https://www.raspberrypi.org/products/raspberry-pi-3-model-b/ Raspberry Pi 3] with [https://www.raspberrypi.org/products/camera-module-v2/ camera module] in a [https://www.amazon.com/Distributed-MCM-83-17540-Enclosure-Raspberry/dp/B01KGTD3I0 clear case]. The 2016-2017 version used an [https://www.amazon.com/eBoot-MP1584EN-Converter-Adjustable-Module/dp/B01MQGMOKI MP1584EN power supply] to convert the 12v battery voltage to the 5v required for the machine vision hardware. It also included a transistor switch to allow the Pi to control power to a [http://www.andymark.com/product-p/am-3597.htm green 12v LED light ring]. Communication between the Pi and roboRIO was uni-directional using PWM. 9 2 10 == Objective == 3 Create a reprogrammable module in which a Raspberry Pi 3, protective case, power cable, light ring, and camera are self contained and execute a base program on startup. The base code of the module continuously reads the camera feed (subscribes to camera) and publishes corresponding data via the Pi's serial output (located on the Pi's GPIO connector). This data can then be fairly simply read by the RoboRIO. We hope that this will make implementing a vision subsystem a more simple proposition, allowing more teams to do so. 4 ---- 5 ---- 6 ---- 7 ---- 11 Extend the vision module to make it more accessible to other teams and more user friendly generally. Changes planned for the 2017-2018 season include: 12 * Execute a base program on startup that continuously reads the camera feed (subscribes to camera) and publishes corresponding data via the Pi's serial output (located on the Pi's GPIO connector). This data can then be fairly simply read by the RoboRIO. 13 * Replace the 12v monochrome LED ring with a smart Neopixel-compatible 12x RGB LED light ring based on the WS2812 controller. This will allow the module to run entirely from 5vdc and provide teams with the ability to select their light-ring color and even make some fancy light shows. Smart light rings are available from [https://www.adafruit.com/product/1643 adafruit] and [https://www.ebay.com/itm/12Bit-WS2812-5050-RGB-LED-Ring-Strip-Integrated-Drivers-for-Arduino-Module/391717334432 eBay] among other sources. You can read about the neopixels [https://learn.adafruit.com/neopixels-on-raspberry-pi/overview here]. Neopixel control can be achieved using many libraries including [http://diozero.readthedocs.io/en/stable/ diozero]; see also [http://rtd.diozero.com/en/latest/LEDStrips/ here] 14 8 15 == Materials == 9 * Clear Case10 * Raspberry Pi 311 * Micro SD card12 * Usb Keyboard13 * Usb Mouse14 * HDMI cable15 * Monitor (that accepts HDMI input, or use an HDMI to VGA adapter)16 * Ribbon Cable Camera16 * [https://www.amazon.com/Distributed-MCM-83-17540-Enclosure-Raspberry/dp/B01KGTD3I0 Clear plastic case] 17 * [https://www.raspberrypi.org/products/raspberry-pi-3-model-b/ Raspberry Pi 3] 18 * [https://www.raspberrypi.org/products/camera-module-v2/ Pi camera module w/cable] 19 * [https://www.adafruit.com/product/1643 NeoPixel Light Ring] 20 * 8GB or larger Micro SD card 21 * Usb Keyboard and Mouse (for developing on the Pi) 22 * HDMI cable or [https://www.amazon.com/gp/product/B016HL49OS HDMI-to-VGA adapter] (for developing on the Pi) 23 * Monitor (that accepts HDMI or VGA input) 17 24 * Micro USB Cable 18 * Adafruit NeoPixel Light Ring 19 * 3 individual male to female PWM wires 20 * 3 individual female to female PWM wires 21 ---- 22 ---- 23 ---- 24 ---- 25 * Qty 3 M-F and qty 3 F-F [https://www.amazon.com/gp/product/B017NEGTXC jumper wires] 26 25 27 == Raspberry Pi Setup == 26 28 … … 64 66 sudo shutdown -r now 65 67 }}} 66 ----67 ----68 ----69 68 === X server === 70 69 Install Xorg and Xinit: … … 96 95 navigate to {{{Edit -> Profile Preferences -> Colors}}} to deselect {{{Use colors from system theme}}}[[BR]] 97 96 select {{{Built-in schemas: White on black}}} 98 ---- 99 ---- 100 ---- 97 101 98 === Development Tools === 102 99 ==== Java 8 ==== … … 122 119 }}} 123 120 124 ----125 ----126 121 ==== Pi4J (Java-GPIO Interface) ==== 127 122 Now we can install [http://pi4j.com/install.html pi4j], a Java interface for the pi GPIO: … … 130 125 }}} 131 126 132 ----133 ----134 127 ==== rpi_ws281x (NeoPixel Control Library) ==== 135 128 Then we can use the rpi_ws281x library for controlling the [https://www.adafruit.com/category/168 Adafruit NeoPixel lightring][[BR]] … … 146 139 }}} 147 140 148 ----149 ----150 141 ==== OpenCV ==== 151 142 152 143 First of all, order some pizza or something because this is going to take about 3 hours (if you are lucky). 153 154 '''EDIT: we have tried with a heatsink as well. It doesn't work. You need to water cool your pi. Please skip to the WATER COOLING section.'''[[BR]]155 144 156 145 Also, you need a heatsink for your processor before building OpenCV. If you see this overheating symbol, you will die. Straight up.[[BR]] 157 146 [[Image(https://i.imgur.com/kYydNgVm.jpg)]][[BR]] 158 147 148 '''EDIT: we have tried with a heatsink and by itself, it didn't work. You need to used forced air (fan) or water *and* a heatsink to cool your pi. Please skip to the WATER COOLING section.'''[[BR]] 149 159 150 If you don't have a heatsink on hand, tape some pennies to the CPU like we did:[[BR]] 160 151 [[Image(https://i.imgur.com/KqWLvKJm.jpg)]][[BR]][[BR]][[BR]] 161 152 162 153 '''================WATER COOLING================'''[[BR]][[BR]] 163 If this still doesn't work, it may be necessary to water cool your pi:[[BR]]154 Poor man's water cooling system:[[BR]] 164 155 [[Image(https://i.imgur.com/DPOazIJm.jpg)]][[BR]] 165 156 Make sure to change the ice cube at least once every half hour. Also, only single bag the ice cube.[[BR]][[BR]][[BR]] … … 184 175 NOTE: we could not get the java wrapper to work with ffmpeg enabled (we ran into a Segmentation fault with opencv libs 3.2.0, 3.3.0, and 3.3.1). We gave up and disabled it.[[BR]] 185 176 177 NOTE: All of the below steps work with OpenCV versions 3.2.0, 3.3.0, and 3.3.1. Use whichever you prefer. 178 186 179 If you do not want to git clone the master opencv repository, download a zipped version: 187 180 [https://github.com/opencv/opencv/archive/3.2.0.zip opencv-3.2.0.zip][[BR]] 188 ---- 189 ---- 190 ---- 181 191 182 === Java Projects with OpenCV === 183 192 184 ==== Enable VideoCapture ==== 193 185 First, to allow OpenCV VideoCapture to access the ribbon cable camera, execute the following: … … 219 211 * {{{Main_class = name of the class file with main method}}} 220 212 * For example, where {{{Vision.class}}} is the class file, {{{Main_class = Vision}}} 221 ---- 222 ---- 223 ---- 213 224 214 === C++ Projects with OpenCV === 225 215 '''NOTE: our performance doubled when we transitioned to C++ from Java'''[[BR]][[BR]]