I have made some progress in accessing still camera with gphoto2
(cf. here).
The detailed description of my set-up will be disclosed within a few weeks (as I am still not sure
if it is 100% success:-). In short:
I changed camera from Canon A620 to Nikon S3000.
I connected camera with active USB hub.
On every capture USB port is reset with usb_reset
utility
(cf here
and here)
I use two Nikon S3000 compact cameras so there is a problem how to identify which is which.
$gphoto2 --auto-detect Model Port ---------------------------------------------------------- Nikon Coolpix S3000 (PTP mode) usb:001,022 Nikon Coolpix S3000 (PTP mode) usb:001,021
So one can use --port usb:001,022
option to access first attached
camera and --port usb:001,021
to access the second one. Of
course hard-coded port numbers are troublesome as they are not fixed and change
if the device is disconnected/connected again.
Better way to identify the camera is to use it's serial number:
## $gphoto2 --get-config serialnumber --port PORT ## example $gphoto2 --get-config serialnumber --port usb:001,022 Label: Serial Number Type: TEXT Current: 000047514512
I have black Nikon with 000041076602 serial number and pink one with 000047514512 serial number. I use the following bash script to access the cameras:
#!/bin/bash PINK_CAM_ID='000047514512' BLACK_CAM_ID='000041076602' while test $# -gt 0; do case "$1" in -b|--black) REQ_CAM="$BLACK_CAM_ID";; -p|--pink) REQ_CAM="$PINK_CAM_ID";; esac shift done ## Picture filename: FILENAME="NIK`date +"%Y%m%d%H%M"`.jpg" ## Scan all attached cameras: while read PORT_ID do ##echo $PORT_ID ## -n means string is non-empty if [ -n "$PORT_ID" ] ; then CAM_ID=`gphoto2 --get-config serialnumber --port $PORT_ID | awk '/Current:/ { print $2 }' ` if [ $CAM_ID = "$REQ_CAM" ] ; then REQ_CAM_PORT="$PORT_ID" ##echo "*** Req Camera ID: #$CAM_ID." fi fi done <<< "`gphoto2 --auto-detect | grep usb | awk '{ print $6}'`" if [ -z "$REQ_CAM_PORT" ] ; then echo "*** Error: Camera $REQ_CAM not found ***" ## sent a SMS cf http://pinkaccordions.homelinux.org/wblog/sms_alerts_with_google_calendar.html sms_reminder.sh exit 1 fi ## reset the USB device REQ_CAM_PORT_DEVNAME=`echo $REQ_CAM_PORT | sed 's/^.*://' | sed 's/,/\//'` usb_reset /dev/bus/usb/${REQ_CAM_PORT_DEVNAME} LANG=C gphoto2 --port "$REQ_CAM_PORT" --force-overwrite --set-config flashmode=1 \ --set-config d002=4 \ --capture-image-and-download --filename "$FILENAME" ## reset the USB device again usb_reset /dev/bus/usb/${REQ_CAM_PORT_DEVNAME}
Property d002
sets picture resolution (4 means 2592x1944).
Value 1 of flashmode
turns-off flash.
It seems that without usb_reset
there are problems with battery charging (why?)
I would like to remote control a still camera via gphoto2
.
After consulting a list of supported cameras I bought (used) Canon A620
from Allegro (local Internet auction site, sort of E-bay).
This camera has many great features (I suspect even too great as Canon stop producing cheap cameras of this sort):
viewfinder, retractable LCD and can be powered with Compact Power Adapter CA-PS500 instead of batteries
(an important feature in my project).
The plan was simple: connect camera via USB cable to computer and power it with PSU. Capture photos periodically with
gphoto2
:
gphoto2 --auto-detect pi@raspberrystar ~/bin $ gphoto2 --auto-detect Model Port ---------------------------------------------------------- Canon PowerShot A620 (PTP mode) usb:001,006
So far, so good.
Now, I tried to capture a photo:
# one shot without flash, download the file and store in a file named as: GPHyyyymmddhhmm.jpg LANG=C gphoto2 --set-config flashmode=0 --capture-image-and-download --filename "GPH%Y%m%d%H%M.jpg"
As the creation time is wrong (due to camera wrong clock) I modified
the above as follows (note that touch
is used to adjust file's timestamp):
#!/bin/basg FILENAME="GPH`date +"%Y%m%d%H%M"`.jpg" LANG=C gphoto2 --set-config flashmode=0 --capture-image-and-download --filename "$FILENAME" touch "$FILENAME"
Unfortunately there are problems: I am able to remotely capture only one photo. Next remote capture try results in an error and the camera has to be hard reset (with power on/off button). The problem is reported by others too.
BTW: when I connected the camera to my PC the reliability is much better (but seems not perfect---I experienced camera disconnection too.)
My first try to resolve the problems was to update gphoto2
(raspbian contains version 2.4.14 of gphoto2
).
## optionally remove old version (there are no dependencies) apt-get remove gphoto2
There is no need to remove gphoto2
as compiled one
will be installed in another directory (/usr/local/
vs
/usr/
).
First install/compile the necessary packages:
apt-get install -y libltdl-dev libusb-dev libexif-dev libpopt-dev ## Download and install newer version of libusb 1.0.11 wget http://ftp.de.debian.org/debian/pool/main/libu/libusbx/libusbx_1.0.11.orig.tar.bz2 tar xjvf libusbx_1.0.11.orig.tar.bz2 cd libusbx-1.0.11/ ./configure && make && sudo make install ## Download and install newer version of libgphoto wget http://garr.dl.sourceforge.net/project/gphoto/libgphoto/2.5.1.1/libgphoto2-2.5.1.1.tar.bz2 tar xjf libgphoto2-2.5.0.tar.bz2 cd libgphoto2-2.5.1.1 ./configure && make && sudo make install
Download and install newer version of gphoto2
wget http://downloads.sourceforge.net/project/gphoto/gphoto/2.5.1/gphoto2-2.5.1.tar.gz tar xzvf gphoto2-2.5.1.tar.gz cd gphoto2-2.5.1 ./configure && make && sudo make install ## run ldconfig sudo ldconfig gphoto2 --version gphoto2 2.5.1 Copyright (c) 2000-2013 Lutz Mueller i inni
BTW compiling gphoto2
on my fedora 14 box requires
to install libtool-ltdl-devel
popt-devel
first:
#configure: error: cannot compile and link against libltdl #libgphoto2 requires libltdl (the libtool dl* library), #but cannot compile and link against it. yum -y install libtool-ltdl-devel popt-devel
Upon installing above two packages, the compilation of
libusb
, libgphoto
and gphoto2
proceeds smoothly.
Unfortunately installing new version of gphoto2
did not help.
The problem will be further examined...