Miscellaneous:USB camera howto

(Difference between revisions)
Jump to: navigation, search
m (stub...)
Line 1: Line 1:
 
{{Template:Howto-stub}}
 
{{Template:Howto-stub}}
  
 +
== Does you camera supports usb storage ? ==
 +
 +
Check if your kernel supports usb storage and SCSI disks:
 +
<code>
 +
modprobe -l
 +
</code>
 +
Look for a module named usb-storage, and another named sd.
 +
If you have compiled SCSI disk support in your kernel (as opposed to a module) you could check this looking for 'sd' in /proc/devices.
 +
 +
Plug your camera in the USB connector. And type :
 +
<code>
 +
dmesg | tail
 +
</code>
 +
If something tells you that an SCSI device has been attached, then you could use your camera as a removable disk.
 +
 +
'''Mount setup'''
 +
 +
Add a line like this one in your /etc/fstab:
 +
<code>
 +
/dev/sda1 /mnt/usbflash vfat rw,noauto,user,noexec 0 0
 +
</code>
 +
In fact you also need the vfat support (Microsoft Windows 9x filesystem).
 +
 +
That's it!
  
 
== Get pictures from your camera with gphoto2 ==
 
== Get pictures from your camera with gphoto2 ==

Revision as of 00:37, 22 November 2005

Contents

Does you camera supports usb storage ?

Check if your kernel supports usb storage and SCSI disks:

modprobe -l

Look for a module named usb-storage, and another named sd. If you have compiled SCSI disk support in your kernel (as opposed to a module) you could check this looking for 'sd' in /proc/devices.

Plug your camera in the USB connector. And type :

dmesg | tail

If something tells you that an SCSI device has been attached, then you could use your camera as a removable disk.

Mount setup

Add a line like this one in your /etc/fstab:

/dev/sda1 /mnt/usbflash vfat rw,noauto,user,noexec 0 0

In fact you also need the vfat support (Microsoft Windows 9x filesystem).

That's it!

Get pictures from your camera with gphoto2

Installing gphoto2

# lin -cr gphoto2

This will install the required libgphoto2 which in turn will demand installing libusb and libexif... i said yes to both.

"libusb" "For usb camera support" say "yes"
"libexif" "For EXIF tag support" say "yes"

Now run the next command as a normal user

$ gphoto2 --list-files

This should result in a complete mess of error messages with the main conclusion :

gphoto2-port(0): Could not release interface 0 (Operation not permitted).

If we would like to, we could get the pictures of our camera with the root account but as this is not very convenient we'll setup some permissions for our camera so a normal user can access the camera.

Setting up permissions to access your camera as a normal user

I only tested this with udev and hotplug, so that's kernel 2.6.x. follow this guide and choose to install udev.

In /etc/fstab add this line:

usbfs  /proc/bus/usb   usbfs defaults       0 0

Add a new group "usb" and make sure that the user (*username*) that has to access the camera is part of that group.

# groupadd -g 31 usb
# usermod -g usb *username*

Just write the output of /usr/lib/libgphoto2/print-usb-usermap to the /etc/hotplug/usb/usbcam.usermap file:

# /usr/lib/libgphoto2/print-usb-usermap > /etc/hotplug/usb/usbcam.usermap

Copy /usr/share/doc/gphoto2/linux-hotplug/usbcam.user to /etc/hotplug/usb/usbcam

# cp /usr/share/doc/gphoto2/linux-hotplug/usbcam.user /etc/hotplug/usb/usbcam

edit /etc/hotplug/usb/usbcam and change the line :

user=ROOT 

to

user=*username*
  • note : If you have multiple users that have to be able to access the camera copy the file usbcam.group and add all your users in that group.
# chmod +x /etc/hotplug/usb/usbcam

Plug in the camera and switch it on. The kernel will now notice that your camera has been connected and will find no kernel driver for the device, next it will ask hotplug to do something about the new device file. Hotplug will then look into /etc/hotplug/usb/*.usermap and find that the usbcam script is to be called for the newly attached device. Thus /etc/hotplug/usb/usbcam is executed, and will set the device permissions correctly. Your /var/log/messages syslog file will contain some messages to that effect. You will probably want to check whether the respective device file has its permissions set up correctly. Have a look at /proc/bus/usb with ls -lR /proc/bus/usb. There should be at least one device file (named something like 015) with the permissions set according to your wishes.

Downloading the pictures of the camera

Just as a normal user in your home directory, perform following commands:

$ gphoto2 --list-ports
$ gphoto2 --auto-detect
$ gphoto2 --summary
$ gphoto2 --list-files
$ gphoto2 --get-all-files

Now you shouldn't see any of the errors anymore and the pictures should be downloaded to your home-directory or to wherever you want them to be downloaded A little variation of this command can make change the filename to the date that it has been pulled of the camera. Make sure the directory 'MyPictures' exists already.

$ gphoto2 --get-all-files --filename ~/MyPictures/'%y-%M-%d-%n'.jpg

Links

link Gphoto homepage

Personal tools
Namespaces
Variants
Actions
Wiki Navigation
Project Sites
Toolbox