<< return to Pixycam.com

programmatically set white balance/brightness on startup

Hi, I am using the pixy to detect retro-reflective tape in high brightness environments. I’ve found that to get consistent blob detection I have to manually set the white balance and exposure values (through pixymon using cam_setWBV(INT32 wbv), cam_setECV(INT32 exposure), and cam_setBrightness(INT8 brightness)), which makes since given the niche lighting conditions of the application. However I was under the assumption that the pixy saved these settings in memory like the color signatures so they’d be preserved past power loss. Unfortunately it seems that when powered on, these settings are set to default values (or automatically calibrated?) which are vastly inferior in terms of accuracy. The obvious solution to this would be to configure the pixy on each power up over serial, but according to this thread: http://www.cmucam.org/boards/9/topics/5872?r=5967 that isn’t a supported feature.

The solution that I’m attempting as of now is to hook the pixy up over usb interface to a raspberry pi and constantly push the commands to set the proper values. This seems rather inefficient and also introduces an entire pi to my project simply because the device we are talking to the pixy with (a roboRIO) can only communicate with it over serial.

So here’s my question: is it possible through any simpler means to configure the pixy in such a way for it retain exposure and white balance settings through repeated startups? I feel like it should be possible to write something to accept those commands over serial, or even save/restore those values on statup but I’m not sure if I’m missing something.

Thanks for the help!

Hi Joseph,

yikes! You shouldn’t need to use the Pi for white balancing. Check out this documentation for PixyMon’s white balance settings: http://cmucam.org/projects/cmucam5/wiki/Camera_Pane

By default, Pixy is set to auto white balance on powerup. You can disable this in the settings.

Hope this helps!

Best,
Jesse

I was under the assumption that I could set them once in pixymon and they would stay constant if I disabled the auto white balance just like you said. but every time I power it back on the white balance changes to 0 resulting in a black image until I change it back to something reasonable (8017984).

Hmm, this is how it should work – it should save the white balance value to flash.

Are you using the latest firmware version 2.0.19?

http://cmucam.org/projects/cmucam5/wiki/Latest_release

If you are using firmware version 2.0.19, please try to “restore default parameter values” and retry disabling white balance.

http://cmucam.org/projects/cmucam5/wiki/Action_Menu

Let us know what you find.

Edward

Thanks for the suggestion, I’m now running the latest firmware, but the problem is still occurring. To be clear, this is my procedure.

Restore default parameter values (to ensure everything is reset)

Disable auto exposure correction, AWB, and AWB on power up

Use the pixymon command line to write settings using cam_setWBV(8017984), cam_setECV(52738), and cam_setBrightness(26). At this point if I enable camera it works perfectly and we can set our color signatures and whatnot

Disconnect USB to turn off the pixy

Reconnect USB to turn it back on

At this point I get a black video in pixymon. and using the cam_getBrightness(), cam_getECV(), and cam_getWBV() commands I can see that brightness gets set to it’s value in the pixymon settings gui (default 80. note that after turning off those settings in step 2 I applied the changes and closed that window). Exposure gets set to 104447 and white balance gets set to 0.

Hi Joseph,
The way it’s supposed to work is when you disable AWB, it will take the current white balance and save it to flash to be loaded upon the next power-up. Running the commands setWBV and setECV might be interfering with this. Can you try without running the commands manually?

Edward

Update: I played with this and it seems to work for AEC but for AWB it is broken. It results in a black screen (exactly as you describe) if you disable “auto white balance on power up”. I went back to earlier versions of the firmware and wasn’t able to find a working version, although I recall using this feature before. Hmmmph. Sorry about that :frowning:

In the meantime, if you manually set the WBV using cam_setWBV on power-up, it should restore video. There is something going wrong in the saving and restoring the WBV to/from flash.

I’m going to push for a quick fix to this. :slight_smile:

Edward