当前位置:网站首页>[camera Foundation (II)] camera driving principle and Development & v4l2 subsystem driving architecture
[camera Foundation (II)] camera driving principle and Development & v4l2 subsystem driving architecture
2022-06-24 21:44:00 【Sweet galier】
Camera driving principle and development &&V4L2 Subsystem driven architecture
One 、 Import

Two 、 Camera data output format
1、USB、VS、MIPI Camera architecture
- MIPI The resolution supported by the interface camera 、 Higher frame rate , Low power .
- MIPI Than USB A lower cost ,USB Cameras are expensive .
- USB The workload of camera development is small , Generally, they are free from driving .
2、RAW RGB DATA
RAW RGB yes sensor Of bayer array Acquired data ( Each sensor obtains the corresponding color brightness ), camera sensor After photoelectric conversion, the output data is RAW data(RAW RGB). stay Sensor in , Each sensitive spot can only be sensitive to light RGB One of the colors . therefore , What is usually said 30 Megapixels or 130 Megapixels, etc , It means to have 30 Wanor 130 Ten thousand light spots , Each sensitive spot can only be sensitive to one color .
RGB: Traditional red green blue format . such as RGB565, Its 16bit The data format is 5bitR+6bitG+5BitB,G More than a , The reason is that human eyes are more sensitive to green .
3、RAW RGB And RGB The difference between
- RAW RGB Each pixel has only one color (R、G、B One of the )
- RGB Each pixel has three colors , Each value is in 0-255 Between .
- from sensor Output data RAW DATA(RAW RGB), after ISP The color interpolation transformation becomes RGB.
4、YUV
Y Represents the luminance component (Luma): If only Y Words , The image will look like a black-and-white photo .
U(Cb) Represents the chromaticity component : It's the blue part of the picture that removes the brightness (Y).
V(Cr) Represents the chromaticity component : It's the red part of the picture that removes the brightness (Y).
①YUV The advantages of :
And RGB comparison , His advantage is that it takes up less space
②YUV Sampling format for
There are three main ways of sampling ,YUV4:4:4,YUV4:2:2,YUV4:2:0
image quality :YUV4:4:4>YUV4:2:2>YUV4:2:0
YUV4:4:4 sampling , every last Y Corresponding to a group of UV component . intend 4 The data in pixels has 4 individual Y,4 individual U,4 individual V.
YUV4:2:2 sampling , every last Y Corresponding to a group of UV component . intend 4 The data in pixels has 4 individual Y,2 individual U,2 individual V.
YUV4:2:0 sampling , every last Y Corresponding to a group of UV component . intend 4 The data in pixels has 4 individual Y,1 individual U,1 individual V.
③YUV The storage format of
YUV The storage format of is divided into packaging format (packet formats) And flat format (planar formats).
- about planar Of YUV Format , First, store all pixels in a row Y, Subsequent storage U、V. The storage type is represented by the sampling method suffix plus P, Such as YUV422P、YUV420P.
- about packet Of YUV Format , Every pixel point Y,U,V It's a continuous alternate storage . The storage type is represented by the sampling method suffix plus SP, Such as YUV422SP、YUV420SP.

One frame YUV420 Image ,u and v The size of the space occupied by the component is... Of the original number of pixels 1/4, The total size occupied is widthheigth(3/2)
One frame YUV422 Image ,u and v The space occupied by the components is half of the original pixels , The total size occupied is widthheigth2
5、MJPEG/H264 Coding format
Some cameras sensor Support output MJPEG/H264 coded , Because it has built-in DSP processor , take YUV Output after data encoding MJPEG/H264 stream .
problem : When code is needed ? What's the role ? - Internet transmission , Reduce bandwidth .
- Video coding compatible , Unified video coding standard .
3、 ... and 、 Video coding principle

1、 The history of video coding 
2、 Video coding principle
I frame : Keyframes , Using intra frame compression technology .
P frame : Forward reference frame , In compression , Only refer to the previously processed frames , Using inter frame compression technology .
B frame : Two way reference frame , In compression , It refers to the previous frame , Also refer to the frame behind it , Using inter frame compression technology .
except I/P/B Out of frame , And image sequences GOP.
GOP: Two I Between the frames is an image sequence , There is only one frame in an image sequence . On the premise of constant bit rate ,GOP The bigger the value is. ,P、B The more frames there will be , Average each I、P、B The more bytes a frame takes , It's easier to get better image quality . Pictured :
Four 、V4L2 Subsystem driven architecture
V4L2: yes linux The kernel driver framework of video devices in the kernel , It provides a unified interface for the upper layer to access the lower layer video devices .
V4L2 Drive the core : It is mainly to build a standard video device driver framework in the kernel , Provide unified interface function for video operation .
platform V4L2 Device drivers : stay V4L2 Within the framework of , According to the characteristics of the platform, the platform related V4L2 Drive part , Including registration video_device and v4l2_dev
Concrete sensor drive : Main power on 、 Provide working clock 、 Video image clipping 、 flow IO Turn on, etc , Implement various device control methods for the upper layer to call and register v4l2_subdev.
UVC: It's a kind of usb Video device driver . Used to support usb Video device , Anyone who usb Interface cameras can support .
V4L2 The core source code of is located in drivers/media/v4l2-core, According to the function, it can be divided into four categories :
- Character device module : from v4l2-dev.c Realization , Main function application character main equipment number 、 register class And to provide video device register 、 Logout and other related functions .
- v4l2 Basic framework L: from v4l2-device.c、v3l2-subdev.c、v3l2-fh.c、v4l2-ctrls.c Wait for the file to build v4l2 Basic framework .
- videobuf management : from videobuf2-core.c、videobuf2-dma-contig.c、videobuf2-dma-sg.c、videobuf2-memops.c、videobuf2-vmalloc.c、v3l2-mem2mem.c Wait for the file to be implemented , complete videobuffer The distribution of 、 Manage and log off .
- loctl frame : from v4l2-ioctl.c File implementation , structure v4l2 ioctl Framework .
V4L2 Registration process :
videobuf management :
V4L2 ioctl frame
User space for V4L2 The operation of the equipment is basically ioctl To achieve ,V4L2 The equipment has a large number of operable functions ( Configuration register ), therefore V4L2 Of ioctl It is also very huge .
V4L2 The driver mainly uses ioctl The command values are as follows :
5、 ... and 、 Camera video capture process

Camera data stream :
6、 ... and 、 Common typical problems
1、 The camera picture is stuck
- Insufficient frame rate
- usb Not enough bandwidth
- Video capture format setting error :YUV、MJPEG or H264 Format
- Encoding and decoding problems
- CPU Take up high
2、 The camera image rotates 90 Degree or 180 Degree problem
3、 The camera picture cannot be opened
边栏推荐
- Analysis of tcpdump packet capturing kernel code
- Auto. JS to realize automatic unlocking screen
- Distributed basic concepts
- Functional analysis of ebpf sockops
- socket(1)
- Remove the screen recording reminder (seven cattle cloud demo)
- B站带货当学新东方
- Please open online PDF carefully
- 数据链路层 && 一些其他的协议or技术
- Rewrite, maplocal and maplocal operations of Charles
猜你喜欢

About transform InverseTransformPoint, transform. InverseTransofrmDirection

socket done

Why are life science enterprises on the cloud in succession?

memcached全面剖析–2. 理解memcached的內存存儲

Alibaba cloud lightweight servers open designated ports

Concepts of kubernetes components

Volcano成Spark默认batch调度器

Big factories go out to sea and lose "posture"

Oauth2.0 introduction

BPF_ PROG_ TYPE_ SOCKET_ Filter function implementation
随机推荐
123. 买卖股票的最佳时机 III
Interpretation of ebpf sockops code
TCP_ Nodelay and TCP_ CORK
Graduation summary of phase 6 of the construction practice camp
Auto. JS to automatically authorize screen capture permission
【Camera基础(一)】Camera摄像头工作原理及整机架构
Implementation of adjacency table storage array of graph
BBR bandwidth per second conversion logic
Pattern recognition - 9 Decision tree
When to send the update windows message
WMI and PowerShell get TCP connection list
Bld3 getting started UI
memcached完全剖析–1. memcached的基础
Decoration home page custom full screen video playback effect GIF dynamic picture production video tutorial playback code operation settings full screen center Alibaba international station
Visit Amazon memorydb and build your own redis memory database
EditText controls the soft keyboard to search
Functional analysis of ebpf tracepoint
Volcano成Spark默认batch调度器
基于STM32的物联网下智能化养鱼鱼缸控制控制系统
VirtualBox virtual machine installation win10 Enterprise Edition