Go to Post ...there's nothing worse than a problem you can't solve because you don't even know about it. - Dave Flowerday [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 27-01-2016, 08:58
robert1356 robert1356 is offline
Registered User
AKA: Robert Palmer
FRC #3824 (RoHAWKtics)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2012
Location: Knoxville, TN
Posts: 47
robert1356 is an unknown quantity at this point
LifeCam USBCamera changing settings from Java

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:
Code:
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:
Code:
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:
Code:
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"
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 23:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi