1
我正在开发一个演示程序,如果设备有前置摄像头,我必须检查设备是否有前置摄像头,然后我必须打开它才能拍摄图像。前脸相机机器人。
我搜索了很多,但没有找到任何解决方案。请通过提供解决方案来帮助我。
在此先感谢。
我正在开发一个演示程序,如果设备有前置摄像头,我必须检查设备是否有前置摄像头,然后我必须打开它才能拍摄图像。前脸相机机器人。
我搜索了很多,但没有找到任何解决方案。请通过提供解决方案来帮助我。
在此先感谢。
我使用的前脸摄像头解决方案:
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("Your_TAG", "Camera failed to open: " + e.getLocalizedMessage());
}
}
}
return cam;
}
使用摄像头完整的教程 - >HERE
我的结果图片:
感谢您的答案,但我试过这个代码,它不适合我。 – rahul
你必须有另一个问题。引导你到这个教程:http://www.vogella.com/articles/AndroidCamera/article.html –
感谢您的建议,让我试试这个链接。 – rahul