gpt4 book ai didi

Android 相机媒体服务器在拍照后死机 - 在模拟器中工作

转载 作者:行者123 更新时间:2023-11-29 14:09:30 25 4
gpt4 key购买 nike

我在我的 Archos 32 Android 设备上收到此错误。我找到了这篇文章:Droid's mediaserver dies on camera.takePicture()

但是除了预览之外还有哪些“缺失的部分”并不是很具体。

我的代码在模拟器和至少一个其他机器人设备上运行。只是与 archos 不兼容,还是我仍然遗漏了什么?

archos 有一个可用的相机程序,所以我知道有一个可以拍照的应用程序是可能的,但我开始认为它与 sdk 不兼容。我在哪里可以下载一个完整的工作相机 eclipse 项目?我能找到的只是代码 fragment 。

这是调试日志:

12-10 10:37:46.827: DEBUG/CameraHalUtils(16242): PPM: STOPPED PREVIEW :5691.681 ms
12-10 10:37:46.835: INFO/cat(1096): <6>video4linux video0: w 640, h 480, fmt 56595559 -> w 640, h 480
12-10 10:37:47.110: DEBUG/CameraHalUtils(16242): PPM: AFTER CAPTURE YUV IMAGE :5975.250 ms
12-10 10:37:47.131: INFO/DEBUG(16218): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-10 10:37:47.131: INFO/DEBUG(16218): Build fingerprint: 'archos/g8/G8A/:2.2.1/FROYO/eng..20101126.043425:user/test-keys'
12-10 10:37:47.131: INFO/DEBUG(16218): pid: 16242, tid: 16250 >>> /system/bin/mediaserver <<<
12-10 10:37:47.131: INFO/DEBUG(16218): signal 11 (SIGSEGV), fault addr 00000000
12-10 10:37:47.131: INFO/DEBUG(16218): r0 00000000 r1 aba8ee30 r2 fefefeff r3 00000000
12-10 10:37:47.131: INFO/DEBUG(16218): r4 a7940a6c r5 000119c0 r6 00010b04 r7 40506eb4
12-10 10:37:47.131: INFO/DEBUG(16218): r8 00100000 r9 a811c319 10 40407000 fp 00012400
12-10 10:37:47.131: INFO/DEBUG(16218): ip 00000000 sp 40506ab8 lr a790f30f pc a790f310 cpsr 20000030
12-10 10:37:47.139: INFO/DEBUG(16218): d0 643a64696f72646e d1 20656c6261696c52
12-10 10:37:47.139: INFO/DEBUG(16218): d2 0049002e00650020 d3 0065006d00610043
12-10 10:37:47.139: INFO/DEBUG(16218): d4 7e7f7c7e7f7e7c81 d5 7b7e80827f807d7f
12-10 10:37:47.139: INFO/DEBUG(16218): d6 2728282a29292928 d7 3f80000028282828
12-10 10:37:47.139: INFO/DEBUG(16218): d8 000000003f800000 d9 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d10 0000000000000000 d11 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d12 0000000000000000 d13 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d14 0000000000000000 d15 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d16 3ff0000000000000 d17 3ff0000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d18 7e37e43c8800759c d19 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d20 0000000000000000 d21 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d22 0000000000000000 d23 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d24 0000000000000000 d25 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d26 0000000000000000 d27 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d28 0000000000000000 d29 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218): d30 0000000000000000 d31 0000000000000000
12-10 10:37:47.139: DEBUG/AudioHardwareAM(16242): acquire wakelock
12-10 10:37:47.139: INFO/DEBUG(16218): scr 20000010
12-10 10:37:47.163: INFO/cat(1096): <7>Configure McBSP for 1 phase
12-10 10:37:47.163: INFO/cat(1096): <7>Configure McBSP TX FIFO threshold to 1260
12-10 10:37:47.194: INFO/DEBUG(16218): #00 pc 0000f310 /system/lib/libcamera.so
12-10 10:37:47.202: INFO/DEBUG(16218): #01 pc 0000d2cc /system/lib/libcamera.so
12-10 10:37:47.202: INFO/DEBUG(16218): #02 pc 00009790 /system/lib/libcamera.so
12-10 10:37:47.202: INFO/DEBUG(16218): #03 pc 0001beea /system/lib/libutils.so
12-10 10:37:47.209: INFO/DEBUG(16218): #04 pc 0001c380 /system/lib/libutils.so
12-10 10:37:47.209: INFO/DEBUG(16218): #05 pc 00011188 /system/lib/libc.so
12-10 10:37:47.209: INFO/DEBUG(16218): #06 pc 00010c68 /system/lib/libc.so
12-10 10:37:47.209: INFO/DEBUG(16218): code around pc:
12-10 10:37:47.217: INFO/DEBUG(16218): a790f2f0 2b004603 2300bf14 b2db2301 d0462b00
12-10 10:37:47.217: INFO/DEBUG(16218): a790f300 681bab13 7368f503 f0044618 4603ff0b
12-10 10:37:47.217: INFO/DEBUG(16218): a790f310 f102681a 6812020c 47904618 46194603
12-10 10:37:47.217: INFO/DEBUG(16218): a790f320 681aab56 6b9bab25 46114608 f7f9461a
12-10 10:37:47.217: INFO/DEBUG(16218): a790f330 ab13ed9c f503681b 46187368 fef2f004
12-10 10:37:47.217: INFO/DEBUG(16218): code around lr:
12-10 10:37:47.217: INFO/DEBUG(16218): a790f2ec efeaf7f9 2b004603 2300bf14 b2db2301
12-10 10:37:47.217: INFO/DEBUG(16218): a790f2fc d0462b00 681bab13 7368f503 f0044618
12-10 10:37:47.217: INFO/DEBUG(16218): a790f30c 4603ff0b f102681a 6812020c 47904618
12-10 10:37:47.217: INFO/DEBUG(16218): a790f31c 46194603 681aab56 6b9bab25 46114608
12-10 10:37:47.217: INFO/DEBUG(16218): a790f32c f7f9461a ab13ed9c f503681b 46187368

这是 CameraHal 报告的内容:

12-10 10:37:41.100: DEBUG/CameraHal(16242): opening ti camera hal
12-10 10:37:41.100: DEBUG/CameraHal(16242): 5269: createInstance() ENTER
12-10 10:37:41.131: INFO/CameraHal(16242): initDefaultParameters: Camera type is OV7675
12-10 10:37:41.131: DEBUG/CameraHal(16242): 1364: CameraCreate() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): 1377: CameraCreate() EXIT
12-10 10:37:41.460: DEBUG/CameraHal(16242): 378: initDefaultParameters() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): 3749: setParameters() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): PreviewFormat yuv420sp
12-10 10:37:41.460: DEBUG/CameraHal(16242): PictureFormat jpeg
12-10 10:37:41.460: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): Validating 640, 176 and 480, 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): Validating 176, 176 and 144, 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.460: DEBUG/CameraHal(16242): PreviewResolution by App 176 x 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): Validating 640, 640 and 480, 480
12-10 10:37:41.460: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.460: DEBUG/CameraHal(16242): Picture Size by App 640 x 480
12-10 10:37:41.460: DEBUG/CameraHal(16242): FRAMERATE 30
12-10 10:37:41.460: DEBUG/CameraHal(16242): Picture Size by CamHal 640 x 480
12-10 10:37:41.460: DEBUG/CameraHal(16242): Preview Resolution by CamHal 176 x 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): Zoom by App 0
12-10 10:37:41.530: DEBUG/CameraHal(16242): 4432: setParameters() EXIT
12-10 10:37:41.530: DEBUG/CameraHal(16242): 679: initDefaultParameters() EXIT
12-10 10:37:41.530: DEBUG/CameraHal(16242): 3339: ICaptureCreate() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 3382: ICaptureCreate() EXIT
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING PROC THREAD
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING Shutter THREAD
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING Raw THREAD
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING Snapshot THREAD
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2976: procThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2913: shutterThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2848: rawThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2727: snapshotThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 843: previewThread() ENTER
12-10 10:37:41.553: DEBUG/CameraHal(16242): 4724: getParameters() ENTER
12-10 10:37:41.553: DEBUG/CameraHal(16242): 4979: getParameters() EXIT
12-10 10:37:41.561: DEBUG/CameraHal(16242): 3749: setParameters() ENTER
12-10 10:37:41.561: DEBUG/CameraHal(16242): PreviewFormat yuv420sp
12-10 10:37:41.561: DEBUG/CameraHal(16242): PictureFormat jpeg
12-10 10:37:41.561: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.561: DEBUG/CameraHal(16242): Validating 640, 176 and 480, 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): Validating 176, 176 and 144, 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.561: DEBUG/CameraHal(16242): PreviewResolution by App 176 x 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.561: DEBUG/CameraHal(16242): Validating 640, 640 and 480, 480
12-10 10:37:41.561: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.561: DEBUG/CameraHal(16242): Picture Size by App 640 x 480
12-10 10:37:41.561: DEBUG/CameraHal(16242): FRAMERATE 30
12-10 10:37:41.561: DEBUG/CameraHal(16242): Picture Size by CamHal 640 x 480
12-10 10:37:41.561: DEBUG/CameraHal(16242): Preview Resolution by CamHal 176 x 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): Zoom by App 0
12-10 10:37:41.631: DEBUG/CameraHal(16242): 4432: setParameters() EXIT
12-10 10:37:41.631: DEBUG/CameraHal(16242): 4724: getParameters() ENTER
12-10 10:37:41.631: DEBUG/CameraHal(16242): 4979: getParameters() EXIT
12-10 10:37:41.631: DEBUG/CameraHal(16242): CameraHal setOverlay/1/00000000/00000000
12-10 10:37:41.631: ERROR/CameraHal(16242): Trying to set overlay, but overlay is null!, line:3472
12-10 10:37:41.663: DEBUG/CameraHal(16242): CameraHal setOverlay/1/00020340/00000000
12-10 10:37:41.663: DEBUG/CameraHal(16242): 3495: setOverlay() EXIT
12-10 10:37:41.663: DEBUG/CameraHal(16242): 3502: startPreview() ENTER
12-10 10:37:41.663: DEBUG/CameraHal(16242): Receive Command: PREVIEW_START
12-10 10:37:41.663: DEBUG/CameraHal(16242): 1364: CameraCreate() ENTER
12-10 10:37:41.663: DEBUG/CameraHal(16242): 1377: CameraCreate() EXIT
12-10 10:37:41.663: DEBUG/CameraHal(16242): 1425: CameraConfigure() ENTER
12-10 10:37:41.717: INFO/CameraHal(16242): CameraConfigure PreviewFormat: w=176 h=144
12-10 10:37:41.717: DEBUG/CameraHal(16242): CameraConfigure: framerate to set = 30
12-10 10:37:41.717: DEBUG/CameraHal(16242): CameraConfigure: Old frame rate is 30/1 fps
12-10 10:37:41.772: INFO/CameraHal(16242): CameraConfigure: New frame rate is 30/1 fps
12-10 10:37:41.772: DEBUG/CameraHal(16242): 1470: CameraConfigure() EXIT
12-10 10:37:41.772: DEBUG/CameraHal(16242): 1487: CameraStart() ENTER
12-10 10:37:41.772: DEBUG/CameraHal(16242): **CaptureQBuffers: preview size=176x144
12-10 10:37:41.772: DEBUG/CameraHal(16242): mPreviewFrameSize = 0xd000 = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): number of buffers = 6
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [0].start = 0x40d89000 length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [1].start = 0x40d96000 length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [2].start = 0x40da3000 length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [3].start = 0x40db0000 length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [4].start = 0x40dbd000 length = 53248
12-10 10:37:41.780: DEBUG/CameraHal(16242): User Buffer [5].start = 0x40dca000 length = 53248
12-10 10:37:41.874: ERROR/CameraHal(16242): Initial Crop: crop_top = 0, crop_left = 0, crop_width = 639, crop_height = 478
12-10 10:37:41.874: DEBUG/CameraHal(16242): 1594: CameraStart() EXIT
12-10 10:37:41.874: DEBUG/CameraHal(16242): PREVIEW_START ACK
12-10 10:37:41.874: DEBUG/CameraHal(16242): Preview Started!
12-10 10:37:41.874: DEBUG/CameraHal(16242): 3519: startPreview() EXIT
12-10 10:37:45.663: DEBUG/CameraHal(16242): 3686: takePicture() ENTER
12-10 10:37:45.663: DEBUG/CameraHal(16242): ENTER OPTION PREVIEW_CAPTURE
12-10 10:37:45.694: DEBUG/CameraHal(16242): 1610: CameraStop() ENTER
12-10 10:37:45.694: DEBUG/CameraHal(16242): Done dequeuing from Camera!
12-10 10:37:46.827: DEBUG/CameraHal(16242): 1644: CameraStop() EXIT
12-10 10:37:46.827: DEBUG/CameraHal(16242): 2297: ICapturePerform() ENTER
12-10 10:37:46.827: DEBUG/CameraHal(16242): PICTURE NUMBER =1
12-10 10:37:46.827: DEBUG/CameraHal(16242): Picture Size: Width = 640 Height = 480
12-10 10:37:46.881: DEBUG/CameraHal(16242): pictureFrameSize = 0x96000 = 614400
12-10 10:37:46.881: DEBUG/CameraHal(16242): Picture Buffer: Base = 0x40e25000 Offset = 0x0
12-10 10:37:46.913: DEBUG/CameraHal(16242): De-queue the next avaliable buffer

我的代码:包 com.example;

导入android.app.Activity;导入 android.hardware.Camera;导入 android.hardware.Camera.PictureCallback;导入 android.hardware.Camera.ShutterCallback;导入 android.os.Bundle;导入 android.util.Log;导入 android.view.View;导入 android.view.View.OnClickListener;导入 android.widget.Button;导入 android.widget.FrameLayout;

公共(public)类 CameraDemo 扩展 Activity { private static final String TAG = "CameraDemo"; 相机相机; 预览预览; 按钮buttonClick;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

preview = new Preview(this);
((FrameLayout) findViewById(R.id.preview)).addView(preview);

buttonClick = (Button) findViewById(R.id.buttonClick);
buttonClick.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
preview.camera.takePicture(shutterCallback, rawCallback, jpegCallback);
}
});

Log.d(TAG, "onCreate'd");
}


ShutterCallback shutterCallback = new ShutterCallback() {
public void onShutter() {
Log.d(TAG, "onShutter'd");
}
};

/** Handles data for raw picture */
PictureCallback rawCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
Log.d(TAG, "onPictureTaken - raw");
}
};

/** Handles data for jpeg picture */
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
Log.d(TAG, "onPictureTaken - jpeg");
}
};

包 com.example;

导入java.io.IOException;导入 android.content.Context;导入 android.hardware.Camera;导入 android.view.SurfaceHolder;导入 android.view.SurfaceView;

类预览扩展 SurfaceView 实现 SurfaceHolder.Callback {

SurfaceHolder mHolder;
public Camera camera;

Preview(Context context) {
super(context);

// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, acquire the camera and tell it where
// to draw.
camera = Camera.open();
try {
camera.setPreviewDisplay(holder);


} catch (IOException e) {
e.printStackTrace();
}
}

public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return, so stop the preview.
// Because the CameraDevice object is not a shared resource, it's very
// important to release it when the activity is paused.
camera.stopPreview();
camera = null;
}

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
Camera.Parameters parameters = camera.getParameters();
// parameters.setPreviewSize(w, h); // seems to crash if this code is enabled
camera.setParameters(parameters);
camera.startPreview();
}

布局

<FrameLayout android:id="@+id/preview"
android:layout_weight="1" android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>

<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/buttonClick"
android:text="Click" android:layout_gravity="center"></Button>

最佳答案

我也有一台 Archos32 出现与您遇到的问题相同的问题。您找到问题的答案了吗?我检查了您的代码,我的 Archos32 的媒体服务器在尝试拍照时也死机了。

不过,我已经更新了您的代码,并且已经达到媒体服务器在拍照时不会死机的程度。我基本上按以下方式更新了 Preview.java:

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
Camera.Parameters parameters = camera.getParameters();

List<Size> previewSizes = parameters.getSupportedPreviewSizes();
Size optimalPreviewSize = previewSizes.get(0);

// parameters.setPreviewSize(w, h); // seems to crash if this code is enabled
parameters.setPreviewFormat(ImageFormat.JPEG);
parameters.setPreviewSize(optimalPreviewSize.width, optimalPreviewSize.height);

camera.setParameters(parameters);
camera.startPreview();
}

这非常糟糕和肮脏,因为我没有做任何特别的事情来确定用于相机预览的预览大小 - 我只是捕获第一个找到的 - 但我所做的更改的结果是媒体服务器不再崩溃 onShutter(),现在也调用 rawCallback() 和 jpegCallback()。

如果你愿意,你可以从 Google's CameraPreview API Demo 获取 getOptimalPreview 方法获取拍照时使用的“最佳”预览尺寸。

如果这对您有用,请告诉我 - 我已经与我的 Archos 战斗了几个小时,试图在不崩溃的情况下实现摄像头,并且终于开始取得一些进展。

关于Android 相机媒体服务器在拍照后死机 - 在模拟器中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4410619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com