三星Galaxy S5摄像头手电筒不工作 [英] Samsung Galaxy S5 Camera Torch not working
问题描述
我们有一个应用程序,与所有支持Android手机的工作原理,除了三星Galaxy S5。我们的应用程序使用相机拍照近距离。 我们需要手电筒模式对我们的重点是拍摄照片的整个时间。我们检查支持的参数,如果支持设置的值。
在PARAMS得到确定,但该事件要么永远不会被解雇或相机被忽略我的设置。我测试用OpenCamera和他们的应用程序是能够把火炬但我找不到我怎么设置我的PARAMS对他们是如何设置他们之间的区别。
下面是我们的code:
//设置的摄像机参数(闪光灯,对焦,白平衡等)
私人无效setCameraParameters()
{
//旋转的preVIEW的方向以匹配设备的取向
camera.setDisplayOrientation(getCameraRotation());
//一个参数对象必须用于设置其他参数。
参数PARAMS = camera.getParameters();
//闪光模式火炬如果支持
如果(params.getSupportedFlashModes()。包括(火炬))
{
//火炬模式
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
}
//对焦模式为微距如果支持的话,汽车如果不能
如果(params.getSupportedFocusModes()。包括(宏))
{
//微距对焦模式
params.setFocusMode(Parameters.FOCUS_MODE_MACRO);
}
其他
{
//自动对焦模式
params.setFocusMode(Parameters.FOCUS_MODE_AUTO);
}
//白平衡模式为自动(如果可用)。
名单<字符串> supported_white = params.getSupportedWhiteBalance();
如果(supported_white!= NULL)
{
如果(supported_white.contains(自动))
{
params.setWhiteBalance(Parameters.WHITE_BALANCE_AUTO);
}
}
//自动曝光锁定为false(如果可用)
如果(params.isAutoExposureLockSupported())
{
params.setAutoExposureLock(假);
}
//自动白平衡锁定(如果可用)。
如果(params.getAutoWhiteBalanceLock())
{
params.setAutoWhiteBalanceLock(假);
}
// JPEG画质设置为100(最高)
{
params.setJpegQuality(100);
}
//设置对焦区域和测光区域
名单< Camera.Area> focusArea = calculateFocusArea();
params.setFocusAreas(focusArea);
params.setMeteringAreas(focusArea);
Camera.Size大小= pickCameraSize(params.getSupportedPictureSizes());
params.setPictureSize(size.width,size.height);
//设置相机的新参数
camera.setParameters(PARAMS);
布尔火炬= getTorchState(摄像头);
}
//添加此方法从zxing github上,看看是否值被设置
布尔getTorchState(摄像头摄像头){
如果(相机!= NULL){
Camera.Parameters参数= camera.getParameters();
如果(参数!= NULL){
字符串flashMode = camera.getParameters()getFlashMode()。
返回flashMode!= NULL
&功放;&安培; (Camera.Parameters.FLASH_MODE_ON.equals(flashMode)|| Camera.Parameters.FLASH_MODE_TORCH
.equals(flashMode));
}
}
返回false;
}
您必须在Android的棒棒堂使用新的摄像机2 API
We have an app that works with all our supported Android phones "except Samsung Galaxy S5". Our app uses the camera to take pictures at close range. We need torch mode ON the entire time we are focusing to take the picture. We check for supported parameters and set the values if supported.
The params get set but the event either never gets fired or the camera is ignoring my settings. I tested using OpenCamera and their app is able to turn the torch on yet I cannot find the difference between how I set my params vs. how they set theirs.
Here is our code:
//Set all camera parameters(flash, focus, white balance, etc)
private void setCameraParameters()
{
//Rotate the orientation of the preview to match orientation of device
camera.setDisplayOrientation(getCameraRotation());
//A Parameters object must be used to set the other parameters.
Parameters params = camera.getParameters();
//Flash Mode to Torch if supported
if(params.getSupportedFlashModes().contains("torch"))
{
// Torch mode
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
}
//Focus Mode to Macro if supported, Auto if not
if(params.getSupportedFocusModes().contains("macro"))
{
//Macro focus mode
params.setFocusMode(Parameters.FOCUS_MODE_MACRO);
}
else
{
//Auto focus mode
params.setFocusMode(Parameters.FOCUS_MODE_AUTO);
}
//White Balance mode to Auto if available.
List<String> supported_white = params.getSupportedWhiteBalance();
if(supported_white!=null)
{
if(supported_white.contains("auto"))
{
params.setWhiteBalance(Parameters.WHITE_BALANCE_AUTO);
}
}
// Auto Exposure Lock to false if available
if(params.isAutoExposureLockSupported())
{
params.setAutoExposureLock(false);
}
// Auto White Balance Lock if available.
if(params.getAutoWhiteBalanceLock())
{
params.setAutoWhiteBalanceLock(false);
}
//JPEG quality set to 100(highest)
{
params.setJpegQuality(100);
}
//Set focus area and metering area
List<Camera.Area> focusArea = calculateFocusArea();
params.setFocusAreas(focusArea);
params.setMeteringAreas(focusArea);
Camera.Size size = pickCameraSize(params.getSupportedPictureSizes());
params.setPictureSize(size.width, size.height);
//Set new parameters for camera
camera.setParameters(params);
boolean torch = getTorchState(camera);
}
// Added this method from zxing github to see if the value is being set
boolean getTorchState(Camera camera) {
if (camera != null) {
Camera.Parameters parameters = camera.getParameters();
if (parameters != null) {
String flashMode = camera.getParameters().getFlashMode();
return flashMode != null
&& (Camera.Parameters.FLASH_MODE_ON.equals(flashMode) || Camera.Parameters.FLASH_MODE_TORCH
.equals(flashMode));
}
}
return false;
}
You have to use new camera2 API in Android Lollipop
and developer site
这篇关于三星Galaxy S5摄像头手电筒不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!