简介

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

arv_camera_acquisition

arv_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

源码

/* 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,则连接第一个可用的相机。

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()释放

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

Available since: 0.8.0

arv_camera_get_model_name

简介:获取相机型号名称

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_IMAGE

ARV_BUFFER_PAYLOAD_TYPE_EXTENDED_CHUNK_DATA

ARV_BUFFER_PAYLOAD_TYPE_MULTIPART
时使用

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_IMAGE

ARV_BUFFER_PAYLOAD_TYPE_EXTENDED_CHUNK_DATA

ARV_BUFFER_PAYLOAD_TYPE_MULTIPART
时使用

gint arv_buffer_get_image_height(ArvBuffer* buffer)

Available since: 0.4.0

标签: none

添加新评论