-
Notifications
You must be signed in to change notification settings - Fork 7
/
03-camera-api.c
52 lines (38 loc) · 1.14 KB
/
03-camera-api.c
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
/* SPDX-License-Identifier:Unlicense */
/* Aravis header */
#include <arv.h>
/* Standard headers */
#include <stdlib.h>
#include <stdio.h>
/*
* Connect to the first available camera, then display the current settings for image width and height, as well as the
* pixel format, using the ArvCamera API.
*/
int
main (int argc, char **argv)
{
ArvCamera *camera;
GError *error = NULL;
/* Connect to the first available camera */
camera = arv_camera_new (NULL, &error);
if (ARV_IS_CAMERA (camera)) {
int width;
int height;
const char *pixel_format;
printf ("Found camera '%s'\n", arv_camera_get_model_name (camera, NULL));
if (!error) arv_camera_get_region (camera, NULL, NULL, &width, &height, &error);
if (!error) pixel_format = arv_camera_get_pixel_format_as_string (camera, &error);
if (error == NULL) {
printf ("Width = %d\n", width);
printf ("Height = %d\n", height);
printf ("Pixel format = %s\n", pixel_format);
}
g_clear_object (&camera);
}
if (error != NULL) {
/* En error happened, display the correspdonding message */
printf ("Error: %s\n", error->message);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}