运行时错误,但逐步调试工作正常

发布于 2024-12-01 21:15:36 字数 1685 浏览 0 评论 0原文

我写了一个android程序来拍照而不预览。当我一步步调试时,我的程序运行得很好。但是,当我在执行模式下运行它时,程序无法按预期工作。没有保存图片,程序无法完成。此外,除非重新启动手机,否则我无法在其他 Android 应用程序(例如相机、摄像机)中使用我的相机。有人对这个问题有什么想法吗?拍照的代码和记录的错误如下:

拍照的代码:

    SurfaceView view = new SurfaceView(this);
    mCamera = Camera.open();
    Camera.Parameters p = mCamera.getParameters();
    p.setPictureFormat(PixelFormat.JPEG);
    mCamera.setParameters(p);

    try {
        mCamera.setPreviewDisplay(view.getHolder());
        mCamera.startPreview();
        mCamera.takePicture(null, null, mPictureCallback);
        mCamera.stopPreview();
        mCamera.unlock();
        mCamera.release();
    } catch (Exception e) {
        mCamera.stopPreview();
        mCamera.release();
        e.printStackTrace();            
    }

回调函数

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
          public void onPictureTaken(byte[] imageData, Camera c) {
               if (imageData != null) {
            StoreByteImage(mContext, imageData, 50,
                    "ImageName");
            finish();
        }
    }
};
}

logcat 报告的错误:

ERROR/Adreno200-ES20(130): rb verson is SBA #24
ERROR/mm-camera(130): prepare snapshot: Aec not settle
ERROR/CameraService(130): mHardware->setOverlay() failed with status -2147483648
ERROR/mm-camera(130): camera_issue_command: get_picture error (Connection timed out): length 36, status 0 FD: 20 1
ERROR/QualcommCameraHardware3D(130): getPicture: CAMERA_OPS_GET_PICTURE ioctl failed!
ERROR/NotificationService(292): adbEnabled = false
ERROR/NotificationService(292): adbEnabled = true

大家能给点建议吗?先感谢您

I wrote an android program to take a picture without preview. My programs works fine when I debug it step by step. However, when I run it in execution mode, the program doesn't work as expected. No picture is saved and the program can not finish. In addition, I can not use my camera in other android applications(e.g. Camera, Camcorder) unless I restart my phone. Anybody have any ideas about this problem? The code for taking pictures and the logged errors is as follows:

Code for taking pictures:

    SurfaceView view = new SurfaceView(this);
    mCamera = Camera.open();
    Camera.Parameters p = mCamera.getParameters();
    p.setPictureFormat(PixelFormat.JPEG);
    mCamera.setParameters(p);

    try {
        mCamera.setPreviewDisplay(view.getHolder());
        mCamera.startPreview();
        mCamera.takePicture(null, null, mPictureCallback);
        mCamera.stopPreview();
        mCamera.unlock();
        mCamera.release();
    } catch (Exception e) {
        mCamera.stopPreview();
        mCamera.release();
        e.printStackTrace();            
    }

The callback function

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
          public void onPictureTaken(byte[] imageData, Camera c) {
               if (imageData != null) {
            StoreByteImage(mContext, imageData, 50,
                    "ImageName");
            finish();
        }
    }
};
}

The reported errors by logcat:

ERROR/Adreno200-ES20(130): rb verson is SBA #24
ERROR/mm-camera(130): prepare snapshot: Aec not settle
ERROR/CameraService(130): mHardware->setOverlay() failed with status -2147483648
ERROR/mm-camera(130): camera_issue_command: get_picture error (Connection timed out): length 36, status 0 FD: 20 1
ERROR/QualcommCameraHardware3D(130): getPicture: CAMERA_OPS_GET_PICTURE ioctl failed!
ERROR/NotificationService(292): adbEnabled = false
ERROR/NotificationService(292): adbEnabled = true

Can anybody give any suggestion? Thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

上课铃就是安魂曲 2024-12-08 21:15:36

这对你有用吗?

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File file = new File(Environment.getExternalStorageDirectory(),
                    currentTimeString + ".jpg");
            outputFileUri = Uri.fromFile(file);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, TAKE_PICTURE);

does this work for you?

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File file = new File(Environment.getExternalStorageDirectory(),
                    currentTimeString + ".jpg");
            outputFileUri = Uri.fromFile(file);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, TAKE_PICTURE);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文