Axis camera not retrieving images

Hi all,

So we decided to switch to the Axis 206 for vision processing, and so far we’ve been unsuccessful in grabbing images to process and sending them to dashboard.

The connection appears to be set up (I can see the camera feed in the LabVIEW dashboard when I select “IP Camera”), and there seems to be no other errors. The images don’t show up at all.

Here is the code we’ve been using:

package org.usfirst.frc.team1648.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

import com.ni.vision.NIVision;
import com.ni.vision.NIVision.Image;
import com.ni.vision.NIVision.ImageType;

import edu.wpi.first.wpilibj.vision.AxisCamera;
import edu.wpi.first.wpilibj.CameraServer;

public class Robot extends IterativeRobot {

 int session;
    Image frame; 
    Image binaryFrame;
    AxisCamera camera;

 public void robotInit() {
 frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
		binaryFrame = NIVision.imaqCreateImage(ImageType.IMAGE_U8, 0);
}
public void teleopPeriodic() {
        while (isOperatorControl() && isEnabled()){
        	SmartDashboard.putNumber("Number of particles", 0);
        	grabImage();
        	Timer.delay(0.005);
        }
    }

Nothing appears to be wrong, and we can’t figure out why. Thanks for the help!

Are you sure that’s all of your code? I don’t even see a definition for grabImage() in there. Giving us the whole picture might help.

Wow, that was a big mistake there- I didn’t even notice it. Thanks for pointing that out. Here’s grabImage():

public void grabImage(){

 if (Pilot.getRawButton(A_BUTTON)){
    		
camera.getImage(frame);
CameraServer.getInstance().setImage(frame);
    		
NIVision.imaqColorThreshold(binaryFrame, frame, 255, NIVision.ColorMode.HSL, 
HIGHGOAL_HUE_RANGE, HIGHGOAL_SAT_RANGE, HIGHGOAL_LUM_RANGE);

int numParticles = NIVision.imaqCountParticles(binaryFrame, 1);
SmartDashboard.putNumber("masked particles", numParticles);
			
CameraServer.getInstance().setImage(binaryFrame);
			
    	}
    }