Well this is odd but fun
Alan Corey <[email protected]>
| Newsgroups | gmane.comp.multimedia.gphoto.user |
|---|---|
| Message-ID | <CAOh3dDYUnB_PYNpw9Jk1BwP9rU2XY8G86deWuxD3R=_S9pOG4w@mail.gmail.com> |
Finally got back to this. I made a very stripped down preview capture
program. It works, but the file I get each time is the picture took
last time. It's getting stored somewhere, maybe the camera's memory.
When I do gp_camera_capture_preview() and then gp_file_save() what
gets saved is the previous picture. Then if I do it again I get the
picture I took the first time. I want it for doing motion detection
so it's not unusable, just 1 frame delayed. I haven't read a lot of
documentation, I just finally got a chance to play with it again.
Seems fast, my camera's giving me 320x240 images, just about what I
want. The files get downloaded to my computer, looking at the camera
with gtkam I don't see any stale images hanging around. I didn't
realize gtkam could do captures (right click in the left window on the
camera).
This needs to be linked with context.c and config.c
/*
My Preview Trying to capture preview images with libgphoto2
*/
// block of includes from preview.c
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <gphoto2/gphoto2.h>
#include "samples.h"
#include <sys/time.h> // there's a gettimeofday somewhere
Camera *canon;
GPContext *canoncontext;
void get_one(void) { // capture 1 preview image
CameraFile *file;
char jpgname[] = "test2.jpg";
int rslt;
rslt = gp_file_new(&file);
if (rslt) {
printf("Error creating new CameraFile %i\n",rslt);
exit(1);
}
// skipping focus for now but do it here
// skipping zoom also
rslt = gp_camera_capture_preview(canon, file, canoncontext);
if (rslt) {
printf("error capturing preview %i\n",rslt);
exit(1);
}
rslt = gp_file_save(file, jpgname);
if (rslt) {
printf("Error saving file (in gp_file_save) %i\n",rslt);
exit(1);
}
}
int main(void) {
int rslt;
// skip this for now
// gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
gp_camera_new(&canon);
canoncontext = sample_create_context();
printf("Camera init. Takes about 10 seconds.\n");
rslt = gp_camera_init(canon, canoncontext);
if (rslt) {
printf("Error initializing camera %i\n",rslt);
exit(1);
}
canon_enable_capture(canon, TRUE, canoncontext); // in config.c
get_one();
gp_camera_exit(canon, canoncontext);
return 0;
}
--
-------------
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