Gphoto2 has several options for capturing and downloading images from these cameras. There is a command line interface, and a python library as a wrapper.
From the command line interface, the user can call --capture-image to trigger an image capture not not download it, and --capture-image-and-download to capture an image and download it from the camera onto the computer, however the download process takes around two seconds before the next image can be taken, as the camera stores the image on the SD card first. The a5100 has the option of liveview image download through --capture-preview, which instantly captures and downloads a 720p image.
The python library, called python-gphoto2, wraps most of the functions of the command line interface and allows better control of the camera in code. The best way to capture images using the python wrapper is to trigger capture using trigger_capture
, and download it directly from the camera, bypassing the SD card, using the wait_for_event
function, which waits for an event (such as a new image file appearing in the camera). See this example, and add a trigger_capture
call before the wait_for_event
call. A more refined version is implemented in flightsoftware, which waits until 0.5 seconds after the previous image capture to trigger the next capture, to keep the image capture interval more consistent.
The See3Cam_CU135 (colloquially known as the "See3Cam") is a 13 MP camera developed by e-con Systems, featuring a 1/3.2" sensor. It supports all M10/S-mount lenses, typically used on CCTV systems, provided that the lens supports it's given sensor size or larger. Although this camera is typically shipped with a USB-C port, our camera uses the micro-USB3 (standard micro-usb but wider). It is generally recommended to always use this camera on a USB3 port to ensure maximum throughput.
General specifications can be found here.
If you are using python-opencv
, you must set resolutions before capturing frames:
Get all possible resolutions of camera in a Linux Terminal:
Set Exposure Command
The datasheets about the board are labeled as the USB-C model. Please disregard this, for our model actually uses the micro-USB3 standard.
The Lens Datasheet is for the included lens currently on the See3Cam.
The Arducam 4 is a third-party version of the Raspberry Pi V2 Camera Module in possession by TJUAV.
The technical specifications for this standard can be found here.
The Sony α5000 (known as the a5000) is a 20.1 MP camera developed by Sony using an APS-C sensor (1.53x sensor crop).
The α5100 is another APS-C mirrorless camera that is dimensionally identical to the α5000 but has a slightly higher resolution 24.3MP sensor, and supports liveview download
Both cameras can be controlled using gphoto2.
The a5000 can take images up to 5456x3632 in resolution, while the a5100 can take images up to 6000x4000 in resolution. Both can take up to 1080p60 video, up to a 30 minutes in length.
This guide is using an a5100 because that is what we should be using over the a5000 for flights. If, for some reason, the a5100 breaks and we need to use the a5000, the steps are the same except that you need to press the center dial button when you see the "Running on NTSC" screen at startup and that you don't need to worry about digital zoom. I recommend keeping the second camera that is not on the plane on charge so that you can swap the batteries between the two if the battery on the plane camera runs out.
Making sure the PCB is switched off with the switch on the edge of the board, remove the PCB from the gimbal by unscrewing the M3x12mm screw on it and sliding it out of its slot.
Insert the camera into the gimbal frame and fasten with the 1/4"-20 x 1/2 inch bolt in the tripod mount. Plug the microUSB cable into the camera.
Remove the lens cap on the camera. Keep the lens cap somewhere safe, and be careful not to scratch or smudge the lens while it is exposed
4. If a flight is about to happen, turn on the camera with the power switch on the shutter release. The lens should extend outwards. Do not power the camera on unless a flight is going to happen soon, because the battery will drain while it is powered, even if it is plugged into USB. Keep the camera off between flights and repeat the steps below each time when turning it back on. Periodically check the battery percentage, and swap the battery out or take the camera out and charge if needed.
5. Make sure the exposure settings are set properly. We want aperture auto mode, ISO 800, and aperture F10. If these settings are not displayed as they are in the image below, press the DISP button (up on the dial) until they are.
6. If exposure mode reads something other than A, press the center button on the dial and turn the dial until it reads Aperture Priority, then press the center button again to select and return to the main display
7. If aperture reads anything other than F10, turn the dial while on the main display until it does read F10.
8. If ISO reads anything other than 800, press the ISO button (left on the dial) and use the up and down on the dial until 800 is selected, then press center to return to the main display.
9. Optionally, or if flight software is not working properly, you may set an exposure compensation manually. This is necessary to make sure the targets are not washed out. Press the exposure comp button (down on the dial) and use the left and right dial buttons to select an exposure comp setting. My guess at a good setting is around -2, but change as needed between or during flights
10. Set zoom to 50mm with NO DIGITAL ZOOM. Use the W/T power zoom switch to move the zoom so that the display reads 50mm but does not show a magnifying lens icon with an x1.(something) number. The bar should be about halfway between W and T
11. Set focus distance to anywhere around 5-50m (doesnt really matter because of the F10 aperture). Twist the outer ring on the lens until the bar in the bottom of the display reads a distance between 5 and 50m
12. Now that all settings are set, slot the gimbal PCB back into the slot and fasten it with the M3x12mm bolt. Hand tight is fine. Be extremely careful not to bump any of the controls, like the W/T switch or the focus ring.
13. On the gimbal PCB, flick the power switch on the edge of the board to turn it on and enable stabilization. If you need to remove the PCB to access the camera again, remember to turn it off first.
The camera is now ready for flight. After the flight finishes or if a period of waiting is anticipated, turn off the camera to save battery and redo all these steps above after turning it back on. If the images are too blurry from motion blur, you may choose to set a slightly lower F number aperture or a higher ISO. Avoid going over 1250 ISO or F8 aperture, as a rule of thumb. REMEMBER TO PUT THE LENS CAP BACK ON THE CAMERA.
The lens should retract when you turn the camera off. If it doesn't, this indicates that the camera is still processing something, and if it doesnt for a long time then the camera has probably frozen. Taking the battery out and putting it back in, then turning the camera back on and off tends to fix this.
Several settings in the camera must be set before using with gphoto2. First, the camera must be set to connect to USB by PTP mode to be controlled by gphoto. The camera should be placed in aperture auto exposure mode and manual focus mode, as autofocus takes several seconds at each capture.
Menu > Setup > 2nd tab > USB Connection > PC Remote
Menu > Camera Settings > 3rd tab > Focus mode > Manual Focus
Some extra settings I recommend changing are to disable the Audio Signals and Auto Review
Menu > Setup > 1st tab > Audio signals > Off
Menu > Custom Settings > 1st tab > Auto Review > Off
Higher ISOs mean a grainier but brighter image. Experimentally, Sony APS-Cs do well at up to 1250 ISO, past which the grain becomes quite noticeable.
Aperture is the size of the opening in the lens. Larger f-numbers (the measure of aperture) mean a smaller opening, less light coming through, but a larger depth of focus. A wide aperture shot will have a much blurrier background than a small aperture shot. For our purposes, we prefer small aperture (larger f-numbers), because we want images to be in focus even if the set focus distance varies from the actual distance. At F/10, for example, 10 meter focus distance is still able to capture a target 50 meters away in focus.
Shutter speed is the amount of time (in seconds) that the shutter is open and exposing light onto the camera sensor. Slower shutter speeds mean more light, but more motion blur. We prefer fast shutter speeds so that the aircraft and camera gimbal's movements do not show in the image.
Remember that for CV purposes, we prefer underexposed (darker) images over overexposed images, as overexposure destroys the contrast between colors on a target.
The a5000 and a5100 do not charge while powered on, which means their batteries will drain even when connected to the Pi over USB. There is no way to avoid this except good battery management.
Looping and saving using Python's gphoto2 library may cause the α5000 to reboot.
Sometimes the camera takes a second or two longer between a couple captures every 30 or 40 images or so at 0.5 seconds per image
Although most aspects of the camera can be controlled using gphoto2, it is impossible to focus and zoom an attached lens.
The camera can be switched to Autofocus-S (Single Shot Autofocus) then back to manual after taking a photo to refocus the camera if necessary.
There is no known method of zooming/retracting an attached lens remotely even if the lens allows powered (i.e. not done by hand) zooming. There is a zoom value in gphoto2 when tethered but it doesn't do anything
The a5100 has an obnoxiously loud shutter, because the camera plays an artificial shutter sound on its speakers. It is not possible to disable this without firmware tweaks