开源相机管理库Aravis例程学习(一)——单帧采集single-acquisition

paw5zx Lv4

简介

本文针对官方例程 中的第一个例程:single-acquisition做简单的讲解,并简单分析其中调用的arv_camera_new arv_camera_acquisitionarv_camera_get_model_name arv_buffer_get_image_width arv_buffer_get_image_height 函数。

aravis版本:0.8.31
操作系统:ubuntu-20.04
gcc版本:9.4.0

源码

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
/* 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 a single buffer.
*/

int main (int argc, char **argv)
{
ArvCamera *camera;
ArvBuffer *buffer;
GError *error = NULL;

/* Connect to the first available camera */
camera = arv_camera_new (NULL, &error);
//camera = arv_camera_new ("192.168.6.23", &error);

if (ARV_IS_CAMERA (camera))
{
printf ("Found camera '%s'\n", arv_camera_get_model_name (camera, NULL));

/* Acquire a single buffer */
buffer = arv_camera_acquisition (camera, 0, &error);

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));
/* Destroy the buffer */
g_clear_object (&buffer);
}

/* Destroy the camera instance */
g_clear_object (&camera);
}

if (error != NULL)
{
/* An error happened, display the correspdonding message */
printf ("Error: %s\n", error->message);
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

此例程较为简单,每一步的细节查看注释即可,此处不过多讲解。
运行结果:

函数说明

arv_camera_new

简介:创建一个ArvCamera对象,如果name是NULL,则连接第一个可用的相机。

1
ArvCamera* arv_camera_new (const char* name, GError** error)

如果是Gige相机,name的格式可以是:

  • <vendor>-<model>-<serial>
  • <vendor_alias>-<serial>
  • <vendor>-<serial>
  • <user_id>
  • <ip_address>
  • <mac_address>

例如:

  • The Imaging Source Europe GmbH-DFK 33GX265-39020369
  • The Imaging Source Europe GmbH-39020369
  • TIS-39020369
  • 192.168.0.2
  • 00:07:48:af:a2:61

Available since 0.8.0

arv_camera_acquisition

简介:获取一帧图像。
注意:①本函数会将相机设置为单帧采集模式②返回的buffer最终必须要通过g_object_unref()释放

1
2
3
4
ArvBuffer* arv_camera_acquisition(
ArvCamera* camera,
guint64 timeout, //采集超时时间,单位µs
GError** error)

Available since: 0.8.0

arv_camera_get_model_name

简介:获取相机型号名称

1
const char* arv_camera_get_model_name (ArvCamera* camera, GError** error)

Available since 0.8.0

arv_buffer_get_image_width

简介:获取图片的width
注意:此函数只能在buffer payload为ARV_BUFFER_PAYLOAD_TYPE_IMAGEARV_BUFFER_PAYLOAD_TYPE_EXTENDED_CHUNK_DATAARV_BUFFER_PAYLOAD_TYPE_MULTIPART时使用

1
gint arv_buffer_get_image_width(ArvBuffer* buffer)

Available since: 0.4.0

arv_buffer_get_image_height

简介:获取图片的height
注意:此函数只能在buffer payload为ARV_BUFFER_PAYLOAD_TYPE_IMAGEARV_BUFFER_PAYLOAD_TYPE_EXTENDED_CHUNK_DATAARV_BUFFER_PAYLOAD_TYPE_MULTIPART时使用

1
gint arv_buffer_get_image_height(ArvBuffer* buffer)

Available since: 0.4.0

  • 标题: 开源相机管理库Aravis例程学习(一)——单帧采集single-acquisition
  • 作者: paw5zx
  • 创建于 : 2024-04-10 13:40:15
  • 更新于 : 2024-11-11 13:57:57
  • 链接: https://paw5zx.github.io/aravis-single-acquisition/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
开源相机管理库Aravis例程学习(一)——单帧采集single-acquisition