Source: Wei-Hao Wang – Welcome
https://lkexue.blogspot.com/2017/05/blog-post_16.html
Source: Bart Delsaert – Astrophotography
Raw bit depth is about dynamic range, not the number of colors you get to capture https://www.dpreview.com/articles/4653441881/bit-depth-is-about-dynamic-range-not-the-number-of-colors-you-get-to-capture
exposurecompensation
Source: https://parallellogram.wordpress.com/2014/09/30/controlling-a-camera-in-linux/
Controlling a camera in Linux – continued | The Parallellogram
Here is a quick guide on controlling a camera from Linux. I first messed around with this in early 2011. Without (yet) a means to move/position the camera, I have found little use for it – but perhaps you may find it useful.
Obviously there are various applications, such as bracketing (possibly for HDR), and time lapse (intervalometer), which do not require movement of the camera (indeed it should he held steady), but many cameras have support for this – since I have upgraded my DSLR, these became less relevant for me.
Once you add the ability to swivel the camera, this adds additional applications such as programing/choreographing video, or taking long exposures of the night sky (automatically tracking with the rotation of the earth). These are obviously best done with a portable setup, ideally with the ability to control motors / path via a readily available UI, such as an Android phone. Using the gyro/accelerometer available in any modern smartphone, inclination of the camera can be managed this way, if you (and your camera!) are this way inclined
You could do all this with an 8-bit micro (see previous post), and a BT UART link – but if you want to load/process the images, this is where the processing power of the Parallella comes in.
I use gphoto2, a nifty command-line app built on libgphoto2. The list of supported cameras can be found here.
Note that I have no bothered with configuring udev rules to set permissions for non-root users. I might cover this in a later post.
Install gphoto2:
sudo apt-get install gphoto2
Connect the camera (using an OTG cable). If you type dmesg, you should see something like:
usb 1-1: new high-speed USB device number 3 using zynq-ehci
linaro-nano:~> sudo gphoto2 --auto-detect
Model Port
----------------------------------------------------------
Nikon DSC D60 (PTP mode) usb:001,003
As you can see, it has detected my Nikon D60 – my old project DSLR which is the victim of my various experiments. If I want further information about the camera, the following command has useful output.
linaro-nano:~> sudo gphoto2 --summary
Now, to show we are reading the current information from the camera:
linaro-nano:~> sudo gphoto2 --get-config=/main/capturesettings/focallength
Label: Focal Length
Type: RANGE
Current: 55
Bottom: 55
Top: 200
Step: 0.01
And now I twirl the zoom knob on the 55-200mm VR lens:
linaro-nano:~> sudo gphoto2 --get-config=/main/capturesettings/focallength
Label: Focal Length
Type: RANGE
Current: 105
Bottom: 55
Top: 200
Step: 0.01
And so we see the focal length has moved from 55mm to 105mm – thus we can read the current configuration of the camera.
In previous hacking, I used an 8-bit AVR with a usb host chip to dump the current aperture, focal length, and exposure settings to an LCD screen. Note that you can also control some of the settings.
You can obtain a list of the supported settings by running
sudo gphoto2 --list-config
Say I then see the ISO setting, and want to see whether I can control this.
linaro-nano:~> sudo gphoto2 --list-config | grep iso
/main/imgsettings/iso
/main/imgsettings/isoauto
/main/imgsettings/autoiso
/main/capturesettings/isoautohilimit
linaro-nano:~> sudo gphoto2 --get-config=/main/imgsettings/iso
Label: ISO Speed
Type: RADIO
Current: 1600
Choice: 0 100
Choice: 1 200
Choice: 2 400
Choice: 3 800
Choice: 4 1600
Choice: 5 3200
So there are 6 settings I can use (the camera was already in autoiso mode – if it was not, likely this command would fail until you set the correct mode). I now wish to set it to 200.
linaro-nano:~> sudo gphoto2 --set-config=/main/imgsettings/iso=200
linaro-nano:~> sudo gphoto2 –get-config=/main/imgsettings/iso
Label: ISO Speed
Type: RADIO
Current: 200
Choice: 0 100
Choice: 1 200
Choice: 2 400
Choice: 3 800
Choice: 4 1600
Choice: 5 3200
linaro-nano:~>
And I can confirm via the camera display that it has indeed set the ISO to 200.
As for triggering a capture, I will demonstrate how to take a bracket of 3 images:
linaro-nano:~> sudo gphoto2 --set-config /main/capturesettings/exposurecompensation=12 --trigger-capture
linaro-nano:~> sudo gphoto2 --set-config /main/capturesettings/exposurecompensation=15 --trigger-capture
linaro-nano:~> sudo gphoto2 --set-config /main/capturesettings/exposurecompensation=18 --trigger-capture
This has taken a series of 3 exposures, storing them on my camera.
I’m now switching to ArchLinux since the gphoto2 2.5.3 which comes with Ewwbuntu does not seem to perform the –capture-image and –capture-image-and-download functions correctly.
With ubuntu, you can use the following workaround:
linaro-nano:~> sudo gphoto2 --list-files
and download all the photos using
linaro-nano:~> sudo gphoto2 --get-all-files
Downloading 'curve.ntc' from folder '/special'...
Saving file as curve.ntc
Downloading 'DSC_2356.NEF' from folder '/store_00010001/DCIM/100NCD60'...
Saving file as DSC_2356.NEF
....
But the way I generally do this, as shown using gphoto2 2.5.4 running on ArchLinux is:
[root@ParallellArch ~]# gphoto2 --trigger-capture
[root@ParallellArch ~]# gphoto2 --capture-image
New file is in location /capt0000.nef on the camera
[root@ParallellArch ~]# gphoto2 --capture-image-and-download
New file is in location /capt0000.nef on the camera
Saving file as capt0000.nef
Deleting file /capt0000.nef on the camera
Deleting 'capt0000.nef' from folder '/'...
[root@ParallellArch ~]# ls -l capt0000.nef; strings capt0000.nef | head -2
-rw-r--r-- 1 root root 7624570 Oct 1 20:48 capt0000.nef
NIKON CORPORATION
NIKON D60
Please see my followup post on the differences between these three commands (all of which cause the camera to take a photo).
Similarly, if I had hooked up my Nikon D7000, which has LiveView, I expect I would be able to capture a movie using <code>–capture-movie</code>. Since I have only had the D7000 for 2 years, I haven’t yet explored the added functionality this may offer in terms of controlability, but I will do so in the coming months.
My old D60 does not appear to support setting the focus at all, while apparently even on newer Nikon and Cannon cameras this is quite limited.
This is a bit disappointing, however I expect for most applications of unattended photography, you will be using autofocus, or an unchanging manual focus (say infinity, for stellar photography).
Ultimately I intend to drive the zoom ring using a motor, so may also consider doing this for the focus ring. But this is fairly far into the future, and only really needed if I implement real-time target acquisition and can manually focus on the strength of this better than the camera can (a bit of a pipe dream).
Soon, I will be exploring the Python library for gphoto2, and will provide a separate post using this.
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 focus
Type: RANGE
Current: 0
Bottom: -32767
Top: 32767
Step: 1
The 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).
$ gphoto2 --shell
gphoto2: {/home/yani} /> capture-preview
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
and 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.
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.
^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
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).
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 writed 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
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.
Nikon D810A – Shooting Guide New Frontiers in Astrophotography
Source: Nikon D810A – Home