I found myself wanting some timelapses of long running prints, so I turned to OctoPrint.
After mounting the camera, I found myself with the dilemma of the auto focus.
I could not find enough information in one place, and not being one to back away from a fight- I started a pot of coffee (which turned into 3 by the end of it) and started digging- these are my findings, so your mileage may vary.
through ssh-
Install uvcdynctrl with: sudo apt-get install uvcdynctrl
using the command: uvcdynctrl --device=video0 --set="enter your parameter here" your numerical value
If you are using MJpegStreamer and enable the 'control.htm' page (instructions to follow), you can use that page to figure out what settings will work. That should save you some time. However, the settings show on this page are NOT the values that the camera is currently using, and the settings change INDIVIDUALLY after you make an alteration.
You COULD use Octolapse. It can adjust the camera settings automatically at the beginning of a print. You can disable the stabilization, rendering, and snapshot profiles if you don't want to use Octolapse for anything else except changing your camera settings at the beginning of each print. See this section of the Camera page wiki from the Octolapse wiki: https://github.com/FormerLurker/Octolapse/wiki/Camera-Profiles#custom-image-preferences
There is a link within the guild that contains info on how to enable control.htm, so be sure to follow that.
I use v4l2-ctl to control my c920 and run a script. Use v4l2-ctl -l to view the parameters you can control with the camera. The script is crude and simple but work for me:
#!/bin/bash
####################################
#
# adjlc920 - v4l2-ctl simple setup for logitech c920 for octoprint use. iterate through array
# to execute the commands vcmd[]. If there is an error, log the error in
# syslog and quit. If all commands execute print success in syslog. I run it
# on reboot in rc.local but you can run it from the terminal if you wish
#
# this will work for any camera. the controls will vary based on the cam. use
# v4l2-ctl -l to list the controls you can adjust
#
# CAUTION: this will exit your rc.local script if it fails. place it cautiously
#
####################################
# quit if v4l2-ctl cannot be found
if [ ! -f /usr/bin/v4l2-ctl ]; then
echo "adjlc920 - /usr/bin/v4l2-ctl unavailable"
exit 2
fi
# the v4l2-ctl commands I want to run in the order I want to run them
# (to find the controls you can use the command v4l2-ctl -l)
vcmd[0]="/usr/bin/v4l2-ctl -c focus_auto=0"
vcmd[1]="/usr/bin/v4l2-ctl -c focus_absolute=25"
vcmd[2]="/usr/bin/v4l2-ctl -c zoom_absolute=105"
vcmd[3]="/usr/bin/v4l2-ctl -c white_balance_temperature_auto=0"
vcmd[4]="/usr/bin/v4l2-ctl -c white_balance_temperature=6500"
exe=${vcmd[0]%% *} # this is the command i.e. /usr/bin/v4l2-ctl
logstring="V4L2-CTL"
for cmds in "${vcmd[@]}"
do
cmdarg=${cmds:21} # get the argument to command
$cmds # execute v4l2-ctl command(s)
if [[ $? != 0 ]] # if error
then
failed=1
logger -t $logstring $cmdarg failed! # log err to syslog - look up in /var/log/syslog
break # break out of loop
fi
done
if [ -z $failed ]; then logger -t $logstring Success!; fi
exit
I've tried your script and it works for all the controls besides setting focus_auto=0, whenever I reboot it's always still a value of 1 for some reason. Any suggestions?
I put the script in rc.local as you did and only added a few other v4l2 commands to the end.
@Ewald_Ikemann thanks for the read. Looks like it's porting same format over to ffmpeg. I'm looking for a h264 format change to stream to reduce overhead on bandwidth and cpu cylces.
You wont be able to use them with OP until the html tag used will be changed from <img> to <video>. Until then you'll have to use some program to view those streams (like vlc or mplayer). So it's pretty much unusable right now for those of us that want everything on the OP page.