View Single Post
  #31   Spotlight this post!  
Unread 01-02-2016, 11:21
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: 48
robert1356 is an unknown quantity at this point
Re: Brightness on 2016 vision samples

I was finally able to get the camera to work the way I wanted it. There appears to be some issue related to calling the camera settings function too often or to close together (in time). I haven't spent the time tracking down the issue, but do have a good work around. Previously, I had in my loop, a check that if the setting changed, it would call the appropriate set setting, then immediately call the getImage() function. This would get the image, but I could never get the exposure to work. The change/workaround that makes it work is:

(This is all Java, but applies equally to C++)

- I created a separate function the when called, updates the specified setting (brightness or exposure)
- it retrieves the value from a Preferences object on the SmartDashboard.
- I added a button on the SmartDashboard to trigger this function call.
- I also added a button (and function) for setAuto and setHoldCurrentExposure (which switches to manual exposure)
- My loop now does just:
- USBCamera.getImage()
- CameraServer.setImage()
- Now when I click one of the buttons, I get exactly what I expect, the exposure or the brightness changes according to the value in the Preferences table. I can get a VERY dark image and I can get a VERY bright image or anything in between.

So for those asking about dark for autonomous and normal for teleop, you can explicitly call the settings and get the exposure/brightness you need. I think the important thing is to call them each only once in a given time period (not sure what the time period is, 100's of milli-seconds or seconds I would guess) and don't call getImage() immediately after the settings change.

I'm honestly not sure why this approach works and the other doesn't someone that knows the internals of the NIVision.IMAQ class would probably have to chime in. I don't have the time to dig into it. If someone wants the code example, let me know and I'll post it somewhere.