Octoprint Logitech C920 webcam - martikainen87/Home-Automation GitHub Wiki
To set the image quality and focus, do the following
SSH into your octoprint server
sudo apt-get install uvcdynctrl
Try different settings with these commands
uvcdynctrl -s 'Brightness' 150
uvcdynctrl -s 'Contrast' 35
uvcdynctrl -s 'Saturation' 50
uvcdynctrl -s 'Sharpness'
uvcdynctrl -d video0 --set='Focus, Auto' 0
uvcdynctrl -d video0 --set='Focus (absolute)' 10
Change the "Foucs (absolut)' XX value to set different focus
Create a directory for a script
mkdir -p /home/pi/bin
Create a new file for the script
nano /home/pi/bin/cam_init.sh
Paste the command with your settings
uvcdynctrl -d video0 --set='Brightness' 150
uvcdynctrl -d video0 --set='Contrast' 150
uvcdynctrl -d video0 --set='Saturation' 150
uvcdynctrl -d video0 --set='Sharpness' 175
uvcdynctrl -d video0 --set='Focus, Auto' 0
uvcdynctrl -d video0 --set='White Balance Temperature, Auto' 1
uvcdynctrl -d video0 --set='Focus (absolute)' 50
Set correct permissions to make it executable
chmod a+x /home/pi/bin/cam_init.sh
Enable autorun for the script
nano /home/pi/.octoprint/config.yaml
Add this at the bottom
events:
subscriptions:
- event: ClientOpened
command: /home/pi/bin/cam_init.sh
type: system
Restart the pi, and when you connect to octoprint the script will run and your settings will be set.