How to adjust Brightness, Gain, White Balance, Gamma, etc on USB cameras?

Getting into using some USB cameras now.

I am wondering how I can go about working the Brightness, Gain, White Balance, Gamma, etc on the camera?

What kind of code do I use? How do I communicate with the camera? Or, are most of these operations done above only after the information arrives on my computers and not on the camera?

Here is my sketch that reads and loads the camera. How would I adjust the gain for instance?

Here is the camera: Amazon listing Alibaba Listing

Answers

  • Part of this questions revolves around not only how to adjust the settings but how to enable/disable auto-brightness with a USB camera.

    This handy app, Webcam Settings for the Mac, is able to hard set these settings - both adjustments and auto on/off. So, I would think there IS a way to interface with a camera. Since this program can do it with many many different cameras there must be some sort of universal protocol.

    So, I think that could possibly work in Processing. Especially if you can send raw bytes. I think this would be best so that another app had to be opened; such as Webcam Settings.

  • edited June 2015
    • Java programs can't directly access hardware!
    • For that we need to rely on some system programming language.
    • Then use Java's native interface in order to run the external program.
  • edited June 2015

    Very interesting...

    So for instance in this program for the PS3 Eye Camera on the Mac it does have these features. I am assuming that is because it is written in C++?

    I am going to write to the maker of Webcam Settings and see if they know how to access it.

    Are you suggesting a script or more of a program in a lower level language like C++, C, etc?

  • Wait, GoToLoop, when I specify what resolution and FPS the camera should be doesn't that access the hardware?

  • Yes, they go to the hardware. But the code which actually deals w/ it isn't in Java.

    • For example, take a look at the "Video" library.
    • Go to your "sketchfolder/libraries/video/library".
    • You're gonna find 3 other subfolders there: "/macosx64/", "/windows32/" & "/windows64/".
    • For Windows, you're gonna find lotsa ".dll" files.
    • While in Mac ".dylib" & ".so".
    • Believe me, those files weren't written in Java! :-\"
  • Okay I wasn't quite able to find those files but I will take your word for it.

    So since it can write to it and specify a frame rate and resolution what would it take to go one further and do the brightness and such?

    I feel there could be a nice solution somewhere. I've been combing the net for ideas. I see a lot of Linux folks using the command line for their solutions. I also see a lot of OpenFrameworks people using it in Xcode.

    But... It would be very pleasant to get this done in Processing.

    So, it must travel over USB. Could we write to it with the serial like we do an Arduino?

  • edited June 2015

    I also see a lot of OpenFrameworks...

    OpenFrameworks is for C++, which is a system programming language btW.

    Could we write to it with the serial like we do an Arduino?

    It depends whether or not the camera accepts direct commands via Serial over its USB cable.
    Of course you're gonna need to find out which values to sent in order to command the cam.

  • Good to know. I just read up on system programming languages over at Wikipedia. "In contrast with application languages, system programming languages typically offer more-direct access to the physical hardware of the machine"

    I am hoping on a few more leads from other sources. I think the favorite approach for me would be getting command of it through Processing. However, it may need to get down to the metal with OpenFrameworks for a solution embedded in the program.

    In any case, my best solution in the time being is to make use of the application "Webcam Settings". I set my camera up, save the settings. And then in the dock, option click the app and set to "Open at Login". If you leave it running in the background it enforces and sets the values every time.

  • There are 3rd party software that allow you to grab and image form within processing using command line commands via processing open() command. But you can only do what these programs support form the command line.

    with Debut from NCH i can grab images and save them as .png and then access them for processing. But they don't support control of brighness as a command line. If i run the full program , i can adjust brightness, hue and saturation settings. Then whatever I set them for, when i exit the program and use the command line to grab, the last setting form the full program remain

    I assume this means that the program has the code to adjust brightness , but no command line hook is supported.

    DOes anybody know of a USB grabber software that simply supports all these functions from a command line command?

    If not someone should consider writing one ( beyond my expertise) With Debut it simply accesses a installed USB camera device and works with any USB camera device, so it seems the device driver in Windows simply needs to include access to these functions as a universal part of the API for windows .

  • I have been at this for almost a year now. It seems that Directx has the ability to control these parameters on a grabber or camera if they are suported by the device. Several usb cameras and grabbers support these parameters in the software that come with them, like Debut. However, there is no simple utility that is wrapped in a C .exe with adequate command line switches to control the brightness gamma contrast etc. It would be advantageous for someone who understands how to write this code could develop such a utility. From a commercial standpoint, I purchased Debut from NCH and it was well worth it, but they are not open to developing further functionality. If you are please contact me! thanks!

Sign In or Register to comment.