如何在不停止相机供纸的情况下使用闪光灯? [英] How to use flash without stopping camera feed?

查看:87
本文介绍了如何在不停止相机供纸的情况下使用闪光灯?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发条形码扫描应用程序,该应用程序将移动视觉api用于大多数流程.我正在尝试实现一个闪光灯按钮,以便用户可以在光线较暗的情况下进行扫描,但是由于某种原因,闪光灯的激活会冻结相机的供稿. Feed处于活动状态时,是否可以通过按钮开始闪烁?要激活闪光灯而不干扰其他线程?谢谢!

I am currently working on a barcode scanning app, which uses the mobile vision api for the majority of processes. I am trying to implement a flash button so that a user may scan in low light, but for some reason the activation of flash freezes the camera feed. Is there some way to start flash with a button while the feed is active? To activate flash without interfering with other threads? Thanks!

推荐答案

我在自定义相机应用程序中使用了此代码.当用户单击FlashOn按钮时,Flash将启动.我认为此代码将为您提供帮助.

i used this code in my custom camera Application.when User clicks the FlashOn Button then Flash will be start.i think this code will help to you.

尝试此代码(单击OnButton):

try this code (OnButton Click) :

private void btnFlashOnClick() {

if (mCamera != null) {
                // First get the Camera Parameters.
                Camera.Parameters parameters = mCamera.getParameters();

                // set FlashMode to camera parameters.
                parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);

                // set Parameters Objects to Camera.
                mCamera.setParameters(parameters);

                // Finally, Start the Preview Of a Camera
                mCamera.startPreview(); // this Line is Usefull for MyApp.If you don't need then Remove this Line.
            }
}

此代码在我的应用中正常工作.希望这对您有帮助...(:

this code is works fine in my App..Hope this will helps you...(:

这篇关于如何在不停止相机供纸的情况下使用闪光灯?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆