blob: bc39000586fcd1371b6ee7027e67494736f8a60f (
plain)
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
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <gphoto2/gphoto2-camera.h>
#include "samples.h"
/* Sample autodetection program.
*
* This program can autodetect a single camera and then calls a
* simple function in it (summary).
*/
int main(int argc, char **argv) {
Camera *camera;
int ret;
char *owner;
GPContext *context;
CameraText text;
context = sample_create_context (); /* see context.c */
gp_camera_new (&camera);
/* This call will autodetect cameras, take the
* first one from the list and use it. It will ignore
* any others... See the *multi* examples on how to
* detect and use more than the first one.
*/
ret = gp_camera_init (camera, context);
if (ret < GP_OK) {
printf("No camera auto detected.\n");
gp_camera_free (camera);
return 0;
}
/* Simple query the camera summary text */
ret = gp_camera_get_summary (camera, &text, context);
if (ret < GP_OK) {
printf("Camera failed retrieving summary.\n");
gp_camera_free (camera);
return 0;
}
printf("Summary:\n%s\n", text.text);
/* Simple query of a string configuration variable. */
ret = get_config_value_string (camera, "owner", &owner, context);
if (ret >= GP_OK) {
printf("Owner: %s\n", owner);
free (owner);
}
gp_camera_exit (camera, context);
gp_camera_free (camera);
gp_context_unref (context);
return 0;
}
|