Attached is a compiled version of the OpenCV 2.4.10 libraries, which we patched to support the particular camera functions of the USB Microsoft HD 3000 web cam.
The patch exposes certain controls to modify the USB camera image settings. The patch also expands the videoCapture contstructor to accept framesize and fps so the user can specify those parameters and have the camera set accordingly on instantiation. All settings are done at the driver hardware level using V4L2 api.
This patch is only required if using the Microsoft HD 3000 USB camera, and while it may support other USB cameras, we can not guarantee that it does. This patch is not needed if you are using an IP camera or other external capture device.
The patch is already compiled into the attached libraries, but if you would like to see what we modified, our changes to OpenCV are public here: https://github.com/KHEngineering/OpenCV_For_FRC_RoboRio/commit/aebc1d9261da2a44bdbcbac93398d48b211dafba
I have also included an example vision application written in C++ which uses OpenCV to perform last years vision task of detecting a hot goal. The example itself is very simple using only basic filters in OpenCV, (but it is exactly what we used throughout the 2014 competition season).
This example can be ran directly on the RoboRio or a number of other Armv7 based processors such as the beaglebone family. The example supports processing images from a USB Camera, IP Axis Camera, or from a file. I have modified the program to select command line arguments which will allow it to capture images from a IP axis camera, webcam, or a file.
This is an example image taken from the camera as input to the algorithm:
This is an example image produced by the algorithm identifying the countors or interest:
This is an example image produced by the algorithm idenfiying the contors within an image:
This is an example image showing what the console will produce when verbose debugging is enabled:
The source and executable are included. To run the program all you need to do is install OpenCV as per the instructions below, and then transfer the executable over and run it. Some examples on how to run it are
./2168_Vision_Example -c 10.21.68.90 -v -t
// this will run and capture frames from a axis camera at IP address 10.21.68.90, it will also display the processed image (because of the visualize flag -v, and will output the time it takes to process each frame because of the timing flag -t)
./2168_Vision_Example -u -v -t
// this will run can capture frames from the usb camera at /dev/video0
.2168_Vision_Example -f /home/image.jpg
//will process a static image without any output, add flags if you wish
you can use the -help flag to see all other flags supported.
This program is multi-threaded, the frame capture runs in one thread, while the image processing runs in another. Shared memory is used between the two and read/write access is controlled via mutex lock.
The OpenCV libraraies, include files, and other required libraries are included in the project itself, so all you need to do it makesure you have the cross-compiler set up, and it should compile without a hitch.
Please let me know if there are any questions. I am releasing this under GNU, but will help troubleshoot any issues as best we can.
We have tested this to be working with the latest FRC 2015 Eclipse C++ plugins as of 1/2/2015, and the latest RoboRio Image v23, on Windows 7 32-bit with Eclipse Luna.
We have also tested this be be sucessuly at running on a beagle-bone black running latest angstrom as of 1/2/2015.
Assumptions: I already assume you have followed the screen steps guide on how to set, up and install your Windows Development computer for C++ FRC development. Make sure you can sucessfully build and deploy a test iterative project.
Official Directions can be found here: Screensteps Live
Additional Troubleshooting tips can be found here: 2168 Control System Website
The easiest way to compile the example on your own from source is to clone this git repo into your eclipse. The project is already set up with all the paths so it should build without a problem.
vi /etc/ld.so.conf.d/opencv.conf
, a new file will open inside the terminal windowi
key to enter insert mode/usr/local/lib/lib_OpenCV
esc
to exit insert mode:wq
and then hit enter to save and exit the fileldconfig
in the rio terminalcd
command e.x. cd /home/Vision/
./2168_Vision_Example -help
to run the programIf you will to run this on a beaglebone instead of the RoboRio, the steps are exactly the same as above for the Rio, just instead of the RoboRio, use the BeagleBone.
As stated above, you can use command line arguments to change the behavior of the program without having to recompile the code. The most general uses are
./2168_Vision -c 10.21.68.90 -v -t // this will run and capture frames from a axis camera at IP address 10.21.68.90, it will also display the processed image (because of the visualize flag -v, and will output the time it takes to process each frame because of the timing flag -t)
./2168_Vision -u -v -t // this will run can capture frames from the usb camera at /dev/video0
.2168_Vision -f /home/image.jpg //will process a static image
you can use the -help flag to see all other flags supported.
Note: When using the -v flag, you must have X11 forwarding set up on the RoboRio and X11 client installed on your development computer. To learn how to set up X11 forwarding on the RoboRio, visit the 2168 Controls Webpage and view the RoboRio tab, to view the steps for enabling X11 forwarding on the RoboRio`
The project here has the includes and arm libraries required as local directories, so if you use this eclipse project, and have the FRC cross compiler installed, it should find all required files automatically. The build path is already set to search the corresponding directories within the project
Please let me know if there are any questions
We develop most of our FRC stuff on Ubuntu 14.04, and use our own cross compiler. With that said we will try to help troubleshoot any problems you encouter as best we can.
The above have been tested on sucessfully on different Windows 7 machines, using the latest FRC tools, and the latest FRC Image as of 1/2/2015. We have confirmed successful processing of USB and IP camera images, as well as successful modification of the USB image settings using OpenCV through our patch. Settings for the Axis IP web cam are done through the Axis Camera webpage.
We also have this running on the Nvidia Tegra, and will be releasing the libraries and build configs for the Tegra Very soon. Happy New Year