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