View Single Post
  #7   Spotlight this post!  
Unread 15-02-2014, 03:01
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 10
sailorjoe is an unknown quantity at this point
Re: Vision CPU Overloading

Follow up from my previous post about theory. Here is the reality. Our code is written in Java. The first time an AxisCamera.getInstance() is called, it takes our four slot cRIO, over the D-Link, between 4.3 and 4.7 seconds to deliver the first image. After that, each image takes about 25ms to deliver. We're running the camera at 320x240 resolution, 15 fps, compression 30. The live image is showing up on the SmartDashboard. The threshold and filtered images, along with the original image, are being stored in the cRIO flash memory, and are viewable via FTP through a web browser. Because of the time it takes to get an image, we put the image.get() statements inside a loop, like so:
imageWidth = 0;
while (imageWidth == 0) {
try {
image = camera.getImage;
imageWidth = image.getWidth;
}
catch (NIVisionException er) {....}
catch (AxisCameraException er) {....}
}

When this loop exits, we have a picture!
So we have the initial call to getInstance() in the RobotInit() routine. But we can't use the picture from there, because the hot goals aren't indicated until the Autonomous period starts. When that happens, we wait 0.1 seconds, get another picture, and process that one for hot goal detection. Processing should take no more than 300ms. Then we start moving the robot.

It would save a lot of discovery if the javadocs or some other documentation about Vision Processing would have mentioned that the instancing or getImage functions allow program execution to continue before their function is complete. Or did I miss it somewhere?
Reply With Quote