Question about CMUCam5 Pixy and white balance/exposure resetting

To preface: sorry if this is the wrong subforum, not sure if this would fit better in programming (not really programming related either though).

This year we are using a CMUCam5 Pixy for vision… and it works well, but white balance and auto exposure seem to reset or change after turning the robot on and off.

In PixyMon, disabling auto exposure, auto white balance, and auto white balance on startup cause the Pixy to stop getting a video feed. Any ideas? Is there a way I can set the exposure/white balance manually in a config file so we don’t have to worry about calibrating before every match?

Thanks in advance

If this information helps: the Pixy is wired to an analog port on the Rio, and using the 5v power from that. We need camera brightness (in PixyMon signature pane) to be very low to take advantage of the reflective tape/LED ring.

Disclaimer: never e

I’ve never held a roboRIO, but I know a fair bit of GNU/linux.

If you’re looking to go the automated, linuxy route, what you’d do is make a script that sets the camera settings you want, then make that a start up script.

Script to set camera exposure:

First, you’ll need to install v4l2-clt (video for linux 2, command line interface)

sudo apt-get install v4l2-utils

then determine what you can actually control

v4l2-ctl --list-ctrls

this will output something like

brightness (int) : min=0 max=255 step=1 default=128 value=128
contrast (int) : min=0 max=255 step=1 default=128 value=128
gamma (int) : min=1 max=6 step=1 default=4 value=4
auto_gain (bool) : default=1 value=1
light_frequency_filter (menu) : min=0 max=2 default=0 value=0
sharpness (int) : min=0 max=3 step=1 default=2 value=2

To set things,

v4l2-ctl --set-ctrl brightness=value1
v4l2-ctl --set-ctrl contrast=value2

where value is the value you wish to set it to.

Once you get that, put those commands (v4l2-ctl --set-ctrl …) in a shell file (.sh).

sudo nano /etc/rc.local

then put /path/to/your/file.sh in here

then, next line, exit 0.

Save, exit. Restart and it should work

The pixy is not a v4l device.

Ah. Bad assumption on my part.

Digging around the the libpixyusb API, there are a few functions that might be of use:

pixy_cam_set_auto_white_balance
pixy_cam_set_white_balance_value
pixy_cam_set_auto_exposure_compensation
pixy_cam_set_brightness

What I do not know is if after you set these, they stick when you close the program that set them. If they do, the later part of what I wrote above still holds, just you’d call an executable that sets the pixy’s settings instead of a shell script.

We got to figure this out last year.

Connect to the Pixy with Pixymon and enable all 3 boxes in that camera pane (the exposure and white balance boxes). Next set your camera brightness where it needs to be. Ours is set to 22 for both Pixys on our machine. For whatever reason, I can only get the camera brightness to adjust if the auto-exposure is still on. Now set your color signature. Now un-check all 3 boxes in the camera tab.

Now the weird step: check the Auto White Balance box for a couple seconds an then un-check it. The Charmed Labs folks tell me this stores the white balance setting to Pixy’s flash memory. All 3 boxes in the camera tab should now be un-checked.

If I have remembered all of this correctly, your Pixy settings are now non-volatile and will still be there on power up.

Oh wow… Quite a process. Thanks for this response!

Thanks for the responses, I’m sure we’ll get something working

We are using pixy cameras as well. Ken’s method of setting is what we had to do as well to set the camera up. Once set it remembers the settings even on power up.