2019:Vision: Difference between revisions
Programming (talk | contribs) (update image source) |
Programming (talk | contribs) m (fix code tags) |
||
Line 14: | Line 14: | ||
*Python3 | *Python3 | ||
<div class="mw-parser-output"> | |||
<div class="mw-parser-output"> | <div class="mw-parser-output"> | ||
= Pi Setup = | = Pi Setup = | ||
Line 19: | Line 20: | ||
| | ||
<font face="monospace">Generate customized image using </font>[https://github.com/frc1511/pi-gen https://github.com/frc1511/pi-gen] (Linux required) | <code><font face="monospace">Generate customized image using </font>[https://github.com/frc1511/pi-gen https://github.com/frc1511/pi-gen] (Linux required)</code> | ||
<code> </code> | <code> </code> | ||
Line 65: | Line 66: | ||
<code>Go to ``7 Advanced Options`` and select ``A1 Expand Filesystem``, then reboot.</code> | <code>Go to ``7 Advanced Options`` and select ``A1 Expand Filesystem``, then reboot.</code> | ||
<br/> | <br/> </div> | ||
</div> | </div> | ||
Latest revision as of 18:09, 21 April 2019
Hardware
- Raspberry Pi Model 3
- 3D printed case w/ a 40mm fan
- Power supply: 12V->5V regulator (CTRE VRM)
Software
- Customized Raspbian Stretch
- OpenCV with FFMpeg and GStreamer
- Python3
Pi Setup
Generate customized image using https://github.com/frc1511/pi-gen (Linux required)
Use Etcher (https://www.balena.io/etcher/), Rufus (https://rufus.ie/), or any other program that can write an image to a SD card
Get a microSD card of at least 8GB in size but no more than 32GB - if using already-setup image use a 32GB card
Use the imaging tool to write the image to the SD card
Use a USB power supply > 2A
Connect a HDMI monitor and keyboard to the Pi and put the SD card in the slot
Power up the Pi and wait for it to boot
After booting, use the credentials below to log in
Username: pi
Pasword: raspberry
Run ``sudo raspi-config``, select ``4 Localization Options`` then ``I1 Change Locale``. Scroll to en_US and select all 3 locales with Space, followed by Enter to generate the locales.
Go back to ``4 Localization Options`` and select ``I3 Change keyboard layout``.
Go to ``7 Advanced Options`` and select ``A1 Expand Filesystem``, then reboot.
Software Compilation
Double line break indicates a new line, single line break is continuing the previous line
Start with customized pi image
sudo apt update && sudo apt upgrade
sudo apt install build-essential cmake pkg-config
sudo apt install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt install libxvidcore-dev libx264-dev
sudo apt install libgtk2.0-dev
sudo apt install libatlas-base-dev gfortran
sudo apt install python2.7-dev python3-dev
cd ~
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.0.1.zip #latest version as of writing
unzip opencv.zip
wget -O opencv_contrib.zip https://githib.com/opencv/opencv_contrib/archive/4.0.1.zip #latest version as of writing
unzip opencv_contrib.zip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py #if using python2
sudo python3 get-pip.py #if using python3
pip install numpy
Go here if you used the setup script
sudo nano /etc/dphys-swapfile and set CONF_SWAPSIZE to 1000. Run ``sudo dphys-swapfile setup``, then reboot with ``sudo reboot``.
cd ~/opencv-4.0.1/ #latest version as of writing
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-4.0.1/modules \
-D BUILD_EXAMPLES=ON \
-D ENABLE_NEON=ON\
-D ENABLE_VFPV3=ON \
-D ENABLE_FFMPEG=ON \
-D ENABLE_GSTREAMER=ON \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python3) .. #use $(which python2) if using python2
Make sure that the section in CMake output includes valid paths for Interpreter, Libraries, numpy, packages path for the Python version used, as well as ‘YES’ for both GStreamer and FFMpeg
Make sure that the Pi has appropriate cooling before compiling. It WILL overheat otherwise.
DO NOT DO ANYTHING WITH THE PI WHILE COMPILING AS THERE IS A VERY HIGH RISK OF CRASHING
make -j4 #compile using all 4 cores, takes a very long time to do (~4 hours)
sudo make install
sudo ldconfig
sudo nano /etc/dphys-swapfile and set CONF_SWAPSIZE back to 100. Run ``sudo dphys-swapfile setup``, then reboot with ``sudo reboot``.
rm ~/opencv-4.0.1
rm ~/opencv_contrib-4.0.1