[KimDaBa] Import from camera

Shawn Willden shawn-kimdaba at willden.org
Fri Oct 29 18:32:29 BST 2004

Hash: SHA1

On Friday 29 October 2004 05:48 am, Robert L Krawitz wrote:
> 1) I'm assuming that something recognizes the "usbcam" and matches it
> against the device.  I prefer to use a card reader because it's a lot
> faster than hooking my camera up (the card reader is USB 2.0, whereas
> my camera is 1.1).

I can see where that would be an issue when you're downloading RAW 6.3MP 
images with embedded large/superfine JPEGs!

> 2) I have multiple cameras (my wife's and mine) and want to import
> them into different directories.  Any tips for distinguishing between
> two cameras?
>    - ----------cut here---------------
>    GROUP=camera
>    if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
>    then
>        chmod o-rwx "${DEVICE}"
>        chgrp "${GROUP}" "${DEVICE}"
>        chmod g+rw "${DEVICE}"
>        sudo -u shawn /home/shawn/bin/got_camera.sh
>    fi
>    - ---------cut here----------------

It should be easy to do.  Basically, you need to have the script figure out 
the model of the camera.  I can think of three ways:

First, the script that is called by hotplug (usbcam, above) has a few other 
environment variables available to it.  One of them, "PRODUCT" contains the 
vendor ID, product ID and revision number.  For example, for my G2 $PRODUCT 
contains 4a9/3055/1.  You could test this value in the usbcam script and do 
different things based on the result.

Second, you can look through /proc/bus/usb/devices.  For example, my devices 
file currently contains (among other stuff):

T:  Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  9 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=ff(vend.) Sub=ff Prot=ff MxPS=32 #Cfgs=  1
P:  Vendor=04a9 ProdID=3055 Rev= 0.01
S:  Manufacturer=Canon Inc.
S:  Product=PowerShot G2
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=96ms

Grepping that for "PowerShot G2" would result in a hit.  Some cameras (not 
mine) also include "SerialNumber" attribute that shows up 
in /proc/bus/usb/devices.  For cameras that provide this, it might be really 
nifty to key not only on the camera model, but also on the specific camera.

Third, ask gphoto2.  During every operation, gphoto2 displays the model of the 
connected camera.  You could run "gphoto2 -a" (list camera abilities) and 
grep for a model string.

So, something like:

gphoto2 -a | grep -q "Rebel"
if [ $? -eq 0 ]; then

I think the nicest way to do it would be to use gphoto2 to ask the camera for 
it's "Owner name", but I can't find a way to get that information 
non-interactively.  "gphoto2 --config" gives me a text mode interface I can 
navigate through to get the information, but I can't find a way to ask for it 
directly.  I imagine it wouldn't be too hard to write a little program to get 
the info using libgphoto2, but I haven't looked into it.

I'd also like a command-line interface for the "set camera date/time to PC 
date/time" option, so that I could automatically synch my camera's clock 
every time I plug it in, but I haven't found a way to do that, either.

Version: GnuPG v1.2.5 (GNU/Linux)


More information about the Kphotoalbum mailing list