Miscellaneous:USB camera howto

(Difference between revisions)
Jump to: navigation, search
 
Line 3: Line 3:
 
===install gphoto2===
 
===install gphoto2===
  
  lin -cr gphoto2
+
  # lin -cr gphoto2
  
 
This will install the required libgphoto2 which in turn will demand installing libusb and libexif... i said yes to both.
 
This will install the required libgphoto2 which in turn will demand installing libusb and libexif... i said yes to both.
Line 9: Line 9:
 
  "libusb" "For usb camera support" say "yes"
 
  "libusb" "For usb camera support" say "yes"
 
  "libexif" "For EXIF tag 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===
 
===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 [http://wiki.lunar-linux.org/index.php/Installation:Kernel_2.6._HowTo 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.
 +
$ gphoto2 --list-ports
 +
$ gphoto2 --auto-detect
 +
$ gphoto2 --summary
 +
$ gphoto2 --list-files
 +
$ gphoto2 --get-all-files --filename ~/My\ Pictures/%y%M%d%n.jpg
 +
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

Revision as of 13:18, 30 October 2005

Get pictures from your camera with gphoto2

install 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 guideand 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.

$ gphoto2 --list-ports
$ gphoto2 --auto-detect
$ gphoto2 --summary
$ gphoto2 --list-files
$ gphoto2 --get-all-files --filename ~/My\ Pictures/%y%M%d%n.jpg

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

Personal tools
Namespaces
Variants
Actions
Wiki Navigation
Project Sites
Toolbox