Access to WPIImages and IPLImages

We are using SmartDashboard to view and process the images from the camera.

We have access to a WPIColorImage. Unfortunately, when we isolate the blue, red and green channel as per examples given, the detection of rectangles of a specific color (around the hoop) is erratic.

So I thougt of using HSL space to isolate specific colors but this can be done only from an IPLImage.

Paul indicated here a way to access the underneath IPLImage using a java wrapper.
http://www.chiefdelphi.com/forums/showthread.php?t=101816&referrerid=46078
Now I have access to the IPLImage but my detection still does not work as expected - I need to see the IPLImage and check what I am doing. Anybody knows how to obtain the WPIImage from an IPLImage ? Thanks.

The following code fragments demonstrate going both directions:



public WPIImage processImage(WPIColorImage colorImg) {

  // Example of getting access to the underlying IplImage of a WPIImage

  WPIImageWrapper wrapper = new WPIImageWrapper(colorImg);
  IplImage iplImage = wrapper.getIplImage();

  // Example of getting the BufferedImage from a IplImage and constructing
  // a new WPIColorImage

  WPIColorImage newColorImg = new WPIColorImage(iplImage.getBufferedImage()); 

  return newColorImg;
}

This is essentially what we did, and it works great.

I understood how to do vision processing on the cRIO and our program is very good at recognizing the target using HSL color space. However, I know next to nothing about programming SmartDashboard extensions with WPI/javacv libraries. Does anyone have example code on using HSL color space with vision processing through SmartDashboard?

Sorry to bump, but I know that someone has a solution and may have just missed this thread/post. Can anyone please give an example of how to track using HSL color space on SmartDashboard?

For accessing SmartDashboard, just extend the WPICameraExtension class provided in the jar in the SmartDashboard extensions directory.
Then just override the processImage(WPIColorImage rawImage) method. The only real change you’ll need to make code wise is to figure how you want to output the data to SD. When you’re done, compile your widget into a jar and place it in the extensions directory. I’m sorry, but I don’t have good example code of this.

I’m working on improving our vision processing over the off season. I’m trying to create a grid of images to display but I can’t figure out how to get the BufferedImage converted back into a WPIImage. It compiles but throws this error when I try to build it.

cannot access com.googlecode.javacv.cpp.opencv_core
class file for com.googlecode.javacv.cpp.opencv_core not found
return new WPIColorImage(img);

I got the last problem figured out but have run into another problem. I am having problems with getting the IplImage out of a WPIImage. When I try to access the image field variable it tells me that it has protected access. What is the work around for this?

What we did here is make a static helper class that lives within the same package namespace as the WPIJavaCV classes with methods to expose the protected member variables (since protected members are visible to all classes within the same package).

Thanks, I had been looking at your code and missed the package line. Makes sense now.