问题描述
我已经成功地捕捉到了一张照片在Android中使用的摄像头。但是,当我试图捕捉5张照片一次,应用程序停止响应,摄像头preVIEW变成绿色,并没有保存照片。我在堆栈跟踪看到的是如下(部分)
I have successfully captured the single photo using camera in Android. But when I tried to capture 5 photos at once, app stops responding, camera preview turns to green and no picture is saved. What I saw in stack trace is as follows (partial)
03-17 14:19:54.804: 信息/ QualcommCameraHardware(19268): DEINIT preVIEWē03-17 14:19:54.804: 信息/ QualcommCameraHardware(19268): DEINIT preVIEW X 03-17 14:19:54.804: DEBUG / QualcommCameraHardware(19268): frame_thread X 03-17 14:19:54.834: DEBUG / QualcommCameraHardware(19268): snapshot_threadË03-17 14:19:54.854: DEBUG / CameraService(19268): takePicture(PID 20509)03-17 14:19:54.884: WARN / AudioFlinger(19268):写 阻塞85毫秒03-17 14:19:55.154: DEBUG / CameraService(19268): postShutter 03-17 14:19:55.284: DEBUG / CameraService(19268):postRaw 03-17 14:19:55.314: DEBUG / QualcommCameraHardware(19268): snapshot_thread X 03-17 14:19:55.344: DEBUG / QualcommCameraHardware(19268): snapshot_threadË03-17 14:19:55.364: DEBUG / CameraService(19268): takePicture(PID 20509)03-17 14:19:55.984: DEBUG / CameraService(19268): postShutter 03-17 14:19:56.064: DEBUG / CameraService(19268):postRaw 03-17 14:19:56.074: ERROR / QualcommCameraHardware(19268): native_jpeg_en code: jpeg_en coder_en code失败。 03-17 14:19:56.074: ERROR / QualcommCameraHardware(19268): JPEG编码失败03-17 14:19:56.084: DEBUG / QualcommCameraHardware(19268): snapshot_thread X 03-17 14:19:56.154: 信息/ DEBUG(19267): *的 * 的* *的 * 的* *的 * 的* *的 * 的* *的 * 的*的 * 的03-17 14:19:56.164:信息/ DEBUG(19267):建立指纹: google_ion / google_ion /蓝/蓝宝石:1.6 / DRC83 / 14721:用户/ ADP,测试键 03-17 14:19:56.164:信息/ DEBUG(19267): PID:19268,TID:20813 >>> /系统/斌/媒体服务器 ... ... ... 14:19:59.894:信息/的ServiceManager(46): 服务media.camera死亡03-17 14:19:59.894:WARN /摄像机(20509): 相机服务器死了! 03-17 14:19:59.894:WARN /摄像机(20509): ICamera死亡03-17 14:19:59.894: ERROR /摄像机(20509):错误100 03-17 14:19:59.915:WARN / AudioSystem(71): AudioFlinger服务器死了! 03-17 14:20:00.014:信息/工艺(71): 发送信号。 PID:18636 SIG:3 03-17 14:20:00.054: 信息/ dalvikvm(18636):主题ID = 7: 反应信号3
我呼吁在一个循环中 takePicture
方法来捕获多张照片;
I am calling the takePicture
method in a loop to capture multiple photos;
for(int m = 0 ; m < 6; m++) {
mPrimCamera.takePicture(null, mPictureCallbackMet, mPictureCallbackMet);
}
我这样做是对的HTC Magic运行Android 1.6。我想,我是用了错误的方式,采取多张照片。 什么是使用Android摄像头的API来获取多张照片的正确方法?
推荐答案
我没有找到任何这API的支持。并多次调用 takePicture从环
方法是行不通的。所以,我得到一个解决方法。在code仍然在循环,但我现在用的螺纹;
I didn't find any API support for this. And repeatedly calling the takePicture
method from the loop is not working. So, I get a workaround. The code is still in loop but I'm now using Thread;
private class CaptureThread extends Thread {
@Override
public void run() {
int count = 0;
while(count < mNo) {
mFileName = mLocation + "/pic" + count + ".jpg";
mCamera.takePicture(null, mPictureCallback, mPictureCallback);
count++;
try {
Thread.sleep(3000);
} catch (InterruptedException exception) {
exception.printStackTrace();
}
}
}
}
这篇关于捕获多张照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!