简体   繁体   English

Camera2 API - Android

[英]Camera2 API - Android

I am trying to use new camera api provided by android as camera2. 我正在尝试使用android提供的新相机api作为camera2。 But

CameraManager manager = (CameraManager) getActivity().getSystemService(Context.CAMERA_SERVICE);

showing error. 显示错误。 Does any one have worked on this api. 有没有人在这个api上工作过。

Have been searching for results for could not find any thing yet. 一直在搜索结果找不到任何东西。

Binod, Binod,

That will only works if your platform support API level 21 - that is the one come after Android L release. 这只有在您的平台支持API级别21时才有效 - 这是Android L发布之后的版本。

For a detailed explanation of how camera 2 API works, you may want to take a look at this article 有关camera 2 API如何工作的详细说明,您可能需要查看本文

you can view this example may this will help you 你可以查看这个例子,这可能会对你有帮助

Android Camera2Basic Sample Android Camera2Basic示例

This sample demonstrates the basic use of Camera2 API. 此示例演示了Camera2 API的基本用法。 Check the source code to see how you can display camera preview and take pictures. 检查源代码以了解如何显示相机预览和拍照。 Pre-requisites 先决条件

Android SDK v21
Android Build Tools v21.1.1
Android Support Repository

https://github.com/googlesamples/android-Camera2Basic https://github.com/googlesamples/android-Camera2Basic

Please check this Github Repo for Android L (API 21) Camera Preview Library PkmX/lcamera 请查看此Github Repo for Android L(API 21)相机预览库PkmX / lcamera

您需要为API 21和更低版本制作2个类,在较低的使用常见Camera对象中,在API 21+中您可以使用Camera2 API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM