1

我必须在我的应用程序中使用场景 HDR。此选项从 android 版本 4.2 开始可用,因此它应该在 HTC One X 上可用。但是当我启动它时,我的应用程序崩溃了。我尝试了这段代码,它在带有 Android 4.2.1 的宏基上运行。我使用surfaceView 来显示预览。这是我使用的代码:

private void setParameters(){

    Camera.Parameters params = camera.getParameters();
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        params.setSceneMode(Camera.Parameters.SCENE_MODE_HDR );
    camera.setParameters(params);
}
@Override
public void surfaceCreated(SurfaceHolder arg0) {

    camera = Camera.open();  
    try {  
        camera.setPreviewDisplay(holder); 
        setParameters();

    } catch (IOException exception) {  
        camera.release();  
        camera = null;  
    }  
}

这是日志:

10-18 16:11:13.486: E/(24770): file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt: not found!
10-18 16:11:13.486: I/(24770): Attempting to load EGL implementation /system/lib//egl/libEGL_tegra_impl
10-18 16:11:13.491: I/(24770): Loaded EGL implementation /system/lib//egl/libEGL_tegra_impl
10-18 16:11:13.516: I/(24770): Loading GLESv2 implementation /system/lib//egl/libGLESv2_tegra_impl
10-18 16:11:13.801: W/dalvikvm(24770): threadid=1: thread exiting with uncaught exception (group=0x41f7aa08)
10-18 16:11:13.806: E/AndroidRuntime(24770): FATAL EXCEPTION: main
10-18 16:11:13.806: E/AndroidRuntime(24770): java.lang.RuntimeException: setParameters failed
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.hardware.Camera.native_setParameters(Native Method)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.hardware.Camera.setParameters(Camera.java:1588)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at com.hologram.camerarv.CamerarvSurfaceView.setParameters(CamerarvSurfaceView.java:98)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at com.hologram.camerarv.CamerarvSurfaceView.surfaceCreated(CamerarvSurfaceView.java:183)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.SurfaceView.updateWindow(SurfaceView.java:569)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.SurfaceView.access$000(SurfaceView.java:86)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:174)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:680)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2156)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1190)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4860)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:766)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.Choreographer.doCallbacks(Choreographer.java:575)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.Choreographer.doFrame(Choreographer.java:542)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:751)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.os.Handler.handleCallback(Handler.java:725)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.os.Handler.dispatchMessage(Handler.java:92)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at android.app.ActivityThread.main(ActivityThread.java:5751)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at java.lang.reflect.Method.invokeNative(Native Method)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at java.lang.reflect.Method.invoke(Method.java:511)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
10-18 16:11:13.806: E/AndroidRuntime(24770):    at dalvik.system.NativeStart.main(Native Method)

谢谢您的帮助。

4

1 回答 1

0

来自官方文档:

不同的设备可能具有不同的相机功能,例如图片大小或闪光模式。应用程序应在设置参数之前查询相机功能。例如,应用程序应在调用 setColorEffect(String) 之前调用 getSupportedColorEffects()。如果相机不支持颜色效果,getSupportedColorEffects() 将返回 null。

首先尝试检查该设备是否支持 HDR 模式。

于 2013-10-18T14:27:26.657 回答