Last post, I looked at what we could do on my old Nikon D60 DSLR connected to the Parallella using both Ubuntu and ArchLinux. This time, I will see what extended options there are on a newer DSLR, in this case the Nikon D7000.
As there are some issues with the 2.5.3 version shipping with Ubuntu, so I will use ArchLinux for this post also.
I found with the D7000 that unless I turned the camera on before connecting the USB, it failed to enumerate. This was true with both my desktop and the Parallella (both of which run ArchLinux).
Unlike the D60, as I hinted at last time, the D7000 supports driving the focus. Although this is restricted to LiveView mode.
[root@ParallellArch ~]# gphoto2 --get-config /main/actions/manualfocusdrive Label: Drive Nikon DSLR Manual focusThe only way I have been able to make use of the focus is by entering the interactive shell - when you use gphoto2 in this manner, the mirror remains locked up after a call to capture-preview (if you call it non-interactively, it will drop immediately after capturing a preview image).
Type: RANGE Current: 0 Bottom: -32767 Top: 32767 Step: 1
$ gphoto2 --shell gphoto2: {/home/yani} /> capture-previewand so I see the focus ring driven back and forth. The call to capture-preview causes the mirror to be left up. As soon as you exit the shell, you will hear the mirror being dropped.
Saving file as capture_preview.jpg gphoto2: {/home/yani} /> set-config /main/actions/manualfocusdrive=-500 gphoto2: {/home/yani} /> set-config /main/actions/manualfocusdrive=500 gphoto2: {/home/yani} /> set-config /main/actions/manualfocusdrive=-500 gphoto2: {/home/yani} /> set-config /main/actions/manualfocusdrive=500 gphoto2: {/home/yani} /> exit
I can also record LiveView movies using
[root@ParallellArch ~]# gphoto2 --capture-movie Capturing preview frames as movie to 'movie.mjpg'. Press Ctrl-C to abort.The resultant motion JPEG file can then be loaded directly into smplayer. You can of course convert this to something like mpeg or avi (for example using ffmpeg or mencoder).
^C Cancelling... Ctrl-C pressed ... Exiting. Movie capture finished (162 frames) [root@ParallellArch ~]# ls -l movie.mjpg; file movie.mjpg -rw-r----- 1 root root 5285244 Oct 1 09:30 movie.mjpg movie.mjpg: JPEG image data, baseline, precision 0, 4360x426
But after each operation, the mirror is lowered. According to this post (dated 2012), locking up the mirror on a Canon is no small feat. However I am sure I must be missing something.
There are other cool things you can do, which may be useful in my project down the track, so I will give them a mention here. You can select the currently lit AF point. The D7000 has a 39-point AF. Mine was set to 2, so I reprogrammed it to 22. I did this while peering into the viewfinder and saw it immediately move. This represents a nifty ability to programmatically configure where the camera will focus, by determining which quadrant the subject will be in (by whatever means), and telling the camera to autofocus on that part of the AF matrix.
[root@ParallellArch ~]# gphoto2 --get-config d108 Label: Active AF Sensor
Type: MENU Current: 2 Choice: 0 1 ..... Choice: 38 39 [root@ParallellArch ~]# gphoto2 --set-config d108=22 [root@ParallellArch ~]# gphoto2 --get-config d108
Label: Active AF Sensor
Type: MENU Current: 22
Since my D7000 shoots in JPG+RAW, I get two images each time I take an exposure:
[root@ParallellArch ~]# gphoto2 --capture-image-and-download New file is in location /capt0000.jpg on the camera
Saving file as capt0000.jpg Deleting file /capt0000.jpg on the camera Deleting 'capt0000.jpg' from folder '/'... New file is in location /capt0001.nef on the camera
Saving file as capt0001.nef Deleting file /capt0001.nef on the camera Deleting 'capt0001.nef' from folder '/'...
I mentioned in my previous post that I would explain the differences between --trigger-capture, --capture-image, and --capture-image-and-download. The first simply causes the camera to take an exposure, so is the command to use if trying to take a short burst with varying exposure settings (a bracketed shot). While you won't then see any new photo if you use --list-files (and it won't be saved to the SD card), a subsequent download will indeed fetch the photo. The second causes an image to be capture, sent over PTP, and ultimately discarded. I think this command is utterly pointless. All it tells you is what the captured file was named (but at the huge inefficiency of sending the whole file!). The final option captures an image, and then downloads ALL files. So if you previously used --trigger-capture, it will send you your file. However if you previously used --capture-image, it will not send you both - it will replace the existing file! Confused? Good - not the most intuitive interface.
Here is an example of me taking a bracketed exposure, and then retrieving the files
[root@ParallellArch ~]# gphoto2 --set-config /main/capturesettings/exposurecompensation=12 --trigger-capture [root@ParallellArch ~]# gphoto2 --set-config /main/capturesettings/exposurecompensation=15 --trigger-capture [root@ParallellArch ~]# gphoto2 --set-config /main/capturesettings/exposurecompensation=18 --trigger-capture [root@ParallellArch ~]# **gphoto2 --capture-image-and-download New file is in location /capt0000.jpg on the camera
Saving file as capt0000.jpg Deleting file /capt0000.jpg on the camera Deleting 'capt0000.jpg' from folder '/'... New file is in location /capt0001.nef on the camera
Saving file as capt0001.nef Deleting file /capt0001.nef on the camera Deleting 'capt0001.nef' from folder '/'... New file is in location /capt0002.jpg on the camera
Saving file as capt0002.jpg Deleting file /capt0002.jpg on the camera Deleting 'capt0002.jpg' from folder '/'... New file is in location /capt0003.nef on the camera
Saving file as capt0003.nef Deleting file /capt0003.nef on the camera Deleting 'capt0003.nef' from folder '/'... New file is in location /capt0004.jpg on the camera
Saving file as capt0004.jpg Deleting file /capt0004.jpg on the camera Deleting 'capt0004.jpg' from folder '/'... New file is in location /capt0005.nef on the camera
Saving file as capt0005.nef Deleting file /capt0005.nef on the camera Deleting 'capt0005.nef' from folder '/'... New file is in location /capt0006.jpg on the camera
Saving file as capt0006.jpg Deleting file /capt0006.jpg on the camera Deleting 'capt0006.jpg' from folder '/'... New file is in location /capt0007.nef on the camera
Saving file as capt0007.nef Deleting file /capt0007.nef on the camera Deleting 'capt0007.nef' from folder '/'...
What just happened? Why 8 images? Remember I am shooting RAW+JPG - so each exposure generates two files. Finally, because --capture-image-and-download causes a final image to be taken, the 3 shots results in 8 images. I could have substituted --trigger-capture with --capture-image-and-download for the last shot, and not generated any wasted captures/transfers.
Note that all of the above wrote photos to SDRAM only - which can then be retrieved via USB. In order to save to the camera's internal SD cards (the D7000 has dual slots), I found you need to use
[root@ParallellArch ~]# gphoto2 --set-config=capturetarget=1
If you keep track of the number of the last recorded image, take a flurry of shots, it should be possible to query the list of available files and selectively retrieve just the newer ones you wish to store, process, upload to the cloud, or whatever.
Obviously this is the only mode you should use for the likes of my earlier 8-bit AVR driven approach, since I had a device triggering the captures which had nowhere near the capabilities required to retrieve and store the photos. This is no issue with the Parallella - but in the interests of preserving backups of photos, limiting the need to saturate the USB link fetching photos too often, and risking losing un-fetched images, I intend to save to the SD card always, and then only retrieve photos as needed.
Obviously there are a whole lot of other functions I would like to explore, in particular things like focus lock and exposure lock for taking panoramas, or preventing AF from hesitating at the wrong moment when you have a shot all setup, but it wants to seek. I will add further details as I explore these. I am not sure how much will require the camera to be correctly configured via the UI, and how much we can do via USB control. Since the D7000 provides two save slots for the entire camera configuration, which can then be saved to and restored from card, it is not too onerous to use a different card when I go out shooting versus when in the platform - but not all cameras afford this luxury, and I prefer the idea of programming it via PTP.