-
Notifications
You must be signed in to change notification settings - Fork 7
/
02-multiple-acquisition-main-thread.c
89 lines (67 loc) · 2.11 KB
/
02-multiple-acquisition-main-thread.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* SPDX-License-Identifier:Unlicense */
/* Aravis header */
#include <arv.h>
/* Standard headers */
#include <stdlib.h>
#include <stdio.h>
/*
* Connect to the first available camera, then acquire 10 buffers.
*/
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)) {
ArvStream *stream = NULL;
printf ("Found camera '%s'\n", arv_camera_get_model_name (camera, NULL));
arv_camera_set_acquisition_mode (camera, ARV_ACQUISITION_MODE_CONTINUOUS, &error);
if (error == NULL)
/* Create the stream object without callback */
stream = arv_camera_create_stream (camera, NULL, NULL, &error);
if (ARV_IS_STREAM (stream)) {
int i;
size_t payload;
/* Retrieve the payload size for buffer creation */
payload = arv_camera_get_payload (camera, &error);
if (error == NULL) {
/* Insert some buffers in the stream buffer pool */
for (i = 0; i < 2; i++)
arv_stream_push_buffer (stream, arv_buffer_new (payload, NULL));
}
if (error == NULL)
/* Start the acquisition */
arv_camera_start_acquisition (camera, &error);
if (error == NULL) {
/* Retrieve 10 buffers */
for (i = 0; i < 10; i++) {
ArvBuffer *buffer;
buffer = arv_stream_pop_buffer (stream);
if (ARV_IS_BUFFER (buffer)) {
/* Display some informations about the retrieved buffer */
printf ("Acquired %d×%d buffer\n",
arv_buffer_get_image_width (buffer),
arv_buffer_get_image_height (buffer));
/* Don't destroy the buffer, but put it back into the buffer pool */
arv_stream_push_buffer (stream, buffer);
}
}
}
if (error == NULL)
/* Stop the acquisition */
arv_camera_stop_acquisition (camera, &error);
/* Destroy the stream object */
g_clear_object (&stream);
}
/* Destroy the camera instance */
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;
}