Changed the video feed brightness, contrast and settings for my Logitech USB video feed to Octoprint control in my browser.
Step-by-step
With the kind help of Fredrik Agert, I got this working perectly on my Pi and would like to share for others that may be looking for this solution.
Please feel free to add, update or comment if I have missed anything ( I have no Linux experience )
I am using Putty on Win 8 to open an SSH Terminal window to the Pi.
Current setup is :
Octoprint 1.3.6
OctoPi 0.14.0
Connect to the Pi using the SSH Terminal window ( Putty ).
First step was to install uvcdynctrl in the Pi with the following terminal command :
sudo apt-get install uvcdynctrl
Next, try a manual change to the video settings with :
uvcdynctrl -s 'Brightness' 55 'Contrast' 15 'Saturation' 80 'Sharpness' 'Focus, Auto'
The changes should show immediately in the Octoprint video feed.
Adjust the values to get the picture quality that you want.
My settings ( due to a very bright background ) are :
uvcdynctrl -s 'Brightness' 150 'Contrast' 35 'Saturation' 50 'Sharpness' 'Focus, Auto'
Next, create the script file that will run and change the settings :
create the pi directory if it does not exist
mkdir -p /home/pi
create the bin directory if it does not exist
mkdir -p /home/pi/bin
start the Pi text editor ( nano ) using :
nano /home/pi/bin/cam_init.sh
In that script file, paste or type the settings line ( with your choice of values ) :
uvcdynctrl -s 'Brightness' 55 'Contrast' 15 'Saturation' 80 'Sharpness' 'Focus, Auto'
ctrl-X to close and Y to Save the file, and Enter to commit the Save.
Next, you need to give that file permission to run as an executable file with :
chmod a+x /home/pi/bin/cam_init.sh
Now you need to tell the Server when to run that script file.
I could not get this to work using the 'Startup' event, but it works perfectly using the 'ClientOpened' event, which occurs every time you connect to the Server from your PCs web browser.
Edit the config file ( WARNING : I was advised to NOT do this when a print job is running ) :
nano /home/pi/.octoprint/config.yaml
and add to the bottom of the file :
events:
subscriptions:
- event: ClientOpened
command: /home/pi/bin/cam_init.sh
type: system
( aparently the spaces at the start of each line are important )
This tells the Server for every time the ' ClientOpened ' event occurs ( you connected to the Server ), to run the script file cam_init.sh
Restart the Pi and once your server is running, and you connect from your browser, the video feed settings will be changed.
If you want to change the settings, go back to :
sudo nano /home/pi/bin/cam_init.sh
and edit the settings.
Save the file, then close the browser tab for Octoprint and open a new tab - the ClientOpened event is triggered and the new settings will be in place.