Miscellaneous:USB camera howto

(Difference between revisions)
Jump to: navigation, search
m (sigh...)
Line 18: Line 18:
 
===Setting up permissions to access your camera as a normal user===
 
===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 [http://wiki.lunar-linux.org/index.php/Installation:Kernel_2.6._HowTo guide]and choose to install udev.
+
I only tested this with udev and hotplug, so that's kernel 2.6.x. follow this [[Installation:Kernel 2.6. HowTo|guide]] and choose to install udev.
  
 
In /etc/fstab add this line:
 
In /etc/fstab add this line:
Line 49: Line 49:
 
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.
 
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.
 
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.  
+
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===
 
===Downloading the pictures of the camera===

Revision as of 17:27, 1 November 2005

Contents

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