Develop and test C++ camera code without a robot

I was planning to do some C++ programming work with the Axis camera over the summer while I’m at school, in order to become familiar with the some of the stuff the vision library can do, like shape recognition and edge detection. But short of lugging a robot to my dorm room or driving an hour and a half to Niagara Falls every weekend, I didn’t have a way to do it. So, cognizant of the fact that NI has provided teams with a Windows version of the C++ vision library, I wrote a tool to help me out, and decided to share it with the community.

It can be found at http://patfair.net/frc/cameratest.

Basically, you connect the camera to your PC via Ethernet and run the application, which I’m calling “FRC Camera Test” for the moment. The program grabs a continuous stream of frames from the camera, does whatever image processing you want, and displays the original image on the left and the results of the processing (image and/or text) on the right. The code provides an interface (in the OOP sense) to make it easy to write your own image processing routines. It’s BSD-licensed, so you can modify the code of the main application too, if you want.

Since I just finished writing this tool and haven’t really used it too much myself, yet, there will likely be improvements made and features added. Comments and suggestions are welcome.

I haven’t looked at the specific details, but this sounds like a great harness for developing and tweaking vision code. Let me add some other details, not necessarily for you, but for anyone interested in playing with the NI-Vision libraries.

If you want to learn about the capabilities of the libraries, the Vision Concepts manual is a great resource. It is available in the Start menu>>National Instruments>>Vision>>Documentation. It doesn’t cover the syntax of the calls, but rather the algorithmic tradeoffs. For example, there are more than six methods for shape recognition, and it helps give background on the tradeoffs. I also presented some slides on the vision libraries Atlanta. They point out some examples to run and some of the library areas that are most applicable to FRC. They should be available on the NI site.

If you want to experiment at a higher level, you can run Vision Assistant on your Windows PC. Set the IP to 192.168.0.6 or similarly get your camera and PC on a compatible network, in the assistant you can choose to Acquire images, scroll in the list of camera types to Axis, adjust the IP address if needed, and click on either the single or multi frame acquire buttons. You can quickly modify camera settings, and once you have images in the browser pane, you can use menus and UI controls to inspect, correct, and process the IMAQ library functions. It may take away all the programming fun, but you can also have it generate C or LV code.

If you prefer to skip the menus and play with the code, Pat’s tool sounds like it does the acquisition and display, and gives you a place to place C code for processing images.

If you are using LV, the WPI VIs work on Windows too. You can take your Robotics project and drag or copy select VIs from the cRIO target in the project to your PC target within the project window. Open the panel under the PC target and it will now run on the PC. You can delete or comment out WPI I/O components – no simulation just yet, and you can run an app that does vision just fine. I would suggest opening the properties for the project and turning off auto-error-handling. The WPI vision libraries ignores a few HTTP errors from the camera, but with AEH, this will result in a dialog each time and it is distracting.

As always, if you have questions or issues, post them. And thanks for doing this for the C/C++ users.

Greg McKaskle

Does this program spew out massive amounts of awesome, or is it just me?

-Nick