logo资料库

官方教程(raspberry-pi-camera-guide).pdf

第1页 / 共60页
第2页 / 共60页
第3页 / 共60页
第4页 / 共60页
第5页 / 共60页
第6页 / 共60页
第7页 / 共60页
第8页 / 共60页
资料共60页,剩余部分请下载后查看
Introduction
Overview
The Camera Module
CSI Connector
On-Chip Hardware
Software and Control Algorithms
Driver Framework
Provisions for the Sensor Subdevice
The CamHelper Class
Device Tree Considerations
Control Algorithm Overview
Framework
Defining and Loading Algorithms
Standard Algorithms
Algorithm Communication
Performance Considerations
Example Camera Tuning File
Directory Structure
Raspberry Pi Control Algorithms
Black Level
Name
Overview
Metadata Dependencies
Defective Pixel Correction (DPC)
Name
Overview
Parameters
Metadata Dependencies
Lux
Name
Overview
Parameters
Metadata Dependencies
Noise
Name
Overview
Parameters
Metadata Dependencies
GEQ (Green Equalisation)
Name
Overview
Parameters
Metadata Dependencies
SDN (Spatial Denoise)
Name
Overview
External API
Parameters
Metadata Dependencies
AWB (Automatic White Balance)
Name
Overview
Implementation
External API
Parameters
Metadata Dependencies
Extensions
AGC/AEC (Automatic Gain Control / Automatic Exposure Control)
Name
Overview
Implementation
External API
Parameters
Metadata Dependencies
ALSC (Automatic Lens Shading Correction)
Name
Overview
Adaptive ALSC Algorithm
Implementation
Parameters
Metadata Dependencies
Contrast
Name
Overview
External API
Parameters
Metadata Dependencies
CCM (Colour Correction Matrices)
Name
Overview
External API
Parameters
Metadata Dependencies
Sharpening
Name
Overview
Parameters
Metadata Dependencies
Metadata and Statistics Usage
Camera Tuning Tool
Overview
Raspberry Pi libcamera-apps
Software Requirements
Equipment
X-rite (Macbeth) Colour Checker
Colorimeter
Integrating Spheres and Flat Field LEDs
Capturing Calibration Images with libcamera
Prepare your Pi
Capturing a Raw Image
Image Capture Requirements
Macbeth Chart Images
Lens Shading Images
Creating the Tuning
Collecting the Files
Running the Tool
Tweaking the Tuning produced by the Tool
Blocks not Tuned
Guidance on how to Tweak the Tuning
Raspberry Pi Camera Algorithm and Tuning Guide Raspberry Pi Trading Ltd.
Raspberry Pi Camera Algorithm and Tuning Guide Colophon Released under the BSD 2-Clause "Simplified" License. Copyright © 2021, Raspberry Pi Trading Ltd. All rights reserved. Compiled on 31/01/2021 Version 1.2(5b3eff95b9618ac0829cf76181539efbad07e9f2) Revision History Version Date Description 1.2 1.1 1.0 30-Jan-2021 Update formatting and style template to match internal guidelines. 27-Jan-2021 Update to CamHelper and various algorithm APIs. Also use of qcam replaced by libcamera-apps. 15-May-2020 Initial revision. Raspberry Pi Trading Ltd.
Raspberry Pi Camera Algorithm and Tuning Guide Contents 1 Introduction 2 Overview . 2.1 The Camera Module . . . 2.2 CSI Connector . 2.3 On-Chip Hardware . . . 2.4 Software and Control Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Driver Framework 3.1 Provisions for the Sensor Subdevice . . 3.2 The CamHelper Class . . 3.3 Device Tree Considerations . . . . . . . . . . . . 4 Control Algorithm Overview . . . . . . . . . . . . . 4.1 Framework . . 4.2 Defining and Loading Algorithms . . . 4.3 Standard Algorithms . . . 4.4 Algorithm Communication . . . 4.5 Performance Considerations . 4.6 Example Camera Tuning File . . . . 4.7 Directory Structure . . . . . . . . . . . . 5.1 Black Level 5 Raspberry Pi Control Algorithms . . . . . . . . . . . . . . . . . . 5.3 Lux . 5.4 Noise . 5.2 Defective Pixel Correction (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.1 Name . . 5.1.2 Overview . . 5.1.3 Metadata Dependencies . . . . 5.2.1 Name . . . 5.2.2 Overview . . 5.2.3 Parameters . . 5.2.4 Metadata Dependencies . . . . . . . 5.3.1 Name . . . 5.3.2 Overview . . 5.3.3 Parameters . . 5.3.4 Metadata Dependencies . . . . . . . 5.4.1 Name . . . 5.4.2 Overview . . . 5.4.3 Parameters . 5.4.4 Metadata Dependencies . . . . 5.5.1 Name . . . . 5.5.2 Overview . 5.5.3 Parameters . . 5.5.4 Metadata Dependencies . . . 5.6.1 Name . . . 5.6.2 Overview . . 5.6.3 External API 5.6.4 Parameters . . 5.6.5 Metadata Dependencies . . . . 5.7.1 Name . . 5.7.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.7 AWB (Automatic White Balance) . . . . . . . . . . . . . 5.5 GEQ (Green Equalisation) . . . . . . . . . . 5.6 SDN (Spatial Denoise) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Raspberry Pi Trading Ltd. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 2 2 3 3 4 4 6 7 8 8 8 9 9 10 10 12 13 13 13 13 13 14 14 14 14 14 15 15 15 15 15 16 16 16 16 16 16 16 16 17 17 18 18 18 18 19 19 19 19 19
Raspberry Pi Camera Algorithm and Tuning Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Extensions . Implementation . . . . 5.7.3 . 5.7.4 External API 5.7.5 Parameters . . 5.7.6 Metadata Dependencies . 5.7.7 . . . 5.8.1 Name . . . 5.8.2 Overview . . . 5.8.3 Implementation . . 5.8.4 External API . 5.8.5 Parameters . . . 5.8.6 Metadata Dependencies . . . . . . 5.8 AGC/AEC (Automatic Gain Control / Automatic Exposure Control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.9 ALSC (Automatic Lens Shading Correction) . . . . . . . . . . . . . . . . . . . . . . . . . 5.9.1 Name . . 5.9.2 Overview . . 5.9.3 Adaptive ALSC Algorithm . 5.9.4 Implementation . . 5.9.5 Parameters . . . 5.9.6 Metadata Dependencies . . . . . 5.10.1 Name . . . 5.10.2 Overview . . 5.10.3 External API 5.10.4 Parameters . . 5.10.5 Metadata Dependencies . 5.11 CCM (Colour Correction Matrices) . . . . . 5.11.1 Name . . . 5.11.2 Overview . . 5.11.3 External API . 5.11.4 Parameters . 5.11.5 Metadata Dependencies . . . . . . 5.12.1 Name . . . 5.12.2 Overview . . . 5.12.3 Parameters . . 5.12.4 Metadata Dependencies . . 5.13 Metadata and Statistics Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.12 Sharpening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.10 Contrast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Camera Tuning Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1 Overview . . 6.2 Raspberry Pi libcamera-apps . . 6.3 Software Requirements . 6.4 Equipment . . . . . . . . . . . 6.4.1 X-rite (Macbeth) Colour Checker 6.4.2 Colorimeter . . . 6.4.3 Integrating Spheres and Flat Field LEDs . . . . . . . . . . . . . 6.5 Capturing Calibration Images with libcamera . . . . . . . . . . 6.9.1 Blocks not Tuned . . 6.9.2 Guidance on how to Tweak the Tuning . . . . . . . . . 6.9 Tweaking the Tuning produced by the Tool . 6.5.1 Prepare your Pi . . 6.5.2 Capturing a Raw Image . . 6.6.1 Macbeth Chart Images . . . . . . . 6.8.1 Collecting the Files . 6.8.2 Running the Tool . . 6.7 Lens Shading Images . . 6.8 Creating the Tuning . 6.6 Image Capture Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Raspberry Pi Trading Ltd. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 . 23 . 23 . 24 . 25 . 25 . 25 . 25 . 28 . 29 . 30 . 30 . 31 . 31 . 31 . 32 . 34 . 34 . 35 . 36 . 36 . 36 . 37 . 37 . 37 . 38 . 38 . 38 . 39 . 39 . 39 . 39 . 39 . 39 . 40 . 40 . 40 42 . 42 . 42 . 42 . 43 . 43 . 43 . 44 . 44 . 44 . 44 . 45 . 45 . 46 . 46 . 46 . 47 . 48 . 48 . 49
Raspberry Pi Camera Algorithm and Tuning Guide List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 1 2 3 4 . . Connecting a camera board through the CSI port. . . Overview of the libcamera system, explained below. . Control algorithms use image metadata and statistics to update their parameters. . Magnified image showing a bright defective pixel - its effect spreads slightly because of the fil- . tering operations performed using it. . . 14 . . Highly magnified image showing maze artifacts (right), and correction (left). 17 . . . Same image as figure 5, highly magnified, showing “noise speckles”. . 18 CT Curve showing colour temperature associated with each point. . . . . 20 AWB example - the incandascent illuminant gives a more plausible result than the daylight one. . 21 . 26 AGC metering regions. . . 27 . 28 . 31 5 6 7 8 9 . 10 Cumulative frequency: a proportion q of the pixels lie below the value p . 11 12 13 . . . . . An example exposure profile - analogue gain and shutter time increase one after the other. Lens shading: no correction (left), luminance correction only (middle), full correction (right). . A grid of 16x12 lens shading gains. The grid may extend slightly beyond the image to ensure . . . . every pixel is covered. . . Cells and their neighbours in a 16x12 grid. . . . An example gamma curve with 16-bit inputs and outputs. . Sharpening Parameter model . . . Usage of image metadata and other information by ISP control algorithms. X-rite Macbeth Chart. . . . . . A Colorimeter. . . . . . 31 . 33 14 . 36 15 . 39 16 . 40 17 . 43 . 18 . 43 19 . . 45 20 Acceptable Macbeth Chart calibration images. 21 . 46 . 22 Too little denoise (left), and on the right the leaves look even more plasticky than they really are! . 50 . . 51 23 . 51 . 24 25 . . 52 26 No contrast enhancement (left) and strong contrast enhancement (right) - note the change to . . Effect of setting sensitivities to 0.8 (left), 1.0 (centre) and 1.2 (right). . . base_ev at the default value 1.0 on the left, and at 1.414 - about half a stop - on the right. sigma has the extreme value 0.03 on the left - spot the purple halo round the green chair. Lens shading images . . 53 . 54 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . the image histogram. . 27 On the left too much residual noise is being sharpened because threshold was lowered. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Raspberry Pi Trading Ltd.
Raspberry Pi Camera Algorithm and Tuning Guide List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fields of the CameraMode class. . 2 Algorithm type monikers. . . 3 Raspberry Pi controller folder structure. . 4 Black level algorithm parameters. . . 5 Defective pixel correction algorithm parameters. 6 . . Lux algorithm parameters. . 7 . Noise algorithm parameters. . 8 Green equalisation algorithm parameters. . 9 . . 10 Denoise algorithm public API. . . . 11 . . . 12 . . . 13 . . . 14 . . . 15 . . . 16 . . . 17 . . . 18 . . 19 . . . 20 Sharpening algorithm parameters. Camera tuning tool command line options. . 21 22 Camera tuning tool runtime config parameters. . Spatial denoise algorithm parameters. . . AWB algorithm public API. . . AWB algorithm parameters. . . . AGC algorithm public API. . . . AGC algorithm parameters. . . ALSC algorithm parameters. . Contrast algorithm public API. . . Contrast algorithm parameters. . . CCM algorithm parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 . 9 . 12 . 13 . 14 . 15 . 16 . 17 . 18 . . 19 . 23 . 24 . 29 . 30 . 35 . 37 . 37 . 39 . 40 . 47 . 48 Raspberry Pi Trading Ltd.
Raspberry Pi Camera Algorithm and Tuning Guide 1 Introduction The “Raspberry Pi Camera Algorithm and Tuning Guide” is intended for users of the Raspberry Pi computer with an image sensor (camera) connected through the Raspberry Pi’s CSI (Camera Serial Interface) camera port, such as either of the official Raspberry Pi camera boards using the version 1 (Omnivision OV5647) or version 2 (Sony imx219) sensors, or the High Quality Camera (aka. the HQ Cam, based on the Sony imx477). Figure 1: Connecting a camera board through the CSI port. The software stack driving the camera system will be libcamera. Experience has shown that driving complex camera systems directly through kernel (typically, V4L2) drivers is very difficult, often leading to large amounts of undesirable and highly platform-specific application code. For this reason a much higher level userspace camera stack, libcamera, has emerged providing mechanisms to integrate 3rd party image sensors and Image Signal Processors (ISPs). Here we describe just such an integration, showing how drivers can be written to make the components of the Raspberry Pi imaging system work with libcamera, concentrating in particular on the processes of calibrating and tuning the ISP to work well with different image sensors. Moreover, the libcamera integration avoids using any of the proprietary control algorithms supplied by the chip vendor (Broadcom). Rather, Raspberry Pi is pro- viding its own control algorithms, running directly on the chip’s ARM cores, as open source code which can be easily inspected and modified by users. This document is not specifically a tutorial on or guide to libcamera itself, for which the reader is referred to http://libcamera.org for more information. The remainder of this document is organised as follows. • Chapter 2: Overview. This is a brief overview of the system as a whole, showing what is already pro- vided, and what must be added in terms of image sensor drivers and ISP control algorithms to obtain a successful images. • Chapter 3: Camera Drivers. As far as possible the camera, or image sensor, is driven by a standard type of kernel driver. However, there are one or two details involved in making drivers work optimally in the Raspberry Pi framework. • Chapter 4: Control Algorithm Overview. Raspberry Pi provides a control algorithm framework which makes it very easy for applications to use Raspberry Pi’s, or anyone else’s, ISP control algorithms. • Chapter 5: Raspberry Pi Control Algorithms. Here we supply a detailed description of Raspberry Pi’s implementation of the control algorithms. • Chapter 6: Camera Tuning Tool. Finally, there is also a Camera Tuning Tool which automates most of the process of tuning the ISP control algorithms for different image sensors. For further help beyond the contents of this user guide, please visit the Raspberry Pi Camera Board forum at https://www.raspberrypi.org/forums. 1 Introduction 1
Raspberry Pi Camera Algorithm and Tuning Guide 2 Overview We have already seen the camera board connected through the ribbon cable to the CSI port on the Raspberry Pi itself. Figure 2: Overview of the libcamera system, explained below. 2.1 The Camera Module Raspberry Pi already produces compatible camera boards based on the Sony imx219 (the version 2 camera), the Sony imx477 (the HQ Cam) and of course there is an older (version 1) camera board based on the Omnivision OV5647. These are Bayer sensors, that is, they output so-called “raw” Bayer images which have not yet been processed into anything a user could recognise. These raw pixels are transmitted back to the system-on-chip (SoC) in discrete image frames, using the MIPI CSI-2 protocol. This is the 2nd version of the CSI (Camera Serial Inter- face) defined by the MIPI (originally “Mobile Industry Processor Interface”) Alliance, an organisation dedicated to standardising interfaces between different components of mobile devices. 2.2 CSI Connector Besides supplying power and clock signals, the ribbon cable performs two principal functions. It allows com- mands (typically register updates) to be sent to the image sensor using the I2C interface. These values define the operating mode of the sensor, including the output image size and framerate, as well as commands to start and stop streaming images. Secondly, the output images from the camera are transmitted through the cable along the CSI-2 interface back to the Broadcom SoC (system-on-chip) at the heart of the Pi. A more detailed specification of the modules and connector, including a link to the schematics, can be found at https://www.raspberrypi.org/documentation/hardware/camera/README.md. 2 Overview 2 PipelineHandlerControlAlgorithms (IPAs)I2CInterfaceControlAlgorithms (IPAs)UnicamISPCommandsPixelsControlParametersand dataUserspaceKernelCameraModuleCSI-2I2Clibcamera
分享到:
收藏