Zoom button for usbwebcam

when i want to change the octoprin webcam zoom , i login with ssh and change de zoom with this comand
v4l2-ctl -c zoom_absolute=1 , can be 1 to 5
i have included in the
/root/bin/webcamd
my default configuration

# runs MJPG Streamer, using the provided input plugin + configuration

function runMjpgStreamer {
input=$1
pushd $MJPGSTREAMER_HOME > /dev/null 2>&1
echo Running ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input"
LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" &;
v4l2-ctl -c zoom_absolute=2 &;
wait
popd > /dev/null 2>&1
} 

is it posible include a buttom in the control window to change the zoom without ssh login?

thanks a lot

postedit:
You need to have installed Custom Control Editor plugin and the mentioned GCODE System Commands plugin

Please format your config so it is readable.

Hi manueloya,

haha, cool, didn't even know my cam could do this, but it works! :smile:

I have implemented 2 buttons to zoom to 1x and 2x with the plugin "GCODE System Commands" using this Howto: How to send remote commands to second Pi from OctoPrint
Since you have no need for remote login, you can ignore the first part of the Howto. Just define 2 Command Definitions in the plugin like 'sudo v4l2-ctl -c zoom_absolute=1' with 2 different numbers and edit the 'config.yaml' file accordingly:

controls:
- children:
  - command: OCTO911
    name: C525 Zoom 1x
  - command: OCTO912
    name: C525 Zoom 2x
  name: Custom Events
  type: section

If necessary, have a look at the sudo config to make it work.

2 Likes

great
thanks a lot

with v412-ctl -l you can look all the comand options

yep, found v4l2-ctl --all, but that's equivalent, I suppose

For my camera, a Logitech C525, only zoom to 1x and 2x works, if I try 3x ... 5x nothing happens. This seems to be depending on the features of the actual camera, right?

With my Raspi-Cam e.g. the line for zoom isn't even shown with v4l2-ctl --all, so obviously this camera cannot zoom at all.

i try to include in the confgi.yaml

controls:
- children:
  - command: OCTO911
    name: C525 Zoom 1x
  - command: OCTO912
    name: C525 Zoom 2x
  name: Custom Events
  type: section

and the octoprint doesnt restart , is de code ok?

The keygen part of that tutorial though was necessary so that the pi user can do password-less sudo (even if remotely). In order for OctoPrint to be able to do password-less sudo for that v4l2-ctl command you'll need to create a file in the /etc/sudoers.d folder similar to the technique talked about here.

I "copy&past"ed the code right out of my config.yaml file, so it should be ok.
I am working in a linux-only environment. Do you have Windows? How have you edited the config.yaml file? I don't know how robust the config.yaml file is regarding white space, blank lines and Windows line-end vs. Linux line-end handling...

v4l2-ctl doesnt need sudo exec, no necesary password-less sudo command

1 Like

I guess they need to be removed in the configuration as seen in the first post.

I have a Logitech C525. When connected to a PC it can Zoom, Pan and Tilt a little bit.

I've been able to get mine to Zoom to three different levels and Pan to the Left and Right. I haven't been able to get the Tilt working though.

config.yaml contains:

controls:
- children:
  - command: OCTO911
    name: Zoom 1x
  - command: OCTO912
    name: Zoom 2x
  - command: OCTO913
    name: Zoom 3x
  - command: OCTO920
    name: Left
  - command: OCTO921
    name: Center
  - command: OCTO922
    name: Right
  name: Custom Events
  type: section`

Settings/ GCODE System Commands

image

On the "Control" tab the buttons appear aligned vertically.

Does anyone know how we can arrange the buttons horizontally instead of vertically?

From Pimp my web interface ...add Themeify and then create the two custom ones marked "form.custom_control".

form.custom_control didn't work?

This seems to take precedence?

#control 
.custom_section_vertical>.custom_control {
display: block;
}

Not sure what to tell you since this technique works on mine, nicely making the custom buttons go horizontally across the page with a 10px padding between them.

I didn't add all items from your list, maybe it depends on some more of the lines?

EDIT: can't see which one that could possibly be...

It only requires the two as indicated and probably a page reload.

caching maybe... shift f5 doesn't help... let me see...

EDIT:
nope, stubborn one... it's horizontal at first but after a second or so it pops down to vertical.

I wonder where the "ko" "/ko" "if: layout == horizontal" stuff originates from in the code base...

You mean here in control.jinja2? So in theory, something above this level has a key/arg pair of something like layout: horizontal. You would think that this would be the ViewModel for Control. Which takes us to here in the docs for custom controls.

Wow. I got it to work (without Themeify this time).

Be super careful about editing your config.yaml. If you put the attribute in the wrong place it simply won't come up.

53%20AM

1 Like