README.md
1Android HdrViewfinder Sample
2==============================
3
4This demo shows how to use Camera2 API and RenderScript to implement an HDR viewfinder.
5
6Introduction
7------------
8
9This demo implements a real-time high-dynamic-range camera viewfinder, by alternating the sensor's
10exposure time between two exposure values on even and odd frames, and then compositing together the
11latest two frames whenever a new frame is captured.
12
13The demo has three modes: Regular auto-exposure viewfinder, split-screen manual exposure, and the
14fused HDR viewfinder. The latter two use manual exposure controlled by the user, by swiping up/down
15on the right and left halves of the viewfinder. The left half controls the exposure time of even
16frames, and the right half controls the exposure time of odd frames.
17
18In split-screen mode, the even frames are shown on the left and the odd frames on the right, so the
19user can see two different exposures of the scene simultaneously. In fused HDR mode, the even/odd
20frames are merged together into a single image. By selecting different exposure values for the
21even/odd frames, the fused image has a higher dynamic range than the regular viewfinder.
22
23The HDR fusion and the split-screen viewfinder processing is done with RenderScript; as is the
24necessary YUV->RGB conversion. The camera subsystem outputs YUV images naturally, while the GPU and
25display subsystems generally only accept RGB data. Therefore, after the images are
26fused/composited, a standard YUV->RGB color transform is applied before the the data is written to
27the output Allocation. The HDR fusion algorithm is very simple, and tends to result in
28lower-contrast scenes, but has very few artifacts and can run very fast.
29
30Data is passed between the subsystems (camera, RenderScript, and display) using the Android {@link
31android.view.Surface} class, which allows for zero-copy transport of large buffers between processes
32and subsystems.
33
34Pre-requisites
35--------------
36
37- Android SDK v21
38- Android Build Tools v21
39- Android Support Repository
40
41Getting Started
42---------------
43
44This sample uses the Gradle build system. To build this project, use the
45"gradlew build" command or use "Import Project" in Android Studio.
46
47Screenshots
48-----------
49
50![Split mode](screenshots/image1.png)
51
52Support
53-------
54
55- Google+ Community: https://plus.google.com/communities/105153134372062985968
56- Stack Overflow: http://stackoverflow.com/questions/tagged/android
57
58If you've found an error in this sample, please file an issue:
59https://github.com/googlesamples/android-HdrViewfinder
60
61Patches are encouraged, and may be submitted by forking this project and
62submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
63
64License
65-------
66
67Copyright 2014 The Android Open Source Project, Inc.
68
69Licensed to the Apache Software Foundation (ASF) under one or more contributor
70license agreements. See the NOTICE file distributed with this work for
71additional information regarding copyright ownership. The ASF licenses this
72file to you under the Apache License, Version 2.0 (the "License"); you may not
73use this file except in compliance with the License. You may obtain a copy of
74the License at
75
76 http://www.apache.org/licenses/LICENSE-2.0
77
78Unless required by applicable law or agreed to in writing, software
79distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
80WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
81License for the specific language governing permissions and limitations under
82the License.
83