Our teams template for future vision projects. Contains a variety of setup scripts that should be run to enable the camera and import OpenCV libraries. Also has a template for processing images via the Pi Camera and creating a UDP server.
-
Buy a Raspberry Pi and Pi Camera v2 from here
-
Buy a case here
-
Buy a camera case
-
You'll also need a mini sd card (8GB +), you can buy this anywhere
-
Buy a LED RING
-
Download Raspbian onto your personal computer: Raspbian
-
Download Etcher and flash the pi using the Raspbian image.
-
Once your SD card is formatted, place an empty text file called ssh in the boot folder to enable SSH. You can then install Putty on your desktop to access the pi. Then hook up your pi to your internet (via ethernet cable) and then ssh into the pi using putty with a hostname of
raspberrypi.local
a username ofpi
and a password ofraspberry
. You may change these once in the terminal by runningsudo raspi-config
. This is the easiest way to access the shell of the RPI however you may also hook up a monitor, keyboard, and mouse if you would like to use the desktop. -
Make sure your pi is connected to the internet and install git via
sudo apt-get install git
or follow these instructions -
Then fork this repository and clone it. Instructions here... If you do not have access to the desktop/web browser you may just clone the repository. To just clone use
git clone https://github.com/HuskieRobotics/Huskie-Vision
-
Now run my setup file (it may take up to 6 hours+ to compile the opencv library, run this overnight). Use the commands
sudo chmod +x /home/pi/Huskie-Vision/setup/setup_script.sh
sudo sh /home/pi/Huskie-Vision/setup/setup_script.sh
-
Take a look at the vision files and fill in your code as necessary. There are a variety of comments that detail exactly how and where to write your code.
-
Also make sure to use the Testing Suite to tune your camera using HSV, Brightness, ISO, etc. It contains trackbars that you can slide around to tune.
-
/setup/setup_script.sh
This file runs all the setup scripts -
/setup/VisionStartup.service
This file is a systemd service. It is copied into the file pathetc/systemd/system/
and given permissions that allow it run the Vision Processing when the Pi boots up. Basically autoruns the program on startup so you don't have to during competition. -
/setup/enable_systemd_service.sh
This file sets up theVisionStartup.service
file in the systemd service folder. -
/setup/enable_cam.sh
This file enables the camera module. You don't necessarily need this if you use a USB camera. -
/setup/install_opencv.sh
This file installs OpenCV for Python 2.7. It does take a long time to run. -
/setup/launcher.sh
This file launches the Vision Processing. Is called by the systemd service. -
/setup/pip_installs.sh
This file uses pip to install all other relevant modules including numpy, socket, and time. -
/vision processing/Image_Processing.py
This file takes the image, finds the contours, and gets all the data you would like from the image. -
/vision processing/Testing Suite.py
This file is a testing suite for your HSV, brightness, and ISO tuning.You will then use these values and plug them into your image processing thresholding. -
/vision processing/UDP_Server.py
Class for the UDP server object that sends JSON packets to the roborio. -
/vision processing/Vision_Main.py
Main Vision program where images are grabbed from camera and the server and Image Processing modules are called.
Team 254 Vision Video SUPER HELPFUL: here
Vision Tracking in FRC (A short guide): here
Learning about OpenCV: here
Learning about Contours: here
What is UDP: here
Our GrabCad Partner space has the files for all of this: here This model actually has a spot for the LED ring to sit on.