Team 2823 Raspberry Pi Experimental OpenCV C/C++ code

Hi Folks,

Our team used a Raspberry Pi for vision processing last year. The student ended up with code that had pretty poor performance; about 1 frame per second. In the off season, I and a few students spent some time working up code to explore the performance and try to optimize the code.

We’ve got a body of code I thought I’d share. I’m afraid it’s not complete, and it’s really only suitable for someone with a strong C/C++ background.

The code is all on GitHub here:

It has one novel useful feature - I rewrote the OpenCV capture function in C, with a built in color filter capability, so in theory we can get a frame in more rapidly than any other way. (Although frame capture turns out not to take that much of the time; it’s things like canny and finding contours that are expensive). It does have a lot of other features; timing of functions, configurable functions to perform (e.g. blur, canny, contours, fast, and so on), and tuning for color and camera filters.

But it’s more of a toolbox; it’s not at all a ready made set of vision code, and really suitable to someone who feels pretty comfortable in C and C++.

At any rate, I figured I’d share instead of just sitting here refreshing the kick off countdown timer… <grin>.



Very audacious. I will comb through this and see if my limited C/C++ experience can tell me what’s happening. The electrical part of my team might find this interesting.

looks very clean. How do you plan to communicate between the roboRIO and the RPi?

That’s a different exercise <grin>. Last year, we just set a gpio pin to on/off if it was hot or not, although we did have a student write a network transport layer.



hmm, neat. If you’re interested, I actually have some experience setting up a TCP/IP communication between an RPi and a linux PC. Albeit different from a roborio, but the similarities are there. I’d love to help you out on this if you want, I may try and convine my team to use an RPi this year. They are awesome :smiley:

Would it not be faster/more efficient to use SPI or I2C directly to the roboRIO instead of trying to use already in use TCP/IP.

Very probably xD However, my electrical knowledge is much lesser than my software. TCP/IP would be my goto comm setup, but I2C would likely be more efficient.