Okay we have had camera working at our tournaments, and have added laptop side processing in the Labview dashboard of the image to get the alignment to the goal, which is sent back to the roborio.
At first we were using the following code to send the image.
camera = CameraServer.getInstance();
camera.setSize(2/camera.kSize320x240/);
camera.setImage(Image.SCALE_FAST);
camera.setQuality(100);
camera.startAutomaticCapture(“cam0”);
But we were running 90% to 100% pegged CPU.
By changing to the following code it now is running a more reasonable 40% to 60% CPU. But we are only getting 1.9 frame per second. I would like to lower the pixels in the picture, but don’t know the how to in straight NIVision code. Any pointers in the right direction would be appreciated.
public class Robot extends IterativeRobot {
…
…
int countToTakePicture = 20;
int currentCountToTakePicture = 0;
…
…
public void teleopPeriodic() {
Scheduler.getInstance().run();
boolean takePicture = false;
if(currentCountToTakePicture == countToTakePicture){
takePicture = true;
}
else if(currentCountToTakePicture <= countToTakePicture){
currentCountToTakePicture++;
} else {
currentCountToTakePicture = 0;
}
if (takePicture){
int session;
session = NIVision.IMAQdxOpenCamera("cam0",NIVision.IMAQdxCameraControlMode.CameraControlModeController);
NIVision.IMAQdxStartAcquisition(session);
Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
NIVision.IMAQdxGrab(session, frame, 10);
cameraServer.getInstance().setImage(frame);
NIVision.IMAQdxStopAcquisition(session);
NIVision.IMAQdxCloseCamera(session);
// from cheifdelphi Program crashes with out of memory issue if we remove this line
frame.free();
}
Lower priority items:
Also should probably do a more controlled way on when to take the picture.
Also thinking about copying it into auton so can autoalign for our low goal, I dont anticipate any problems but, my lack of full understanding of NIVision makes me worry, should I?