1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#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"
int main(int argc, char *argv[]){
Camera *camera;
GPContext *context = gp_context_new();
int retval;
CameraEventType evttype;
void *evtdata;
CameraFile *file;
gp_camera_new(&camera);
retval = gp_camera_init(camera, context);
if(retval != GP_OK)
{
printf("Error: %s\n", gp_result_as_string(retval));
return 1;
}
do {
retval = gp_camera_wait_for_event (camera, 10, &evttype, &evtdata, context);
} while ((retval == GP_OK) && (evttype != GP_EVENT_TIMEOUT));
retval = gp_file_new(&file);
if (retval != GP_OK) {
printf("gp_file_new: %d\n", retval);
return 1;
}
/*retval = gp_camera_capture_preview(camera, file, context); */
if (retval != GP_OK) {
printf("gp_camera_capture_preview: %d\n", retval);
return 1;
}
gp_file_free (file);
if(argc == 1)
{
retval = camera_auto_focus(camera, context, 1);
if(retval != GP_OK) {
printf("Error: %s\n", gp_result_as_string(retval));
return 1;
}
}
else if(argc == 2)
{
int value = atoi(argv[1]);
retval = camera_manual_focus(camera, value, context);
if(retval != GP_OK) {
printf("Error: %s\n", gp_result_as_string(retval));
return 1;
}
}
do {
retval = gp_camera_wait_for_event (camera, 10, &evttype, &evtdata, context);
} while ((retval == GP_OK) && (evttype != GP_EVENT_TIMEOUT));
retval = camera_auto_focus(camera, context, 0);
if(retval != GP_OK) {
printf("Error: %s\n", gp_result_as_string(retval));
return 1;
}
gp_camera_exit(camera, context);
return 0;
}
|