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