• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

.google/23-Nov-2023-2418

Application/23-Nov-2023-1,424784

gradle/wrapper/23-Nov-2023-76

screenshots/23-Nov-2023-

CONTRIB.mdD23-Nov-20231.6 KiB3627

README.mdD23-Nov-20233.7 KiB8965

build.gradleD23-Nov-2023369 2320

gradlewD23-Nov-20235 KiB165122

gradlew.batD23-Nov-20232.3 KiB9166

packaging.yamlD23-Nov-2023423 1510

settings.gradleD23-Nov-202322 21

README.md

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