Logitech c920 journey


#1

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

example: uvcdynctrl --device=video0 --set="Sharpness" 255

I found a list of adjustable parameters by running: uvcdynctrl -c

Back to the auto zoom dilemma- I first had to disable it to use the manual zoom

uvcdynctrl --device=video0 --set="Focus, Auto" 0
disabled the auto focus, then

uvcdynctrl --device=video0 --set="Focus" 18
to start finding the right value for my situation

More info can be found at: http://www.linux-commands-examples.com/uvcdynctrl


#2

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.


#3

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 

edited:(verbage)


Step by step to disable auto focus for logitech C920
#4

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.


#5

Are you getting any errors when setting focus? If not, perhaps find another avenue to run the script on login/startup!?


#6

Anyone have more details for linux newbie?

Would like to setup c920 webcam to use h264 streaming/timelapse.


#7

Hi @Sudo
You may have a look at this thread.


#8

@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.


#9

Try searching the forum for "h264". You might be surprised that someone has already worked on that.


#10

Didnt find a working solution


#11

#12

@Sudo You can get a working x264 stream from c920/c930e using the commands on this page: https://wiki.matthiasbock.net/index.php/Logitech_C920,_streaming_H.264

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.


#13

One could write a plugin to use jQuery to make the change on that tab.