更一般地说,如果一台设备有多个嵌入式摄像头,
有没有一种方法可以特别初始化其中一个?
我在Android参考文档中没有找到它:
- https://developer.android.com/reference/android/hardware/Camera.html https://developer.android.com/reference/android/hardware/Camera.html
- https://developer.android.com/reference/android/hardware/camera2/package-summary.html https://developer.android.com/reference/android/hardware/camera2/package-summary.html
- https://developer.android.com/reference/android/hardware/camera2/CameraManager.html https://developer.android.com/reference/android/hardware/camera2/CameraManager.html
三星 SHW-M100S 有两个摄像头。如果没有提到使用两个摄像头,知道三星是怎么做的......?
private Camera openFrontFacingCameraGingerbread() {
int cameraCount = 0;
Camera cam = null;
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
try {
cam = Camera.open(camIdx);
} catch (RuntimeException e) {
Log.e(TAG, "Camera failed to open: " + e.getLocalizedMessage());
}
}
}
return cam;
}
添加以下权限AndroidManifest.xml
file:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
Note:此功能在 Gingerbread(2.3) 及以上 Android 版本中可用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)