开源相机管理库Aravis例程学习(五)——camera-api

ops/2024/10/20 16:05:06/

开源相机管理库Aravis例程学习(五)——camera-api

  • 简介
  • 例程代码
  • 函数说明
    • arv_camera_get_region
    • arv_camera_get_pixel_format_as_string
    • arv_camera_get_pixel_format
    • ARV_PIXEL_FORMAT_BIT_PER_PIXEL

简介

本文针对官方例程中的:03-camera-api做简单的讲解。并介绍其中调用的arv_camera_get_regionarv_camera_get_pixel_format_as_stringarv_camera_get_pixel_formatARV_PIXEL_FORMAT_BIT_PER_PIXEL

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

例程代码

这段代码使用Aravis的API,获取相机的一些基本设置,如图像的宽度、高度和像素格式,主要操作步骤如下:

  • 连接相机
  • 获取图像宽度,高度,像素格式等信息
  • 释放资源
/* 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;//连接相机camera = arv_camera_new (NULL, &error);if (ARV_IS_CAMERA (camera)) {int width;int height;const char *pixel_format;int format_number;int bit_per_pixel;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) format_number = arv_camera_get_pixel_format (camera, &error);//获取图像像素位数if (!error) bit_per_pixel = ARV_PIXEL_FORMAT_BIT_PER_PIXEL (format_number);if (error == NULL) {printf ("Width = %d\n", width);printf ("Height = %d\n", height);printf ("Pixel format = %s\n", pixel_format);printf ("Pixel format number = %d\n", format_number);printf ("Bit per pixel = %d\n", bit_per_pixel);}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;
}

运行结果:
在这里插入图片描述

函数说明

arv_camera_get_region

简介:用于获取相机当前的感兴趣区域(ROI),此函数会将当前相机的ROI的位置坐标(x,y)和尺寸(width,height)通过指针返回,并记录错误信息。

void arv_camera_get_region (ArvCamera* camera,gint* x,gint* y,gint* width,gint* height,GError** error
)

其中:
[in]camera:相机对象
[out]x:ROI起始x坐标
[out]y:ROI起始y坐标
[out]width:ROI宽度
[out]height:ROI高度
[out]error:错误信息

Available since: 0.8.0

arv_camera_get_pixel_format_as_string

简介:从连接的相机中获取当前设置的像素格式,以字符串形式返回。

const char* arv_camera_get_pixel_format_as_string (ArvCamera* cameraGError** error
)

Available since: 0.8.0

arv_camera_get_pixel_format

简介:从连接的相机中获取当前设置的像素格式,返回其编码。

ArvPixelFormat arv_camera_get_pixel_format(ArvCamera* cameraGError** error
)

Available since: 0.8.0

ARV_PIXEL_FORMAT_BIT_PER_PIXEL

简介:宏定义,用于获取pixel_format的第17位到第24位的值,其表示的是像素格式的Bpp(bits per pixel)。

#define ARV_PIXEL_FORMAT_BIT_PER_PIXEL(pixel_format) (((pixel_format) >> 16) & 0xff)

http://www.ppmy.cn/ops/22161.html

相关文章

社交到底是什么?

社交的核心&#xff1a;感受世界而非自我展示 社交常常被误解为一个自我展示的舞台&#xff0c;然而&#xff0c;真正的社交远比这更深刻。它不是关于我们如何展示自己的优势&#xff0c;而是关于我们如何与世界建立联系&#xff0c;了解和探索他人。本文将探讨社交的真正意义…

白话机器学习1:分类问题中的评价指标

机器学习中的评价指标非常多&#xff0c;它们用来衡量模型的性能和预测能力。不同类型的机器学习任务可能需要不同的评价指标。以下是一些常见的评价指标&#xff0c;按照不同类型的机器学习任务分类&#xff1a; 对于分类问题&#xff1a; 准确率&#xff08;Accuracy&#…

用Jenkins实现cherry-pick多个未入库的gerrit编译Android固件

背景: 在做Android固件开发的时候,通常我们可以利用gerrit-trigger插件,开发者提交一笔的时候自动触发jenkins编译,如果提交的这一笔的编译依赖其他gerrit才能编译过,我们可以在commit message中加入特殊字段,让jenkins在编译此笔patch的时候同时抓取依赖的gerrit代码下…

求解素数-埃氏筛选

什么是素数了?就是除了0和1之外,一个数只能由1和它本身相乘得来,这就是素数 第一种暴力求解: package com.fan.suanfati;import java.util.Scanner;public class SuShu {public static void main(String[] args) {System.out.println("请输入数字,以便求出该数字内的素数…

Django初步了解

目录 一、什么是Django 二、Django的设计模式 三、涉及的英文缩写及其含义 四、安装&#xff08;官方教程&#xff09; 一、什么是Django Django是一个Python Web框架&#xff0c;可以快速开发网站&#xff0c;提供一站式的解决方案&#xff0c;包括缓存、数据库ORM、后台…

Memory augment is All You Need for image restoration 论文翻译

目录 一.介绍 二.实际工作 A.图像阴影去除 B.图像去雨 C.存储模块的开发 三.网络结构 A.内存扩充 B.损失函数设计 四.实验 A.与最先进方法的比较 B.MemoryNet消融研究 五.结论 CVPR2023 MemoryNet 记忆增强是图像恢复所需要的一切 论文地址https://arxiv.org/abs/…

材质系统:关于PBR(Physically Based Rendering)需要知道的一些事

目录 前言 1. 什么是PBR&#xff1f; 2. 为什么PBR在近期开始流行 3. PBR材质与其他渲染器中材质&#xff08;如Vray材质、Enscape中的材质&#xff09;的区别是什么&#xff1f; 4. 为什么Vray之类的渲染器从一开始没有使用PBR材质系统&#xff1f; 前言 本文内容基于对图…

json.loads()与json.dumps()区别

1、json.loads() 序列化&#xff0c;将JSON字符串&#xff0c;转换为Python的数据结构&#xff0c;如字典。 2、json.dumps() 反序列化&#xff0c;将Python的数据结构&#xff0c;转换成JSON字符串。