java.lang.RuntimeException: setParameters failed

asked 2013-10-12 07:49:18 -0600

ecoolsoft gravatar image

updated 2013-10-12 10:08:24 -0600

Encounter Exception when running "OpenCV Sample - 15 puzzle" of OpenCV-2.4.6-android-sdk.

Tablet Android 4.0.3 failed. (Phone Android 2.2.1 Success.)

10-12 19:40:02.019: W/System.err(4412): java.lang.RuntimeException: setParameters failed 10-12 19:40:02.019: W/System.err(4412): at android.hardware.Camera.native_setParameters(Native Method) 10-12 19:40:02.019: W/System.err(4412): at android.hardware.Camera.setParameters(Camera.java:1295) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.android.JavaCameraView.initializeCamera(JavaCameraView.java:155) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.android.JavaCameraView.connectCamera(JavaCameraView.java:232) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.android.CameraBridgeViewBase.onEnterStartedState(CameraBridgeViewBase.java:355) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.android.CameraBridgeViewBase.processEnterState(CameraBridgeViewBase.java:318) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.android.CameraBridgeViewBase.checkCurrentState(CameraBridgeViewBase.java:311) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.android.CameraBridgeViewBase.enableView(CameraBridgeViewBase.java:228) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.samples.puzzle15.Puzzle15Activity$1.onManagerConnected(Puzzle15Activity.java:44) 10-12 19:40:02.019: W/System.err(4412): at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:318) 10-12 19:40:02.019: W/System.err(4412): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1068) 10-12 19:40:02.019: W/System.err(4412): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1085) 10-12 19:40:02.019: W/System.err(4412): at android.os.Handler.handleCallback(Handler.java:605) 10-12 19:40:02.019: W/System.err(4412): at android.os.Handler.dispatchMessage(Handler.java:92) 10-12 19:40:02.019: W/System.err(4412): at android.os.Looper.loop(Looper.java:137) 10-12 19:40:02.019: W/System.err(4412): at android.app.ActivityThread.main(ActivityThread.java:4424) 10-12 19:40:02.019: W/System.err(4412): at java.lang.reflect.Method.invokeNative(Native Method) 10-12 19:40:02.019: W/System.err(4412): at java.lang.reflect.Method.invoke(Method.java:511) 10-12 19:40:02.019: W/System.err(4412): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 10-12 19:40:02.019: W/System.err(4412): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 10-12 19:40:02.019: W/System.err(4412): at dalvik.system.NativeStart.main(Native Method)


Got it. My tablet scrren is 800--444, the supported scrren of camera is 640--480, so the code below is not working. CameraBridgeViewBase.calculateCameraFrameSize

    protected Size calculateCameraFrameSize(List<?> supportedSizes, ListItemAccessor accessor, int surfaceWidth, int surfaceHeight) {
    int calcWidth = 0;
    int calcHeight = 0;

    int maxAllowedWidth = (mMaxWidth != MAX_UNSPECIFIED && mMaxWidth < surfaceWidth)? mMaxWidth : surfaceWidth;
    int maxAllowedHeight = (mMaxHeight != MAX_UNSPECIFIED && mMaxHeight < surfaceHeight)? mMaxHeight : surfaceHeight;

    for (Object size : supportedSizes) {
        int width = accessor.getWidth(size);
        int height = accessor.getHeight(size);
        if (width <= maxAllowedWidth && height <= maxAllowedHeight) {
            if (width >= calcWidth && height >= calcHeight) {
                calcWidth = (int) width;
                calcHeight = (int ...
(more)
edit retag flag offensive close merge delete