Android相机控制拍摄的图像在快门后保持预览的时间

发布于 2024-12-20 07:29:19 字数 491 浏览 0 评论 0原文

我正在 Android(2.3 及更高版本)中使用 camera.takePicture() 拍照。它工作得很好,但我在不同的设备上遇到奇怪的行为。在我的 Nexus One 上,我拍摄的图像在恢复预览之前会冻结几秒钟。在我的 Transformer 上,它几乎立即恢复到预览。

目前,解决方法是在 onShutter() 事件中调用 camera.stopPreview(),但这仍然有点奇怪,因为它没有显示您拍摄的照片,它显示了拍摄照片后一瞬间预览看到的内容。在 Transformer 上,您甚至可以看到它“冻结-移动-冻结”,因为它在拍照后冻结了一瞬间,再次开始移动,然后进入 onShutter,并在我调用 stopPreview()

有谁知道某个地方的设置,或者我可以调用的一些代码,可以告诉相机在重新启动预览之前保留该图像多长时间?或者更好的是,它根本不会自动释放预览,而是等到我调用 startPreview 吗?

I am taking a picture in Android (2.3 and greater) that takes a picture using camera.takePicture(). It works great, but I get weird behavior on different devices. On my Nexus One, the image I captured stays frozen for a few seconds before reverting to the preview. On my Transformer, it reverts to the preview almost immediately.

For now, a workaround would be to call camera.stopPreview() in the onShutter() event, but that's still a bit weird, since it's not showing the photo you took, it's showing what the preview saw a split second after you took the picture. On the Transformer, you can even see it "freeze-move-freeze" as it freezes for a split second after taking the picture, starts moving again, then gets to onShutter and freezes when I call stopPreview().

Does anyone know of a setting somewhere, or some code I could call, that would tell the camera how long to hold onto that image before restarting the preview? Or better yet, have it not automatically release the preview at all, and wait until I call startPreview?

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

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

发布评论

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

评论(1

驱逐舰岛风号 2024-12-27 07:29:19

在我的设备上,我必须手动重新启动预览,它在拍照后不会自行启动。我使用类似的图片回调

camera.takePicture(null, null, takePictureCallback);

,回调是

private Camera.PictureCallback takePictureCallback = new Camera.PictureCallback() {
    @Override
    public void onPictureTaken(byte[] data, Camera cam) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (camera != null) {
                    camera.startPreview();
                }

                canTakePicture = true;
            }
        }, PHOTO_PREVIEW_LENGTH);

        new PhotoProcessor(activity, targetUri).execute(data);
    }
};

PhotoProcessor 保存图像,PHOTO_PREVIEW_LENGTH 是捕获图像显示的长度(以毫秒为单位)。

on my devices I have to restart the preview manually, it doesn't start up itself after taking a picture. I use a picture callback like

camera.takePicture(null, null, takePictureCallback);

and the callback is

private Camera.PictureCallback takePictureCallback = new Camera.PictureCallback() {
    @Override
    public void onPictureTaken(byte[] data, Camera cam) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (camera != null) {
                    camera.startPreview();
                }

                canTakePicture = true;
            }
        }, PHOTO_PREVIEW_LENGTH);

        new PhotoProcessor(activity, targetUri).execute(data);
    }
};

PhotoProcessor saves the image, PHOTO_PREVIEW_LENGTH is the length in ms for how long is the captured image shown.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文