View Single Post
  #8   Spotlight this post!  
Unread 13-02-2016, 15:03
medofbr medofbr is offline
Registered User
FRC #5404
 
Join Date: Jan 2016
Location: Pennsylvania
Posts: 12
medofbr is an unknown quantity at this point
Re: LifeCam USBCamera changing settings from Java

Quote:
Originally Posted by robert1356 View Post
Using the NIVision IMAQ commands, the min/max values returned are 5 and 20,000 respectively. I duplicated the USB Camera class (too bad they made all the variable private instead of protected) and replaced the setExposureManual() with code that allowed me to set the value explicitly. It turns out that anything above about 40 or 50 will give you quite a bright image. I'm actually using 10 I think for the exposure and 10 for the brightness.

As for losing the settings - as long as you don't power the camera off, you will not lose the settings. It's tricky, but you can use Robot code to configure the camera, then disconnect, then run GRIP and it will have the setting you just set. There are some real caveats in all this and I think I finally have all the cases worked out. I'm probably going to post the code when I get it working.

Caveat #1 - The robot code cannot use CameraServer - if it does, GRIP will not be able to publish a stream. Unfortunately, while you CAN disconnect from the USBCamera, you CANNOT kill the CameraServer stream without rebooting the robot or manually killing the robot code.

Caveat #2 - don't forget that during development, if you use your robot code to set the settings, then launch GRIP, if you reload robot code, GRIP is still running and your robot code will throw an exception trying to connect to the USBCamera - you have to either reboot your roborio or kill the GRIP process. I've written code to kill the GRIP process if the USBCamera open() method throws and exception.
When you say you can use the Robot code to configure the camera, then disconnect, then run GRIP, what do you mean by "then disconnect"? Does the mean calling the CloseCamera() function?