Plugin Request: Webcam controls


#1

I have a simple request. Not all of us are great with operating systems and command line commands, so it would be great if someone had a plugin that would put webcam controls on Octoprint's controls tab. Exposure, zoom, focus, etc. would be great to play with since each of us has a different way of mounting our webcams and the standard settings don't always work well. For instance, my webcam is overexposed and the autofocus wants to focus on the far back pillar of the printer's structure. I have to manually tone the exposure down and bring focus back to the center of the print bed. It would be SO much easier if someone with the programming chops to do it made some click buttons and sliders for the main configurable webcam parameters and a way to store settings for easy retrieval of different settings that work well for each user.


Camera and Light controls
#2

Octolapse can do this, though it will take a bit of settings trickery to get them to apply without taking a timelapse.

See this link for info regarding how to get custom webcam image preferences working (only works with mjpegstreamer at the moment, which is what ships with OctoPi) with Octolapse. As you will read this requires some edits to octopi.txt and will expose the camera control.htm page (you're not using port forwarding are you?), FYI.

You have two options here:

  1. You can configure Octolapse and your webcam according to the link above, then edit your 'snapshot profile' and set all of the 'extruder trigger requirements to forbidden. This will prevent any and all snapshots from being taken. This way Octolapse will configure your camera settings automatically before each print. However, Octolapse really wasn't designed for this, and I've never tried it, but I THINK it should work.
  2. You could just disable Octolapse entirely and manually click the 'Apply Now' button within the camera profile settings. This way you can save all of your settings and make adjustments as necessary (focus) before each print.

Perhaps I'll think about splitting this portion of Octolapse into a separate plugin. I already want to do this with some other bits (extruder position/state tracking, gcode parser, etc), but I wouldn't wait around :slight_smile: There are quite a few other things in the queue!

Let me know if that helps.


#3

Well, that bites. I just started an 18 hour print before I read this. I'll get back to you.

Also, no port forwarding. That's a no-go.


#4

The "apply now" method through Octolapse worked to change the settings. However, the values for the settings populated in Octolapse were nowhere near the settings on my webcam and trying to adjust one setting fragged it pretty good. I changed the value for the exposure, thinking everything else would remain unchanged and BAM. Perhaps having Octolapse read existing settings and populate that setup screen with them would be a good idea. It took me a long time to get a usable picture back; the way Octolapse just overwrites settings with arbitrary numbers put into those boxes by Octolapse itself completely screwed up my webcam.

Also, consider adding sliders that easily and quickly allow a user to adjust one setting at a time, and you've got something useful on your hands.

As it stands, the Octolapse method to change webcam settings is flawed and gives insufficient warning that it's likely about to change all of the numerical webcam settings to the values that are populated arbitrarily by Octolapse code. Consider doing away with one button changing every setting if Octolapse isn't polling the webcam/OS to initialize setting values to reflect the existing settings for the connected webcam.

Thanks for your efforts on writing this plugin!


#5

@thehammer,

Thanks for your feedback. Sorry you had so much trouble with your camera image. As far as I can tell there is no way to poll the current settings, but I'll take a second look to see if that's possible. Maybe there's something I missed. You might want to check out the default control.htm page ( should be at {ip_address_of_pi}/webcam/control.htm ) to see how it reacts. You'll notice that the numbers in there are NOT the current camera settings either, so I suspect this is some fundamental limitation (though I might be wrong).

Regarding the use of sliders and improved control, you'll be glad to know that this is already in the works :slight_smile: I also make these same controls accessible within the octolapse tab for quick access.


#6

Awesome. Can't wait to get the update when they make it in and can see them implemented.


#7

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 bottom in the control window to change the zoom without ssh login?

thanks a lot


#8

saw this thread and I have a similar wish for a webcam control plug in @FormerLurker have you made any progress ?


#9

What's the best way to get back to the default webcam settings which were pretty OK, after messing them up but good with octolapse (which I have decided not to use, I appreciate it but just not that into it).


#10

@Brent_Myers,

I've been sick for the last week, so I didn't have a chance to respond, sorry. I just finished another huge project for the next release of Octolapse, and have a bit more to do before it's ready for testing. Once that is complete I plan to add the enhanced webcam controls. This should all be done before the next release goes out. There's really not that much to do besides adding some slider controls and a stream preview, so I'm not too worried about it. I'm going to also try to implement a 'restore defaults' that reverts things back to the camera defaults IF I can figure out how to do that.


#11

get well, thank you for the update. I am excited for this camera control plug in.


#12

Are you planning a separate plug in for web cam controls ?


#13

I was not planning to do a separate plugin, but I suppose it is possible. It actually wouldn't be a simple plugin, though, because a lot of code needs to go into it. I'll think about this.


#14

And then Brent_Myers shipped a box of 20 different webcams to FormerLurker and he was happy. The End. :credits roll:


#15

Ok, I just completed my first stab at this, and I think it turned out pretty well! It's currently pretty tightly coupled to Octolapse at the moment, but I'll consider exporting it into a separate plugin at some point. At the very least I'll try to make the code more reusable in case someone else wants to do that :slight_smile:

Here is a link to my patreon post on the webcam settings controls, including screen caps of the new page. Let me know if you have any questions or comments!


#16

Nice!! Looking forward to this for webcam!