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,可以确保摄像头系统的高效运行和图像质量。

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/267238.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

手机来电显示私密号码怎么回事?

手机来电显示私密号码是很多用户经常遇到的问题,那么手机来电显示私密号码怎么回事呢? 原因 手机来电显示私密号码一般有以下几种原因: 对方使用了网络电话或开通了隐藏号码服务。网络电话是一种通过互联网进行通话的服务,一般…

深入理解强化学习——马尔可夫决策过程:预测与控制

分类目录&#xff1a;《深入理解强化学习》总目录 预测&#xff08;Prediction&#xff09;和控制&#xff08;Control&#xff09;是马尔可夫决策过程里面的核心问题。预测&#xff08;评估一个给定的策略&#xff09;的输入是马尔可夫决策过程 < S , A , R , P , γ > …

SQL自学通之函数 :对数据的进一步处理

目录 一、目标 二、汇总函数 COUNT SUM AVG MAX MIN VARIANCE STDDEV 三、日期/时间函数 ADD_MONTHS LAST_DAY MONTHS_BETWEEN NEW_TIME NEXT_DAY SYSDATE 四、数学函数 ABS CEIL 和FLOOR COS、 COSH 、SIN 、SINH、 TAN、 TANH EXP LN and LOG MOD POW…

unity 3分钟 制作粒子爆炸效果 可以用在三消消除等

思路就是&#xff1a; 有一个对象池&#xff0c;管理各种特效。 当需要播放特效时&#xff0c;触发如下代码&#xff1a; blocker为粒子生成的位置 var particles gamePools.iceParticlesPool.GetObject(); if (particles ! null) {particles.transform.position blocker…

UnoCSS 原子化开发初体验

UnoCSS 是一个即时的原子化 CSS 引擎&#xff0c;旨在灵活和可扩展。核心是不拘一格的&#xff0c;所有的 CSS 工具类都是通过预设提供的。再也不用为了取一个 classname 类名而烦恼了。 一、UnoCSS 特点 完全可定制&#xff1a;无核心工具&#xff0c;所有功能都通过预设提供…

恢复Django 项目

随笔记录 目录 1. 重建Mysql DB 2. 启动Django 项目 2.1 确保你的系统上已安装pip工具。你可以使用以下命令来检查pip是否已安装 2.2 安装Packages 2.2.1 安装Django 2.2.2 安装pymysql 2.2.3 安装 kafka 2.2.4 安装 requests 2.2.5 安装simplepro 2.2.6 安装libjp…

nodejs+vue+微信小程序+python+PHP的外卖数据分析-计算机毕业设计推荐django

构建一种完全可实现、可操作的开放源代码信息收集系统&#xff0c;帮助记者完成工作任务。采编人员仅需输入所收集到的网址及题目即可迅速启动收集工作并进行信息归类。 2.根据新的数据收集要求&#xff0c;采用云计算技术实现新的收集器的迅速部署。对于资料采集点的改版&…

电工--半导体器件

目录 半导体的导电特性 PN结及其单向导电性 二极管 稳压二极管 双极型晶体管 半导体的导电特性 本征半导体&#xff1a;完全纯净的、晶格完整的半导体 载流子&#xff1a;自由电子和空穴 温度愈高&#xff0c;载流子数目愈多&#xff0c;导电性能就愈好 型半导体&…

随机生成验证码的jar包

这是已经开发好的验证码&#xff0c;咱们直接调用接口&#xff0c;拿过来直接用就可以了 链接&#xff1a;https://pan.baidu.com/s/1QMPhW5UzxmhIa7THFab5hw 提取码&#xff1a;6666 下面演示一下&#xff1a; 首先创建一个Code来先生成随机验证码&#xff0c;然后传…

使用NCNN在华为M5部署MobileNet-SSD

一、下载ncnn-android-vulkan ncnn-android-vulkan.zip 文件是一个压缩文件&#xff0c;其中包含了 ncnn 框架在 Android 平台上使用 Vulkan 图形库加速的相关文件和代码。 在 Android 平台上&#xff0c;ncnn 框架可以利用 Vulkan 的并行计算能力来进行神经网络模型的推理计…

Leetcode415 字符串相加

字符串相加 题解1 竖式加法(从后往前) 给定两个字符串形式的非负整数 num1 和 num2 &#xff0c;计算它们的和并同样 以字符串形式返回。 你不能使用任何內建的用于处理大整数的库&#xff08;比如 BigInteger&#xff09;&#xff0c; 也不能直接将输入的字符串转换为整数形…

网络安全——SSH密码攻击实验

一、实验目的要求&#xff1a; 二、实验设备与环境&#xff1a; 三、实验原理&#xff1a; 四、实验步骤&#xff1a;​ 五、实验现象、结果记录及整理&#xff1a; 六、分析讨论与思考题解答&#xff1a; 网络安全-SSH密码攻击实验效果截图&#xff1a; https://downloa…