maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   gphoto2 + canon 20d + n810 = chunky super unstable eyefi (https://talk.maemo.org/showthread.php?t=13868)

aki 2007-12-26 19:18

gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
I've managed to get gphoto2, perl and other assorted programs compiled for my n810 now and have been playing with the usb host stuff.

The idea I've been working on is that it's possible for a computer to view/download images from my Canon 20d camera while it's shooting. To do so, I've set the camera up in "normal mode" (rather than PTP that causes the system to pretty much shutdown aside from the connection mode) and have been trying to use gphoto2 to poll+download the camera for new images.

I've thrown together the following perl script and have used it with success on my laptop... and some with the n810. What it does is first downloads a list of all the pictures on the camera, then flags them as "seen". From then on, it will poll the camera every 5 seconds or so and downloads any new pictures it sees to the memory card. That's just the test. When it's reliable I'm thinking of geotagging the images, then using something like djpeg to resize the image then upload the picture to flickr or some other site. If I get samba working, perhaps I'll get the system to dump the pictures onto a share.

The problem I'm encountering is that most of the time, when "gphoto2 -L" is invoked, the system freezes then reboots. Is there anything I can do to figure out what's causing the reboot?

If anyone wants, I can upload a tarball of my /media/mmc1/pocket, I've managed to stuff most of the little programs that I use into there. (perl, imagemagick *slow*, vim, dcraw, jhead, mysql, apache, subversion, etc)

Code:

#!/usr/bin/perl

use strict;
use vars qw/ $CFG %SEEN /;
use Symbol;

$CFG = {
    gphoto_fpath => "/media/mmc1/pocket/bin/gphoto2",
    process_cmd => "echo Fetched {}",
    save_path => "/media/mmc1",
    poll_delay => 5,
};

main();

sub main {
# --------------------------------------------------
    my $files = camera_files();

# So that we can score the images in the right directory
    chdir $CFG->{save_path};

    while (1) {
        photos_seen_mark( $files );
        $files = camera_files();
        if ( my $not_seen = photos_seen_filter($files) ) {
            camera_file_fetch( $not_seen );
            photos_post_action( $not_seen );
        }
        sleep $CFG->{poll_delay};
    }
}

sub photos_post_action {
# --------------------------------------------------
# Execute a script or do something for each photo
# that has been fetched
#
    my $files = shift or return;
    for ( @$files ) {
        my $fpath = $CFG->{save_path}? "$CFG->{save_path}/$_->{fname}" : $_->{fname};
        my $process_cmd = $CFG->{process_cmd};
        $process_cmd =~ s/\{\}/"$fpath"/g;
        system $process_cmd;
    }
}

sub photos_seen_mark {
# --------------------------------------------------
# Mark all the photos passed via array as "seen"
#
    my $files = shift;   
    for ( @$files ) {
        $SEEN{$_->{fname}} = 1;
    }
}

sub photos_seen_filter {
# --------------------------------------------------
# Returns an array of all the photos that have
# not been seen by the system
#
    my $files = shift;   
    my @filtered = grep {not $SEEN{$_->{fname}}} @$files or return;
    return \@filtered;
}

sub camera_file_fetch {
# --------------------------------------------------
# Fetches the files in the list passed in
#
    my $files = shift or return;
    my $range = join ",",map {$_->{id}} @$files;
    my $fh = Symbol->gensym;
    open $fh, "$CFG->{gphoto_fpath} --get-file=$range --force-overwrite 2> /dev/null |" or die $!;
    my @saved;
    while ( my $l = <$fh> ) {
        next unless $l =~ /Saving file as (.*)/;
        push @saved, $1;
    }
    close $fh;
}

sub camera_files {
# --------------------------------------------------
# Returns an array of hashrefs describing what files
# are available on the target camera
#
    my $fh = Symbol->gensym;
    open $fh, "$CFG->{gphoto_fpath} -L 2> /dev/null |" or die $!;
    my @files;
    my @headers = qw( id fname u size unit mime );
    while ( my $l = <$fh> ) {
        my @e = split /\s+/, $l;
        next unless $l =~ /^\#\d+/;
        my @e = split /\s+/, $l;
        my $rec = {};
        @$rec{@headers} = @e;
        $rec->{id} =~ s/^#//;
        push @files, $rec;
    }
    close $fh;

    return \@files;
}


---

Update: managed to get it more reliably when I invoke the script just after the camera is detected but before the second usb error is shown. Seems to be working fine as long as I get everything started in that window. W00t!

---

Update2: It's uploading! :) The script now downloads the photos to a temp directory and invokes (yet) another script that resizes via djpeg (image magick takes 4 minutes, djpeg does it in a few seconds) and uploads the result to my server. Of course, there's the little problem that it uploads /all/ my pics... but it's working! :)

darethehair 2007-12-28 00:52

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
Hey, cool!

I was eventually going to try to compile 'gphoto2' myself for OS2008, now that I know that the USB can talk to my Nikon Coolpix camera. Can you make the binary for 'gphoto2' available? That would be great!

I realize that it would be a waste of a beautiful N8xx device to use it as a remote camera snapshot wireless controller device (as in http://webuser.fh-furtwangen.de/~der...to/remote.html), but theoretically one could have a VERY hires non-real-time 'webcam' that way.

I originally purchased used Linksys NSLU2 devices for the express purpose of driving some consumer digital cameras that way, but so far the Debian installs that I have do NOT work (for reasons unknown) for me that way :(

tvengineer 2007-12-28 03:08

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
I'll second the idea of making the gphoto2 binaries available,...

I also got an NSLU linksys for the same reason.. but never got it to work..

I have the CoolPix P2 with built in Wifi... it would sure be sweet to be able to control the camera with the n800 via wifi.. but I won't hope for everything all at once... :-)

Best scenario would be to be able to control the exposure settings etc. on the camera while it is on a tripod, wirelessly, from the N800.

aki 2007-12-28 04:59

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
Sure thing, I'll try and make a deb available and if I can't do that, I'll just make a tar/gz that you can unpackage in your home dir. Give me a day or two so I can find some time to recompile everything into the new paths.

robertmc 2008-01-02 16:51

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
For me, this would be a killer app- a way to control Auto Exposure Bracketing in a low priced DSLR camera for taking HDR photos with the N800. I'd be willing to pay for that app. No more lugging around a laptop.... just the N800, a mini tripod and a camera. You could get the whole setup in one small camera bag!

icebox 2008-01-07 20:01

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
In case it matters I would also like to get involved into this, I'd like to see my n800 talking to my canon 10d.

Any chance for that gphoto binary?

thanks

mi_ko 2008-01-07 20:11

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
Did anybody try canon 400d + n810?

darethehair 2008-01-10 17:06

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
Hmmm...I have made my own stumbling efforts to compile libgphoto2 and gphoto2 in a chinook-based scratch environment, and then copy what I think are the relevant files over to the N800. Although there are hints of optimism, it ultimately does not work -- since gphoto2 does not detect any 'ports' to use for me. I have no idea what to do next :(

Nokia-N800-50-2:/usr/local/lib# gphoto2 --list-ports
Devices found: 0
Path Description
--------------------------------------------------------------

I don't want to just 'download' from my Nikon Coolpix camera -- I want to be able to '--capture-image'.

darethehair 2008-01-10 18:19

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
Success! But also a bit of worry too :)

I guess I missed copying over one of the 'relevant' directories to the N800 (i.e. /usr/local/lib/libgphoto2_port) and once I did so, the ports (including the relevant 'usb' one) showed up. I was then able to 'capture-image' and download the images. However, in doing so, my N800 rebooted twice -- I am not sure why (although the original poster alludes to something similar). I do not know how to prevent it yet.

Now, I guess we are still hoping for the original poster to package this up for us, but if not I suppose I *could* try to make a 'tar file myself -- for use at one's own risk!

darethehair 2008-01-10 20:11

Re: gphoto2 + canon 20d + n810 = chunky super unstable eyefi
 
Anyone brave enough to try downloading/installing my ported version of 'libgphoto2' and 'gphoto2' onto their OS2008 N8xx devices and let me know how it works out?

I have *never* done anything remotely like this before (porting, packaging, making available on my web site, etc. so...DO THIS ALL AT YOUR OWN RISK!).

http://members.shaw.ca/dmenns2/README.libgphoto2.dare
http://members.shaw.ca/dmenns2/README.gphoto2.dare
http://members.shaw.ca/dmenns2/libgphoto2.tar.gz
http://members.shaw.ca/dmenns2/gphoto2.tar.gz

Give me feedback! Let me know if my install instructions are correct, and if you have success in using 'gphoto2'!


All times are GMT. The time now is 10:28.

vBulletin® Version 3.8.8