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