Vision on the cRIO with OpenCV

Hi folks,
Our team uses java, and I just had an idea about vision for the upcoming season.

Does anybody have any experience with using OpenCV on the robot, after extracting images from the Axis camera?
From reading some posts in here it seems that there’s not much support for the NI Vision library in java, so I suppose my next best bet would be to use OpenCV!

Thanks guys!
Yiftach

It is possible to do vision on the cRio, or use an onboard processor. It looks like you have the intent to do it on the cRio in labview.

This forum would be a great place to start. http://forums.ni.com/t5/Machine-Vision/Using-OpenCV-library-in-LabVIEW/td-p/648429

You should be able cross-compile opencv for vxworks-powerpc (the hard part), then use either opencv’s java wrapper (which may or may not work) or JNA (which should work as that is what is used to call the NI vision lib) to call into the opencv library.

EDIT: also, if you want to stick with the NI vision lib but need a function C++ has that isn’t exposed to Java, you can add a JNA wrapper for it.

Out of curiosity, why restrict yourself to working on the cRIO? If you are willing to work with OpenCV, you’re probably better off integrating it into a SmartDashboard widget on the driver station. At the cost of some extra network latency (although if you’re streaming to the drivers you’ll have video traffic going there anyway), you can do all the processing on a machine with more power than the cRIO (I believe even the classmate has better than a 400MHz ARM CPU), and which doesn’t have a whole lot of processing going on already (ie. all your robot’s logic).

For a great example, look at Miss Daisy’s 2012 vision system. It’s a paper in CD-Media. If you can’t find it yourself, I can get you a link.

Don’t use openCV on the cRIO.

Instead, use openCV on an onboard processor, or your driver station laptop. Even the classmate is an order of magnitude faster at vision processing than the cRIO is.

Like a previous poster said, look at 341 for inspiration.

I am not looking for real-time vision processing, I want to process images at need, I will give another look to the NI Vision library in java, and see if I can get something to work.

I want to do it on the cRIO so I won’t have to rely on the on-field network(which I already had some issues with in this following season), and I’m not worrying about maxing out the CPU because I will only process the images when it is needed.

You don’t need to rely on the field network for your processing. The coprocessor option such as the Odroid or other Linux/Android-based single board computer can run OpenCV and spare the cRIO the processing requirement. If you absolutely do not anticipate using real-time image processing, then using the vision library for LabVIEW is a possibility as Greg McKaskle has pointed out before in other threads.

The problem with using the vision library for LabView is that our team is using java!
I understood that there are some C++ functions from that library wrapped for java use, but not all of them, and I wonder if it’d be possible for me to use the NI Vision Assistant and rewrite the code I get from there in java.

I really don’t think “real-time image processing and use of that data” can be done, and I want to try the “single-frame processing and actions based on it” thing to see if it can go well enough.

So to sum up, I’ll give up on OpenCV for now(as it seems) and check out the NI Vision Library for java.

You’re right. I have been reading so many vision threads lately that I got this one mixed up. I believe the LabVIEW WPI library is a variant of OpenCV, check on this for accuracy. What I was actually referring to was the algorithm for single image vision using the cRIO. The single image is relatively simple for the cRIO to handle, especially if you know what you are comparing the camera image to. If you want to go to a real-time algorithm, you will need to start looking into coprocessors.

I’m not directly responding to any of the posts on this thread, but just wanted to try and clarify what NI Vision is.

NI Vision consists of hundreds of highly optimized kernel routines written in C/C++ and library wrappers into that kernel for a few languages. Those languages are C++, LabVIEW, and .NET. NI doesn’t ship java wrappers for NIVision, and WPI has written only written JNI wrappers for a few functions. In addition, the WPILib wrappers for C++ usage of NI Vision are not really that compatible with how NI Vision was intended to be used. Many parameters are remapped or left out entirely.

If you are interested in using NI Vision from LabVIEW, it is easy and all wrappers are already done for you.

If you are interested in using NI Vision from C++, it is pretty straightforward. Open the Program Files/National Instruments/Vision directory. You will find includes, libraries, examples, and documentation for C users. The C manual is the CVI one. Note that it is a C interface and not class based.

If you are interested in using NI Vision from Java, see the C++ case and use an import tool or write JNI wrappers.

NI Vision is included for Windows and VxWorks.

Greg McKaskle