2023-简单点-picamera的bayer数据获取抽丝剥茧

2023-12-12 01:52

本文主要是介绍2023-简单点-picamera的bayer数据获取抽丝剥茧,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

capture函数,设置bayer=True
在这里插入图片描述
啥是mmal.xxxx? 啥是camera_port?
在这里插入图片描述
看起来是个设置标志,产生buffer,获取针对对应格式的c数据结构

在这里插入图片描述
在这里插入图片描述
camera_port与self._camera.outputs有关

在这里插入图片描述

啥是mmalcamera
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
总之,找到Outputs有3个,disable()一下,然后配置相机参数,commit提交一下;
enable output with 回调函数,然后设置output.param【某某】为True产生buffers然后才能得到最终数据。
在这里插入图片描述

看完了例子,还有个encoder.start()
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
最后就追溯到这了。。。。
在这里插入图片描述
在这里插入图片描述
看来是多重继承
在这里插入图片描述

在这里插入图片描述
继续
又是多重

class PiRawMixin(PiEncoder):"""Mixin class for "raw" (unencoded) output.This mixin class overrides the initializer of :class:`PiEncoder`, alongwith :meth:`_create_resizer` and :meth:`_create_encoder` to configure thepipeline for unencoded output. Specifically, it disables the constructionof an encoder, and sets the output port to the input port passed to theinitializer, unless resizing is required (either for actual resizing, orfor format conversion) in which case the resizer's output is used."""RAW_ENCODINGS = {# name   mmal-encoding             bytes-per-pixel'yuv':  (mmal.MMAL_ENCODING_I420,  1.5),'rgb':  (mmal.MMAL_ENCODING_RGB24, 3),'rgba': (mmal.MMAL_ENCODING_RGBA,  4),'bgr':  (mmal.MMAL_ENCODING_BGR24, 3),'bgra': (mmal.MMAL_ENCODING_BGRA,  4),}def __init__(self, parent, camera_port, input_port, format, resize, **options):encoding, bpp = self.RAW_ENCODINGS[format]# Workaround: on older firmwares, non-YUV encodings aren't supported on# the still port. If a non-YUV format is requested without resizing,# test whether we can commit the requested format on the input port and# if this fails, set resize to force resizer usageif resize is None and encoding != mmal.MMAL_ENCODING_I420:input_port.format = encodingtry:input_port.commit()except PiCameraMMALError as e:if e.status != mmal.MMAL_EINVAL:raiseresize = input_port.framesizewarnings.warn(PiCameraResizerEncoding("using a resizer to perform non-YUV encoding; ""upgrading your firmware with sudo rpi-update ""may improve performance"))# Workaround: If a non-alpha format is requested with the resizer, use# the alpha-inclusive format and set a flag to get the callback to# strip the alpha bytesself._strip_alpha = Falseif resize:width, height = resizetry:format = {'rgb': 'rgba','bgr': 'bgra',}[format]self._strip_alpha = Truewarnings.warn(PiCameraAlphaStripping("using alpha-stripping to convert to non-alpha ""format; you may find the equivalent alpha format ""faster"))except KeyError:passelse:width, height = input_port.framesize# Workaround (#83): when the resizer is used the width must be aligned# (both the frame and crop values) to avoid an error when the output# port format is set (height is aligned too, simply for consistency# with old picamera versions). Warn the user as they're not going to# get the resolution they expectif not resize and format != 'yuv' and input_port.name.startswith('vc.ril.video_splitter'):# Workaround: Expected frame size is rounded to 16x16 when splitter# port with no resizer is used and format is not YUVfwidth = bcm_host.VCOS_ALIGN_UP(width, 16)else:fwidth = bcm_host.VCOS_ALIGN_UP(width, 32)fheight = bcm_host.VCOS_ALIGN_UP(height, 16)if fwidth != width or fheight != height:warnings.warn(PiCameraResolutionRounded("frame size rounded up from %dx%d to %dx%d" % (width, height, fwidth, fheight)))if resize:resize = (fwidth, fheight)# Workaround: Calculate the expected frame size, to be used by the# callback to decide when a frame ends. This is to work around a# firmware bug that causes the raw image to be returned twice when the# maximum camera resolution is requestedself._frame_size = int(fwidth * fheight * bpp)super(PiRawMixin, self).__init__(parent, camera_port, input_port, format, resize, **options)def _create_encoder(self, format):"""Overridden to skip creating an encoder. Instead, this class simply usesthe resizer's port as the output port (if a resizer has beenconfigured) or the specified input port otherwise."""if self.resizer:self.output_port = self.resizer.outputs[0]else:self.output_port = self.input_porttry:self.output_port.format = self.RAW_ENCODINGS[format][0]except KeyError:raise PiCameraValueError('unknown format %s' % format)self.output_port.commit()def _callback_write(self, buf, key=PiVideoFrameType.frame):"""_callback_write(buf, key=PiVideoFrameType.frame)Overridden to strip alpha bytes when required."""if self._strip_alpha:return super(PiRawMixin, self)._callback_write(MMALBufferAlphaStrip(buf._buf), key)else:return super(PiRawMixin, self)._callback_write(buf, key)

在这里插入图片描述

class PiVideoFrame(namedtuple('PiVideoFrame', ('index',         # the frame number, where the first frame is 0'frame_type',    # a constant indicating the frame type (see PiVideoFrameType)'frame_size',    # the size (in bytes) of the frame's data'video_size',    # the size (in bytes) of the video so far'split_size',    # the size (in bytes) of the video since the last split'timestamp',     # the presentation timestamp (PTS) of the frame'complete',      # whether the frame is complete or not))):"""This class is a :func:`~collections.namedtuple` derivative used to storeinformation about a video frame. It is recommended that you access theinformation stored by this class by attribute name rather than position(for example: ``frame.index`` rather than ``frame[0]``)... attribute:: indexReturns the zero-based number of the frame. This is a monotonic counterthat is simply incremented every time the camera starts outputting anew frame. As a consequence, this attribute cannot be used to detectdropped frames. Nor does it necessarily represent actual frames; itwill be incremented for SPS headers and motion data buffers too... attribute:: frame_typeReturns a constant indicating the kind of data that the frame contains(see :class:`PiVideoFrameType`). Please note that certain frame typescontain no image data at all... attribute:: frame_sizeReturns the size in bytes of the current frame. If a frame is writtenin multiple chunks, this value will increment while :attr:`index`remains static. Query :attr:`complete` to determine whether the framehas been completely output yet... attribute:: video_sizeReturns the size in bytes of the entire video up to this frame.  Notethat this is unlikely to match the size of the actual file/streamwritten so far. This is because a stream may utilize buffering whichwill cause the actual amount written (e.g. to disk) to lag behind thevalue reported by this attribute... attribute:: split_sizeReturns the size in bytes of the video recorded since the last call toeither :meth:`~PiCamera.start_recording` or:meth:`~PiCamera.split_recording`. For the reasons explained above,this may differ from the size of the actual file/stream written so far... attribute:: timestampReturns the presentation timestamp (PTS) of the frame. This representsthe point in time that the Pi received the first line of the frame fromthe camera.The timestamp is measured in microseconds (millionths of a second).When the camera's clock mode is ``'reset'`` (the default), thetimestamp is relative to the start of the video recording.  When thecamera's :attr:`~PiCamera.clock_mode` is ``'raw'``, it is relative tothe last system reboot. See :attr:`~PiCamera.timestamp` for moreinformation... warning::Currently, the camera occasionally returns "time unknown" values inthis field which picamera represents as ``None``. If you arequerying this property you will need to check the value is not``None`` before using it. This happens for SPS header "frames",for example... attribute:: completeReturns a bool indicating whether the current frame is complete or not.If the frame is complete then :attr:`frame_size` will not incrementany further, and will reset for the next frame... versionchanged:: 1.5Deprecated :attr:`header` and :attr:`keyframe` attributes and added thenew :attr:`frame_type` attribute instead... versionchanged:: 1.9Added the :attr:`complete` attribute."""__slots__ = () # workaround python issue #24931@propertydef position(self):"""Returns the zero-based position of the frame in the stream containingit."""return self.split_size - self.frame_size@propertydef keyframe(self):"""Returns a bool indicating whether the current frame is a keyframe (anintra-frame, or I-frame in MPEG parlance)... deprecated:: 1.5Please compare :attr:`frame_type` to:attr:`PiVideoFrameType.key_frame` instead."""warnings.warn(PiCameraDeprecated('PiVideoFrame.keyframe is deprecated; please check ''PiVideoFrame.frame_type for equality with ''PiVideoFrameType.key_frame instead'))return self.frame_type == PiVideoFrameType.key_frame@propertydef header(self):"""Contains a bool indicating whether the current frame is actually anSPS/PPS header. Typically it is best to split an H.264 stream so thatit starts with an SPS/PPS header... deprecated:: 1.5Please compare :attr:`frame_type` to:attr:`PiVideoFrameType.sps_header` instead."""warnings.warn(PiCameraDeprecated('PiVideoFrame.header is deprecated; please check ''PiVideoFrame.frame_type for equality with ''PiVideoFrameType.sps_header instead'))return self.frame_type == PiVideoFrameType.sps_header

在这里插入图片描述
这个.frame就是0,用在encoder里

在这里插入图片描述

在这里插入图片描述
self.outputs就是个字典,以下是填入对象
在这里插入图片描述
mo.open_stream:
在这里插入图片描述
就是读写咯
在这里插入图片描述
乖乖,就是说encoder有outputs字典,可以存储多种output.

找了半天还是没找到关于buffer_count的
在这里插入图片描述

picamera2库有相关设置调整,picamera貌似内置好的
在这里插入图片描述

buffer_count在摄像头捕获和处理图像时起着重要作用。它表示用于存储图像数据的缓冲区数量。这些缓冲区是临时的存储空间,用于在图像从摄像头传感器读取并传输到应用程序或处理器进行进一步处理时暂存图像数据。
具体来说,buffer_count的作用包括:
图像连续性:当摄像头连续捕获图像时,每个缓冲区都会存储一帧图像的数据。通过设置足够的缓冲区数量,可以确保摄像头能够连续地捕获图像,而不会因为处理速度不够快而丢失帧。这样,就能够保证图像流的连续性。
性能优化:适当的缓冲区数量可以平衡摄像头捕获速度和应用程序处理速度之间的差异。如果缓冲区数量太少,摄像头可能会因为等待应用程序处理完前一帧而减慢捕获速度。而如果缓冲区数量过多,可能会占用过多的内存资源,导致效率下降。因此,根据系统的性能和需求,设置合适的buffer_count可以提高图像处理的效率和性能。
资源管理:缓冲区数量也涉及到内存资源的管理。每个缓冲区都需要占用一定的内存空间。通过控制buffer_count,可以管理摄像头系统所使用的内存量,以确保资源的合理利用。
综上所述,buffer_count在摄像头捕获和处理图像时起到了关键的作用,它影响着图像连续性、性能优化和资源管理。通过合理设置buffer_count,可以确保摄像头系统的高效运行和图像质量。

目前未找到硬编码位置,,,,,,,,

这篇关于2023-简单点-picamera的bayer数据获取抽丝剥茧的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/482827

相关文章

大模型研发全揭秘:客服工单数据标注的完整攻略

在人工智能(AI)领域,数据标注是模型训练过程中至关重要的一步。无论你是新手还是有经验的从业者,掌握数据标注的技术细节和常见问题的解决方案都能为你的AI项目增添不少价值。在电信运营商的客服系统中,工单数据是客户问题和解决方案的重要记录。通过对这些工单数据进行有效标注,不仅能够帮助提升客服自动化系统的智能化水平,还能优化客户服务流程,提高客户满意度。本文将详细介绍如何在电信运营商客服工单的背景下进行

基于MySQL Binlog的Elasticsearch数据同步实践

一、为什么要做 随着马蜂窝的逐渐发展,我们的业务数据越来越多,单纯使用 MySQL 已经不能满足我们的数据查询需求,例如对于商品、订单等数据的多维度检索。 使用 Elasticsearch 存储业务数据可以很好的解决我们业务中的搜索需求。而数据进行异构存储后,随之而来的就是数据同步的问题。 二、现有方法及问题 对于数据同步,我们目前的解决方案是建立数据中间表。把需要检索的业务数据,统一放到一张M

关于数据埋点,你需要了解这些基本知识

产品汪每天都在和数据打交道,你知道数据来自哪里吗? 移动app端内的用户行为数据大多来自埋点,了解一些埋点知识,能和数据分析师、技术侃大山,参与到前期的数据采集,更重要是让最终的埋点数据能为我所用,否则可怜巴巴等上几个月是常有的事。   埋点类型 根据埋点方式,可以区分为: 手动埋点半自动埋点全自动埋点 秉承“任何事物都有两面性”的道理:自动程度高的,能解决通用统计,便于统一化管理,但个性化定

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

异构存储(冷热数据分离)

异构存储主要解决不同的数据,存储在不同类型的硬盘中,达到最佳性能的问题。 异构存储Shell操作 (1)查看当前有哪些存储策略可以用 [lytfly@hadoop102 hadoop-3.1.4]$ hdfs storagepolicies -listPolicies (2)为指定路径(数据存储目录)设置指定的存储策略 hdfs storagepolicies -setStoragePo

Hadoop集群数据均衡之磁盘间数据均衡

生产环境,由于硬盘空间不足,往往需要增加一块硬盘。刚加载的硬盘没有数据时,可以执行磁盘数据均衡命令。(Hadoop3.x新特性) plan后面带的节点的名字必须是已经存在的,并且是需要均衡的节点。 如果节点不存在,会报如下错误: 如果节点只有一个硬盘的话,不会创建均衡计划: (1)生成均衡计划 hdfs diskbalancer -plan hadoop102 (2)执行均衡计划 hd

csu 1446 Problem J Modified LCS (扩展欧几里得算法的简单应用)

这是一道扩展欧几里得算法的简单应用题,这题是在湖南多校训练赛中队友ac的一道题,在比赛之后请教了队友,然后自己把它a掉 这也是自己独自做扩展欧几里得算法的题目 题意:把题意转变下就变成了:求d1*x - d2*y = f2 - f1的解,很明显用exgcd来解 下面介绍一下exgcd的一些知识点:求ax + by = c的解 一、首先求ax + by = gcd(a,b)的解 这个

hdu2289(简单二分)

虽说是简单二分,但是我还是wa死了  题意:已知圆台的体积,求高度 首先要知道圆台体积怎么求:设上下底的半径分别为r1,r2,高为h,V = PI*(r1*r1+r1*r2+r2*r2)*h/3 然后以h进行二分 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#includ

【Prometheus】PromQL向量匹配实现不同标签的向量数据进行运算

✨✨ 欢迎大家来到景天科技苑✨✨ 🎈🎈 养成好习惯,先赞后看哦~🎈🎈 🏆 作者简介:景天科技苑 🏆《头衔》:大厂架构师,华为云开发者社区专家博主,阿里云开发者社区专家博主,CSDN全栈领域优质创作者,掘金优秀博主,51CTO博客专家等。 🏆《博客》:Python全栈,前后端开发,小程序开发,人工智能,js逆向,App逆向,网络系统安全,数据分析,Django,fastapi

usaco 1.3 Prime Cryptarithm(简单哈希表暴搜剪枝)

思路: 1. 用一个 hash[ ] 数组存放输入的数字,令 hash[ tmp ]=1 。 2. 一个自定义函数 check( ) ,检查各位是否为输入的数字。 3. 暴搜。第一行数从 100到999,第二行数从 10到99。 4. 剪枝。 代码: /*ID: who jayLANG: C++TASK: crypt1*/#include<stdio.h>bool h