Android手机如何自动拍照?
我开发了一个android应用程序。我使用了前置摄像头功能。它工作正常,但我需要自动捕获。即没有点击快门按钮声音,我想捕获照片代码..
我的相机活动代码是
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.i("Camera failed to open: ",e.getLocalizedMessage());
}
}
}
return cam;
}
提前致谢..
I have developed an android application. In that i have used front facing camera functionality. Its working fine but I need to auto capture. i.e. without click shutter button sound, I want to capture photocode..
my camera activity code is
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.i("Camera failed to open: ",e.getLocalizedMessage());
}
}
}
return cam;
}
Thanks in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请按照 Android 开发人员参考页面中概述的步骤进行操作。不需要有“快门按钮”。如果您不想在屏幕上显示图像,可以创建一个虚拟 SurfaceHolder,例如
Follow the steps outlined in the Android Developer reference pages. There's no requirement to have a 'shutter button'. You can create a dummy SurfaceHolder if you don't want to show the image on the screen, e.g.
在创建时写入此代码以自动捕获图像
write this code in on create to auto capture image