View Single Post
  #1   Spotlight this post!  
Unread 27-01-2016, 22:29
ahartnet's Avatar
ahartnet ahartnet is offline
Registered User
AKA: Andrew Hartnett
FRC #5414 (Pearadox)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2005
Location: Houston, Texas
Posts: 202
ahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond repute
Re: LifeCam USBCamera changing settings from Java

Robert,

I was actually able to get almost exactly what you have to work. The only difference is I made sure to update the camera before opening the camera and starting the capture.

Code:
public class Robot extends IterativeRobot {

    Preferences prefs;
    CameraServer server;
    USBCamera targetCam;
    public static int g_exp;

    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {

    	prefs = Preferences.getInstance();
    	g_exp = prefs.getInt("exp", 1);
    	SmartDashboard.putNumber("Exp", g_exp);
    	
    	targetCam = new USBCamera("cam0");
    	targetCam.setBrightness(5);
//     We actually still had trouble setting exposure. It didn't actually like values 0-100. We found that setting the brightness did enough though.
//    	targetCam.setExposureManual(g_exp); 
    	targetCam.updateSettings();
    	
    	SmartDashboard.putNumber("Brightness", targetCam.getBrightness());
    	
    	targetCam.openCamera();
    	
	server = CameraServer.getInstance();
        server.setQuality(50);

        server.startAutomaticCapture(targetCam);
    }
We then don't get anything in the teleopPeriodic. In order to change the parameter for brightness (or exposure) you could change the value on the smart dashboard, click on the tab 2nd from the top on the left side of the driver station and click robot code restart (or whatever it's called). You don't need to do a full reboot.

Now if you find anyway to turn off the autofocus...that'd be handy.
__________________
Team 451 The Cat Attack, Student Alumni (2005)
Team 1646 Precision Guessworks, Mentor (2006-2008)
Team 2936 Gatorzillas, Mentor (2011-2014)
Team 5414 Pearadox, Mentor (2015-Present)