Engineering and technology

DSLR focus control with gphoto2

DSLR focus control with gphoto2

If you read the documentation on gphoto2 regarding the focus control (“manual” focus as they call it) it mentions that focus control only works while liveview mode is on, and that seemed to be sufficient for Canon, but it turned out that for Nikon cameras there was more to it than just liveview.

First the necessary disclaimer though: I’ve only tried the Nikon D5100 here and Canon 550D and 600D, so YMMV.

But let’s start with liveview (or preview) mode itself first – this one is controlled by “/main/actions/viewfinder” setting in both Nikon and Canon.

Essentially it’s name is “viewfinder mode”. That’s how it’s actually called by GPhotow – when you get list of camera properties via GPhoto2 on Canon it’s name is “Canon EOS Viewfinder”, and on Nikon “Nikon Viewfinder” (key is same – “/main/actions/viewfinder” – on both). So let’s not call it liveview/preview mode anymore – it’s viewfinder mode hereafter.

Next thing to be aware of is that this mode is switched off when gphoto2 releases the camera. So running command-line tool “gphoto2” with parameters “–set-config /main/actions/viewfinder=1” is not the right way to do it – gphoto2 will enable viewfinder mode, then since no more commands are there it’s going to quit, and on quit it will release the camera, which will disable viewfinder mode.

So just run gphoto2 in interactive mode (if you use gphoto2 in command line – if you use gphoto2 library and call it’s API methods you’re fine, just be aware that doing camera release – actually the method name is gp_camera_exit – will disable viewfinder mode).

Also the viewfinder mode will disable itself after some seconds of camera inactivity (you’ll hear the clicking when it does that). Maybe this is configurable somewhere in the menus, but I didn’t find out where, and in general one should just be aware of it behaving that way by default.

Ok, so we run “gphoto2 –shell” to start gphoto2 command-line tool in interactive mode, do “set-config /main/actions/viewfinder=1”, what’s next?

Well, one more sanity check thing to do is to make sure on your lens the physical switch from auto to manual focus is set to auto – that enables your DSLR body to control the focus, but doesn’t necessarily means autofocusing. Which might be confusing for some.

Then on Canon I could just set “/main/actions/manualfocusdrive” to one of those “Near 1/2/3 or Far 1/2/3” values and that got focus engine rotate the lens accordingly. But not on Nikon.

Experimentally I’ve found out that on Nikon I also have to set these (works for me in this specific order):

  • /main/actions/viewfinder=1 (enable viewfinder mode first, as you already know)
  • /main/capturesettings/focusmode2=MF (selection) – don’t bother with
  • /main/capturesettings/liveviewaffocus=Single-servo AF
  • Then control focusing engine via /main/actions/manualfocusdrive (set to 1000/-1000 to see clear rotation)

Again, this is what I had found out on Nikon D5100 specifically, but I assume it’s more/less same for all or most Nikon DSLRs.

That’s it. Now go and programmatically control that focus on your Nikon 🙂

Source: DSLR focus control with gphoto2 | M.V.M-n.

[ubuntu] Zoneminder upgrade – 1.26 to 1.32

Thanks! as it turns out, I did indeed install 16.04 of ubuntu … however, I ended up right back where I was. I actually ended up removing ZM and totally reinstalling (dropping the database etc). As it turns out, the whole problem was the typical path issue. Unfortunately, EVERY REFERENCE I COULD FIND re: how to ensure that the script alias and PATH_ZMS variable was set correctly, referred to a console OPTIONS ==> PATH setting that is NO LONGER present on 1.32 of ZM. which brings up a curious problem as to how to ensure folks new to this level of support can possibly find the correct answers online without having to actually make a post. When the actual functionality of the product changes like this, and the old docs are still readily accessible.. it makes it difficult to keep from pulling out your hair. I was unable to figure this out until I actually SEARCHED GOOGLE for “ZONEMINDER MISSING PATH_ZMS” at which point, i found the handy site that explained as how these path variables are now in zmcustom.conf as noted here (if this is allowed https://forums.zoneminder.com/viewto…=27722#p108059

Once I realized that the path variables are now in zmcustom.conf in /etc/zm/conf.d the world was a much better place, and immediately the camera i had defined started working. I simply had to insert “/zm” in front of the default setting there. Getting a few other cameras to work was very difficult due to odd FOSCAM HD camera settings, but I finally got there. We’re back in business – though i do have to re map my zone on the motion detection camera.

Source: [ubuntu] Zoneminder upgrade – 1.26 to 1.32