Re: Getting a hook from shell mode to do motion detection?
Marcus Meissner <[email protected]>
| Newsgroups | gmane.comp.multimedia.gphoto.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, Order of -l components is important and you need to add -lgphoto2_port, e.g. like: gcc -Wall -o pb sample-photobooth.c -L/usr/local/bin/gphoto2-2.5.15/lib -lgphoto2 -lgphoto2_port Ciao, Marcus On Sun, Dec 31, 2017 at 07:39:01PM -0500, Alan Corey wrote: > Well, I haven't had a lot of luck getting things from the > libgphoto2/examples dir running so I gave up. Just recently I tried > copying sample-photobooth.c (and samples.h) into an empty dir and > compiling with a makefile that looks like > > ------------- > pb: sample-photobooth.c > gcc -Wall -o pb -lgphoto2 sample-photobooth.c \ > -L/usr/local/bin/gphoto2-2.5.15/lib > > # lib path is because I didn't want it to conflict with debs gphoto > # it's where libgphoto2.so.6.0.0 is > -------------- > > And I get errors like: > upstairs# make > gcc -Wall -o pb -lgphoto2 sample-photobooth.c \ > -L/usr/local/bin/gphoto2-2.5.15/lib > /usr/bin/ld: /tmp/ccBGh1Jj.o: undefined reference to symbol > 'gp_log_add_func@@LIBGPHOTO2_5_0' > //usr/local/bin/gphoto2-2.5.15/lib/libgphoto2_port.so.12: error adding > symbols: DSO missing from command line > collect2: error: ld returned 1 exit status > Makefile:2: recipe for target 'pb' failed > make: *** [pb] Error 1 > > I did an ldconfig on the path where the library is. I was also > getting the "DSO missing from command line" error trying to build > preview.c. I've never seen it on anything I wrote, trying to google > it wasn't very productive. > > On 12/31/17, Marcus Meissner <[email protected]> wrote: > > Hi, > > > > If you want to do this all with one camera you might be better of writing > > a program using libgphoto2, either in C or Python. > > > > FWIW, I did something similar to Tomas btw. > > > > Setup: > > > > - Cheap Webcam > > - Canon EOS 1000D with AC adapter. > > - Laptop > > > > Then I ran the "motion" tool using the webcam. > > > > The "motion" tool has hooks where it can callout to shell scripts. > > I wrote a simple shell script that ran gphoto2 --capture-image-and-download > > > > and hooked it to the motion detection hook. > > > > It needed some checking that it does not run it twice (because > > if there is motion it would trigger faster than capturing) > > and it runs the disk full quite quickly with DSLR sized images. > > > > Ciao, Marcus > > > > > > On Sat, Dec 30, 2017 at 02:06:13PM -0500, Alan Corey wrote: > >> I've been thinking about this. I plan to write in C, and between > >> system() and popen() and pipe() and etc there's probably a way to do > >> it. From a console you type shell and give commands, then you can > >> type more commands. But I'm not sure how a program would do that: as > >> a file descriptor or a pipe (or a socket) (dbus?)? Gphoto as a > >> process stays running, you just need a programmatic way to communicate > >> with it. The looping and branching wouldn't happen in Gphoto's shell, > >> that would be more like a low level server or driver. I could of > >> course modify my copy of the source but I'd rather not do that. I was > >> about to experiment a bit until I found my oldschool loadjpeg function > >> evidently doesn't work under Linux, I need to make a Turbo Jpeg > >> equivalent. Or maybe I still need some dev file or header. Wacky, it > >> doesn't know jpeg_CreateDecompress or what a size_t is? I wrote it > >> under OpenBSD a couple years ago, it's been reasonably portable until > >> now. Loading a straight uncompressed RGB binary would be optimum but > >> I need to decompress jpegs. Don't know yet if I can send to stdout. > >> > >> I ran across motion last night but didn't bother to install it. I > >> think it's strictly V4L so it's low quality just because the cameras > >> are. I've got a 640x480 USB webcam that does V4L but I'd rather not > >> use it. My motion detection scheme comes partly from a D-Link IP cam, > >> that also only does 640x480. I'll probably be running this on a > >> Raspberry Pi, and I've got a few of those cameras, but I'd rather not > >> use them. > >> > >> The standard Gphoto --capture-preview or the shell equivalent gets me > >> a 320x240 jpeg which, if I decompress and compare in C, not something > >> awful like Python, should be fast enough. I'd rather not use 2 > >> cameras. I'm from the Nikon camp, new to Canons for this project. > >> For $20 used I got a 7 MP camera that not only works with Gphoto but > >> also shoots RAW, most low-end Nikons won't do either. I'm not > >> sticking my D5200 DSLR in a birdfeeder. > >> > >> Shell mode is good for this because there's only 1 start-up time, the > >> delay between pictures can be much lower than if you call Gphoto in a > >> loop to start from scratch each time. 1 frame per second might be > >> adequate but I'm aiming at 10. CPU time on a Pi 3 comes cheap since > >> it runs on a watt or two. So I don't need to compare 320x240 images > >> but if I can do it efficiently I can live with it. > >> > >> On 12/30/17, Tomas Alonso <[email protected]> wrote: > >> > El Viernes, 29 de diciembre de 2017 17:39:08 Alan Corey escribió: > >> >> I want to set up a wildlife camera, so I've read a few articles about > >> >> it. I've been practicing with an old Canon PowerShot S70 and it seems > >> >> suitable. What I'd like to try to do is use the preview images for > >> >> motion detection. I need to mask out some areas to avoid false > >> >> activations from clouds passing over, that sort of stuff, and probably > >> >> some averaging to account for the sun rising and setting. > >> >> > >> >> For speed it seems advisable to work in Gphoto2's shell mode but I'm > >> >> trying to figure out a way to provide input from an external program. > >> >> I want to do capture-preview in a loop: get a preview, run my compare > >> >> program, get another preview. If the compare sees something go into > >> >> another loop grabbing big images for some amount of time, then back to > >> >> previews. > >> >> > >> >> I did help in shell mode but I don't see anything listed that looks > >> >> like it would work, like being able to detect the presence of some > >> >> file I could use a a semaphore. There aren't any branch (or loop) > >> >> instructions either. > >> >> > >> >> Alan > >> > > >> > Hello Alan, > >> > > >> > For other needs related to security I'm also interested in doing > >> > something > >> > equivalent. I thought my first try would be > >> > > >> > http://www.chriswpage.com/2009/05/setup-an-advanced-webcam-security-system-with-ubuntu-8-04-and-motion/ > >> > > >> > using the motion program under Linux. It allows to launch scripts when > >> > motion > >> > is detected, but you need a webcam for motion detection and a camera > >> > for > >> > good > >> > quality shots. That's (and the fact I own a Canon 40D) why I'm not sure > >> > at > >> > all > >> > about the webcam approach. > >> > > >> > I have high programming skills and experience with gphoto so to > >> > implement > >> > this > >> > myself will not be a problem. If you can't find a solution for your > >> > case > >> > just > >> > send me the exact gphoto commands you use for your camera to enter > >> > shell > >> > mode, > >> > take a preview, and take also a big image in auto mode or whatever you > >> > use > >> > (including the file names generated in your computer after executing > >> > those > >> > commands). > >> > > >> > Can't promise to do it for a given date but likely it will take few > >> > weeks. > >> > > >> > Regards, > >> > Tomas. > >> > > >> > > >> > ------------------------------------------------------------------------------ > >> > Check out the vibrant tech community on one of the world's most > >> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > >> > _______________________________________________ > >> > Gphoto-user mailing list > >> > [email protected] > >> > https://lists.sourceforge.net/lists/listinfo/gphoto-user > >> > > >> > >> > >> -- > >> ------------- > >> No, I won't call it "climate change", do you have a "reality problem"? - > >> AB1JX > >> Impeach Impeach Impeach Impeach Impeach Impeach Impeach Impeach > >> > >> ------------------------------------------------------------------------------ > >> Check out the vibrant tech community on one of the world's most > >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot > >> _______________________________________________ > >> Gphoto-user mailing list > >> [email protected] > >> https://lists.sourceforge.net/lists/listinfo/gphoto-user > > > > > -- > ------------- > No, I won't call it "climate change", do you have a "reality problem"? - AB1JX > Impeach Impeach Impeach Impeach Impeach Impeach Impeach Impeach ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot