android直接调用摄像头
16lz
2021-01-23
android可以通过Intent来调用摄像头,那样调用的系统提供的摄像头程序,如果想直接调用摄像头的硬件,也可以直接访问摄像头.
具体可以参考 http://developer.android.com/guide/topics/media/camera.html里"Building a Camera App"这一节
关键的两个步骤是
创建SurfaceView用来绘制摄像头的预览
创建layout确定SurfaceView的位置,比如在这里可以在摄像头预览上加上自己定制的组件
要注意的几点是
camera要及时的在onPause方法中release掉
activity要加上 android:screenOrientation="landscape"否则预览和实际图像往往有90度角的偏转
引用 On most devices, the default orientation of the camera preview is landscape. This example layout specifies a horizontal (landscape) layout and the code below fixes the orientation of the application to landscape. For simplicity in rendering a camera preview, you should change your application's preview activity orientation to landscape by adding the following to your manifest.
比如加上瞄准镜的效果
具体可以参考 http://developer.android.com/guide/topics/media/camera.html里"Building a Camera App"这一节
关键的两个步骤是
创建SurfaceView用来绘制摄像头的预览
创建layout确定SurfaceView的位置,比如在这里可以在摄像头预览上加上自己定制的组件
要注意的几点是
camera要及时的在onPause方法中release掉
activity要加上 android:screenOrientation="landscape"否则预览和实际图像往往有90度角的偏转
引用 On most devices, the default orientation of the camera preview is landscape. This example layout specifies a horizontal (landscape) layout and the code below fixes the orientation of the application to landscape. For simplicity in rendering a camera preview, you should change your application's preview activity orientation to landscape by adding the following to your manifest.
比如加上瞄准镜的效果
更多相关文章
- Android官方架构组件:Lifecycle详解&原理分析
- Android 之 下拉(Spinner) 组件示例
- Android之四大组件解析
- android 3D摄像头的扩展现实
- Intent组件构成,解析机制
- 深入剖析Android四大组件(三)——AIDL实现Android IPC
- android——桌面组件的开发
- Android 桌面组件【widget】初探