We are trying to use the LifeCam and the USBCamera class for our vision processing. One thing we need is the ability to control exposure and brightness so we get a good image going into our image processing pipeline.
So far I have been able to get an image on the SmartDashboard, provide a way to enter Exposure and Brightness values on the SmartDashboard and send them to the USBCamera class. The problem is, when I change the values, the image doesn’t change brightness or exposure. I know the image is updating because I see the motion in new frames.
Here is what we’re currently doing:
Startup:
USBCamera targetCam = new USBCamera("cam0"); // create connection to camera
NIVision.Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB,0); // create frame buffer
targetCam.openCamera(); // open the camera connection
targetCam.startCapture(); // start the frame capturing process (internal to USBCamera)
Loop:
targetCam.getImage(frame); // retrieve a frame from the USBCamera class
CameraServer.getInstance().setImage(frame); // push that frame to the SmartDashboard using the CamServer class
The above works as expected, and is pretty cool to boot.
Now adding the brightness/exposure control to the loop
Loop:
int exposure = Preferences.getInstance.getInt("camExposure", 50);
int brightness = Preferences.getInstance.getInt("camBrightness", 50);
if (brightness <= 100 && brightness >=0)
targetCam.setBrightness(brightness);
if (exposure <=100 && exposure >= 0)
targetCam.setExposureManual(exposure);
targetCam.UpdateSettings();
updatedBrightness = targetCam.getBrightness();
SmartDashboard.putNumber("Current Brightness", updatedBrightness);
targetCam.getImage(frame); // retrieve a frame from the USBCamera class
CameraServer.getInstance().setImage(frame); // push that frame to the SmartDashboard using the CamServer class
The above updated code, with brightness and exposure still gives me updated frames from the camera, I can also change the brightness and exposure from the SmartDashboard and the getBrightness() will return the NEW value and display it on the SmartDashboard, so I know the USBCamera class THINKS the brightness is changing BUT the actual brightness and exposure of the video does NOT change.
Does anyone have any experience on getting this to work? Any hints, tips or suggestions? We may have to punt with the USBCam and switch to the Axis Cam, which would be a shame since the LifeCam is so compact and “simple”