but schnapphoto daemon can't detect my cam cannon 7d with Pi and HH ...

rlee247 wrote:How would I go about writing a code that will combine the
$ gphoto2 --capture-image-and-download
and
$ sudo ./usbreset /dev/bus/usb/002/003
commands so that it would execute both with one command? I saw the for loop code in a previous post but am not sure which libraries I would have to include or how to call functions from other apps into a code.
Also-for gphoto2, is there a way I can automatically generate new filenames so that I don't have to overwrite or rename after every picture?
(usbreset is from http://marc.info/?l=linux-usb&m=121459435621262&w=2)
PaulMPhoto wrote:I've been following this thread for sometime and have created a wireless camera grip following David Hunt's model.
I found that even with latest Pi and all updates you still need the usbreset as described earlier and if as I do you want to use --keep to keep the original photos on the camera memory card I need to upgrade gphoto2 to the later versions by downloading and compiling it myself.
With various scripts I have it works well and I can use my camera as normal but pics are uploaded automatically to my computer via FTP the originals are also still on the camera if needed.
However I realised that it would be more useful for taking pictures remotely and that typing in command line vis ssh was a bit clunky and not for everyone so I have developed a web interface to control the camera and to be able to see the results quickly.
The interface allows you to change any of the camera parameters Speed, Aperture, ISO, White balance etc. and then take and display a picture. If the camera supports it you can also do a quick preview.
It should work with any gphoto supported camera but there is a small config file needed for each one as the description of the config settings varies depending on the camera.
Here's how I did it. I already had Apache and PHP working on the Pi so the first step was to work out how to use gphoto2 from PHP. I found the PHP exec function e.g.
exec ('gphoto2 --auto-detect',$output,$int);
However the big problem I had was getting the permissions right. The default Apache user is www-data. www-data needed to send commands via exec to the camera via the usb port in use.
After much trial and error I found I needed to change 2 things.
Firstly to get it working at all I needed to edit /etc/sudoers file using visudo. I gave www-data the same permissions as the default user pi by the following to the end of the file:
www-data ALL=(ALL) NOPASSWD: ALL
I also needed to change the permissions on the USB port in use for it all to work. Using the info from earlier in the thread to find the port I created the following script called usbperm
#!/bin/bash
#
dev=`gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//'`
sudo chmod 777 /dev/bus/usb/${dev}
exit 0
Changing the permissions to 777 maybe overkill but it works!
Then just a couple of weeks to get the web page working as I wanted and looking pretty (please notice the symbols matching the camera ones and rounded corners!)
I found using exec('gphoto2 --list-all-config',$output,$int); to get the camera config settings and then parsing it to find the individual settings was much faster than separate calls to get each one.
Changes then made using --set-config from popup windows for each setting.
Clicking on the look-a-like camera button takes a picture with
exec('gphoto2 --capture-image-and-download --keep --filename capt0000.jpg --force-overwrite --quiet');
For my Canon I also needed to insert every time a --set-config /main/settings/capturetarget=1 to force it to use the card and not the internal memory of the camera which it keeps defaulting to.
Clicking on Preview takes a quick preview (if the camera supports it) using
exec('gphoto2 --capture-image-and-download --filename capture_preview.jpg --force-overwrite --quiet')
Of course after each call to gphoto2 I need to do a usb reset with
exec('usbreset /dev/bus/usb/'.$dev);
usbreset and usbperm were added to /usr/bin/ with full permissions.
Here's a screenshot of what it looks like
Full size at http://www.paulmorganphoto.co.uk/PhotoWeb.jpg
rlee247 wrote:Is this patch the one uploaded by GonZoo?
https://github.com/gonzalo/gphoto2-updater
Hi Paul,PaulMPhoto wrote:I've been following this thread for sometime and have created a wireless camera grip following David Hunt's model.
I found that even with latest Pi and all updates you still need the usbreset as described earlier and if as I do you want to use --keep to keep the original photos on the camera memory card I need to upgrade gphoto2 to the later versions by downloading and compiling it myself.
With various scripts I have it works well and I can use my camera as normal but pics are uploaded automatically to my computer via FTP the originals are also still on the camera if needed.
However I realised that it would be more useful for taking pictures remotely and that typing in command line vis ssh was a bit clunky and not for everyone so I have developed a web interface to control the camera and to be able to see the results quickly.
The interface allows you to change any of the camera parameters Speed, Aperture, ISO, White balance etc. and then take and display a picture. If the camera supports it you can also do a quick preview.
It should work with any gphoto supported camera but there is a small config file needed for each one as the description of the config settings varies depending on the camera.
Here's how I did it. I already had Apache and PHP working on the Pi so the first step was to work out how to use gphoto2 from PHP. I found the PHP exec function e.g.
exec ('gphoto2 --auto-detect',$output,$int);
However the big problem I had was getting the permissions right. The default Apache user is www-data. www-data needed to send commands via exec to the camera via the usb port in use.
After much trial and error I found I needed to change 2 things.
Firstly to get it working at all I needed to edit /etc/sudoers file using visudo. I gave www-data the same permissions as the default user pi by the following to the end of the file:
www-data ALL=(ALL) NOPASSWD: ALL
I also needed to change the permissions on the USB port in use for it all to work. Using the info from earlier in the thread to find the port I created the following script called usbperm
#!/bin/bash
#
dev=`gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//'`
sudo chmod 777 /dev/bus/usb/${dev}
exit 0
Changing the permissions to 777 maybe overkill but it works!
Then just a couple of weeks to get the web page working as I wanted and looking pretty (please notice the symbols matching the camera ones and rounded corners!)
I found using exec('gphoto2 --list-all-config',$output,$int); to get the camera config settings and then parsing it to find the individual settings was much faster than separate calls to get each one.
Changes then made using --set-config from popup windows for each setting.
Clicking on the look-a-like camera button takes a picture with
exec('gphoto2 --capture-image-and-download --keep --filename capt0000.jpg --force-overwrite --quiet');
For my Canon I also needed to insert every time a --set-config /main/settings/capturetarget=1 to force it to use the card and not the internal memory of the camera which it keeps defaulting to.
Clicking on Preview takes a quick preview (if the camera supports it) using
exec('gphoto2 --capture-image-and-download --filename capture_preview.jpg --force-overwrite --quiet')
Of course after each call to gphoto2 I need to do a usb reset with
exec('usbreset /dev/bus/usb/'.$dev);
usbreset and usbperm were added to /usr/bin/ with full permissions.
Here's a screenshot of what it looks like
Full size at http://www.paulmorganphoto.co.uk/PhotoWeb.jpg
mald wrote:Hey Rodd,
A patch is proposed for gphoto might have a patch that fixes the rpi issue. They are looking for somebody to test it. Maybe you can give his patch a try (without the --keep) and see if it works.
http://gphoto.10949.n7.nabble.com/test- ... 12907.html