• Home
Name Date Size #Lines LOC

..--

.google/03-May-2024-2418

Application/03-May-2024-1,782983

gradle/wrapper/03-May-2024-66

kotlinApp/03-May-2024-1,8761,119

screenshots/03-May-2024-

CONTRIB.mdD03-May-20241.6 KiB3627

CONTRIBUTING.mdD03-May-20241.5 KiB3627

LICENSED03-May-202411.1 KiB204170

README.mdD03-May-20243.7 KiB9166

build.gradleD03-May-202410 110

gradlewD03-May-20245 KiB165122

gradlew.batD03-May-20242.3 KiB9166

packaging.yamlD03-May-2024475 1610

settings.gradleD03-May-202422 21

README.md

1
2Android Camera2Basic Sample
3===================================
4
5This sample demonstrates how to use basic functionalities of Camera2
6API. You can learn how to iterate through characteristics of all the
7cameras attached to the device, display a camera preview, and take
8pictures.
9
10Introduction
11------------
12
13The [Camera2 API][1] provides an interface to individual camera
14devices connected to an Android device. It replaces the deprecated
15Camera class.
16
17Use [getCameraIdList][2] to get a list of all the available
18cameras. You can then use [getCameraCharacteristics][3] and find the
19best camera that suits your need (front/rear facing, resolution etc).
20
21Create an instance of [CameraDevice.StateCallback][4] and open a
22camera. It is ready to start camera preview when the camera is opened.
23
24This sample uses TextureView to show the camera preview. Create a
25[CameraCaptureSession][5] and set a repeating [CaptureRequest][6] to it.
26
27Still image capture takes several steps. First, you need to lock the
28focus of the camera by updating the CaptureRequest for the camera
29preview. Then, in a similar way, you need to run a precapture
30sequence. After that, it is ready to capture a picture. Create a new
31CaptureRequest and call [capture][7]. Don't forget to unlock the focus
32when you are done.
33
34[1]: https://developer.android.com/reference/android/hardware/camera2/package-summary.html
35[2]: https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#getCameraIdList()
36[3]: https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#getCameraCharacteristics(java.lang.String)
37[4]: https://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback.html
38[5]: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html
39[6]: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html
40[7]: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)
41
42Pre-requisites
43--------------
44
45- Android SDK 27
46- Android Build Tools v27.0.2
47- Android Support Repository
48
49Screenshots
50-------------
51
52<img src="screenshots/main.png" height="400" alt="Screenshot"/>
53
54Getting Started
55---------------
56
57This sample uses the Gradle build system. To build this project, use the
58"gradlew build" command or use "Import Project" in Android Studio.
59
60Support
61-------
62
63- Google+ Community: https://plus.google.com/communities/105153134372062985968
64- Stack Overflow: http://stackoverflow.com/questions/tagged/android
65
66If you've found an error in this sample, please file an issue:
67https://github.com/googlesamples/android-Camera2Basic
68
69Patches are encouraged, and may be submitted by forking this project and
70submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
71
72License
73-------
74
75Copyright 2017 The Android Open Source Project, Inc.
76
77Licensed to the Apache Software Foundation (ASF) under one or more contributor
78license agreements.  See the NOTICE file distributed with this work for
79additional information regarding copyright ownership.  The ASF licenses this
80file to you under the Apache License, Version 2.0 (the "License"); you may not
81use this file except in compliance with the License.  You may obtain a copy of
82the License at
83
84http://www.apache.org/licenses/LICENSE-2.0
85
86Unless required by applicable law or agreed to in writing, software
87distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
88WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
89License for the specific language governing permissions and limitations under
90the License.
91