White balance issues with mjpeg-streamer on Octopi

What is the problem?

(I do realize this is a purely cosmetic problem, I'm just throwing it out there in the hope that someone has encountered/solved this before and it's just my Google-Fu that's too weak ...)

I'm trying to set a fixed white balance for the timelapse camera on my Octopi configuration while also maintaining good image quality (using -usestills)

What did you already try to solve it?

I've tried the various settings available in the raspicam documentation in /boot/octopi.txt, but the configuration seems to accept only "-awb auto" and either ignores other settings or does not activate the camera at all. The white balance is also apparently only set once at cold boot in the camera. For every iteration/test the raspi needs a full restart.

If there's a command line command to relaunch/restart the mjpeg-streamer after a configuration change without requiring to restart the Raspi, that'd be a great help for me already ...

My current config line is:

camera_raspi_options="-usestills -fps 2 -x 1296 -y 730 -awb auto -ex fixedfps -quality 50"

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)
Octopi 1.3.6 stable, Raspi 3, tronXY X5S, Marlin 1.1.7 (works fine)

Also, kudos for Octoprint and Octopi! Works like a charm and has made my printer feel much more "Machine" and not "Tinker toy requiring SD card DJ'ing" :wink:


That I can help you with: sudo service webcamd restart

Awesome, thank you very much!

(Edit: the service restart also works like a charm if I boot up octopi and forget to turn on the build room light first, thus getting the camera stuck at "overexposed" :wink: )

I've meanwhile poked around a lot in /boot/octopi.txt (and rebooted at least a dozen times … thankfully I've splurged for a fast MicroSD card :slight_smile: ) and I've found a way to make things work like I wanted to - with fixed color balance and still image quality (because the -awb "something" setting seems not to be honored together with -usestills ?)

I've tried the option "-awbg (floatR,floatB)" first but this keeps mjpeg-streamer from even starting ... and then I looked into the log file where both the error message and all the permissible options were listed. #doh :smiley:

Here is my current config line, for both image quality and fixed color adjustment:

camera_raspi_options="-usestills -fps 2 -x 1296 -y 730 -awb off --awbgainR 1.7 --awbgainB 1.5 -ex fixedfps -quality 50"

And this makes the difference between example pictures "before" and "after" below:

Again, thank you very much for Octoprint!

Sweet! :+1:

That's a huge difference indeed, looks like you've got it figured out now! Don't forget to mark your own reply as answer btw :slight_smile:

(This is a follow-up after a few months of use.)

One issue I ran into is that the exposure gets locked on boot, and that the print surface is black, so the camera compensates and the picture becomes too bright.
I've temporarily remedied this by placing a gray/white piece of cardboard (also as dust protection) over the print bed, but that's not very convenient.

Now that I'm in the process of building an enclosure around my TronXY X5S, the lighting setup changed once again, and frankly I'm just too lazy so I tried to come up with a better way to get the camera to reliably adjust itself.

Here’s a slight modification to my camera options line inside /boot/octopi.txt

camera_raspi_options="-ev -6 -usestills -fps 2 -x 1296 -y 730 -awb off --awbgainR 1.7 --awbgainB 1.5 -ex fixedfps -quality 50"

The -ev -6 sets the camera’s exposure value to "-6 from average", for my situation that’s dark enough that bright areas in the picture do not get blown out. Depending on your setup, you’ll need to tune that value yourself.



1 Like

Thanks for this. I couldn't for the life of me figure out how to lock in the white balance using the Red and Blue gain like raspistill command does.

1 Like

This is an update after switching to Octoprint 1.7 on Octopi 0.18

I needed to adjust the /boot/octopi.txt file by adding


to make sure my custom settings were applied. I guess the new default is to use USB webcam first, and the RaspiCam seems to respond with a "USB emulation" mode. So my custom settings in camera_raspi_options were no longer active.

Edit: It's actually mentioned in the inline documentation of /boot/octopi.txt