xref: /aosp_15_r20/pdk/apps/TestingCamera2/README.txt (revision ac7df209e3ba002eb4fcfc7c8d4b818a0371fca4)
1*ac7df209SYuntao XuTestingCamera2 is a test application for the Android camera2 API (android.hardware.camera2.*).
2*ac7df209SYuntao Xu
3*ac7df209SYuntao Xu1. Overview
4*ac7df209SYuntao Xu
5*ac7df209SYuntao XuThe goal of Testingcamera2 is to allow all API primitives and behaviors to be excercised through
6*ac7df209SYuntao Xua reasonable UI, and allow simple demos and test cases to be built on top of it.
7*ac7df209SYuntao Xu
8*ac7df209SYuntao XuThe concepts the application uses match the concepts of the API itself, so any given configuration
9*ac7df209SYuntao Xuin the application can easily be reproduced directly with the camera2 API.
10*ac7df209SYuntao Xu
11*ac7df209SYuntao Xu2. UI concepts:
12*ac7df209SYuntao Xu
13*ac7df209SYuntao XuThe UI is divided into two panels, organized either side-by-side (in landscape orientations) or
14*ac7df209SYuntao Xuabove each other (in portrait orientations).
15*ac7df209SYuntao Xu
16*ac7df209SYuntao XuThe left (or above) panel generally displays output from the camera subsystem, while the right
17*ac7df209SYuntao Xu(or below) panel generally has controls for interacting with the camera subsystem.
18*ac7df209SYuntao Xu
19*ac7df209SYuntao XuEach category of object in the API is configured through a pane dedicated to that category; the
20*ac7df209SYuntao Xupanes are grouped in lists by category, and can be added, removed, or collapsed from view
21*ac7df209SYuntao Xuarbitrarily.
22*ac7df209SYuntao Xu
23*ac7df209SYuntao XuThe left pane contains target panes along with the app's overall log pane.  The right pane contains
24*ac7df209SYuntao Xucamera, request, burst, and utility panes.
25*ac7df209SYuntao Xu
26*ac7df209SYuntao XuThe basic operation of the app is as follows:
27*ac7df209SYuntao Xu
28*ac7df209SYuntao Xu  1. Add a camera pane, select camera to use
29*ac7df209SYuntao Xu  2. Add at least one target pane, and for each, select the kind of target desired and its
30*ac7df209SYuntao Xu     configuration options.
31*ac7df209SYuntao Xu  3. Open and configure the camera from the camera pane
32*ac7df209SYuntao Xu  4. Add a request pane, select the desired camera and targets, and the desired use case template.
33*ac7df209SYuntao Xu  5. Start capturing images with either 'capture' (one-shot) or 'repeat' (continuous) buttons on
34*ac7df209SYuntao Xu     the request.
35*ac7df209SYuntao Xu
36*ac7df209SYuntao XuThe application also has a set of preset configurations that can be accessed from the top-right
37*ac7df209SYuntao Xudropdown menu, to speed up operation.
38*ac7df209SYuntao Xu
39*ac7df209SYuntao Xu2.1. Camera panes
40*ac7df209SYuntao Xu
41*ac7df209SYuntao XuThe camera pane includes device-level controls for a single camera, which can be selected from all
42*ac7df209SYuntao Xuthe cameras available on the Android device.  It allows for opening the device, reading out its
43*ac7df209SYuntao Xucamera characteristics information, for configuring a set of targets, and for stopping or flushing
44*ac7df209SYuntao Xuthe camera.
45*ac7df209SYuntao Xu
46*ac7df209SYuntao Xu2.2. Target panes
47*ac7df209SYuntao Xu
48*ac7df209SYuntao XuTarget panes represent various destinations for camera data.  The kind of destination desired, and
49*ac7df209SYuntao Xuthe camera this target is meant for, are always available to select.  Each kind of destination
50*ac7df209SYuntao Xuhas its own set of controls for configuration and operation.
51*ac7df209SYuntao Xu
52*ac7df209SYuntao XuThe pane always has a 'configure' toggle, which specifies whether that target pane will be included
53*ac7df209SYuntao Xuin the selected camera's next configure operation. Until the target pane is included in a camera's
54*ac7df209SYuntao Xuconfiguration, it cannot be used as a target for capture requests to that camera.
55*ac7df209SYuntao Xu
56*ac7df209SYuntao Xu2.2.1. TextureView and SurfaceView targets
57*ac7df209SYuntao Xu
58*ac7df209SYuntao XuThese are basic outputs generally used for camera preview; each is simply configured by the size
59*ac7df209SYuntao Xuof buffers it requests from the camera.
60*ac7df209SYuntao Xu
61*ac7df209SYuntao Xu2.2.2. ImageReader target
62*ac7df209SYuntao Xu
63*ac7df209SYuntao XuThis is the basic still capture output, used for JPEG or uncompressed data that needs to be
64*ac7df209SYuntao Xuapplication-accessible. It is simply configured with the desired output format, and the size.
65*ac7df209SYuntao Xu
66*ac7df209SYuntao Xu2.2.3. MediaCodec and MediaRecorder targes
67*ac7df209SYuntao Xu
68*ac7df209SYuntao XuThese are video recording targets, which use the Android device's video encoding APIs to create
69*ac7df209SYuntao Xuvideo files.
70*ac7df209SYuntao Xu
71*ac7df209SYuntao Xu2.2.4. RenderScript target
72*ac7df209SYuntao Xu
73*ac7df209SYuntao XuThis target sends camera data to a RenderScript Allocation, from which it can be efficiently
74*ac7df209SYuntao Xuprocessed by Android's RenderScript APIs.
75*ac7df209SYuntao Xu
76*ac7df209SYuntao Xu2.3. Request panes
77*ac7df209SYuntao Xu
78*ac7df209SYuntao XuRequest panes are used to set up the configuration for a single camera capture request. It includes
79*ac7df209SYuntao Xuall the settings required for the camera device to capture a frame of data. It contains selectors
80*ac7df209SYuntao Xufor the camera to send the request to, and then which of the configured target panes to use for
81*ac7df209SYuntao Xuimage output.  A given request can send data to any subset of the configured targets, but it
82*ac7df209SYuntao Xumust include at least one target.
83*ac7df209SYuntao Xu
84*ac7df209SYuntao XuThe camera device provides default values for all the request settings for various use cases; the
85*ac7df209SYuntao Xustarting template can be selected from the dropdown.
86*ac7df209SYuntao Xu
87*ac7df209SYuntao XuOnce a camera has been opened and configured, and the correct target(s) has been selected for the
88*ac7df209SYuntao Xurequest, the request can be sent to the camera with either the capture or repeat buttons.
89*ac7df209SYuntao Xu
90*ac7df209SYuntao XuCapture is a one-shot operation, which simply instructs the camera to capture a single frame of
91*ac7df209SYuntao Xudata. This is commonly used for high-resolution snapshots, for triggering autofocus, or other
92*ac7df209SYuntao Xusingle-occurance events. Captures are queued and processed in FIFO order.
93*ac7df209SYuntao Xu
94*ac7df209SYuntao XuRepeat is a continuous operation, where the camera device continually captures the images using
95*ac7df209SYuntao Xuthe same request settings.  These have lower priority than captures, so if some request is actively
96*ac7df209SYuntao Xurepeating, other requests can still use the 'capture' action to trigger single captures. Another
97*ac7df209SYuntao Xurequest triggering repeat will pre-empt any previous repeat actions by other requests.
98*ac7df209SYuntao Xu
99*ac7df209SYuntao XuTo stop repeating, use the camera pane's stop method.
100*ac7df209SYuntao Xu
101*ac7df209SYuntao Xu2.4. Burst panes
102*ac7df209SYuntao Xu
103*ac7df209SYuntao XuBurst panes simply aggregate together a set of requests into a single high-speed burst. Bursts
104*ac7df209SYuntao Xuare captured atomically with no intervening other requests.  Similarly to single requests, they
105*ac7df209SYuntao Xucan be one-shot or continuous.
106*ac7df209SYuntao Xu
107*ac7df209SYuntao XuThe burst pane contains the target camera to send the burst to, and then allows including one or
108*ac7df209SYuntao Xumore requests into the burst, from the list of requests that target the chosen camera.
109*ac7df209SYuntao Xu
110*ac7df209SYuntao Xu2.5. Utility panes
111*ac7df209SYuntao Xu
112*ac7df209SYuntao XuUtility panes are catchall panes, which can implement various kinds of ease-of-use functionality,
113*ac7df209SYuntao Xusuch as implementing simple autofocus operation, still capture sequencing, or other high-level
114*ac7df209SYuntao Xufunctions.
115*ac7df209SYuntao Xu
116*ac7df209SYuntao Xu2.6. Configuration load/save
117*ac7df209SYuntao Xu
118*ac7df209SYuntao XuTestingCamera2 supports loading a predefined set of panes from an XML definition. The definitions
119*ac7df209SYuntao Xucan either be one of the default included sets, or located on the device SD card.
120*ac7df209SYuntao Xu
121*ac7df209SYuntao Xu3. Internal architecture
122*ac7df209SYuntao Xu
123*ac7df209SYuntao XuEach pane is a specialized view, with a few generic methods for setting them up and notifying them
124*ac7df209SYuntao Xuof changes in other panes.  Panes are tracked by a global pane tracker, which allows individual
125*ac7df209SYuntao Xupanes to notify others of status changes (such as a change in the selected camera, so that all
126*ac7df209SYuntao Xupanes targeting that camera pane can update their displayed settings choices), to find panes of
127*ac7df209SYuntao Xugiven types, and so on.
128*ac7df209SYuntao Xu
129*ac7df209SYuntao XuThe operation of the camera devices is centralized in a single camera ops class, which keeps track
130*ac7df209SYuntao Xuof open devices, notifies panes about changes to camera device status, and allows the utility panes
131*ac7df209SYuntao Xuto intercept/override camera device operations as desired.
132*ac7df209SYuntao Xu
133