当我创建第二个AVCaptureSession时,自动对焦无法在第一个AVCaptureSession上运行.要创建的第二个会话是自动对焦工作的会话,第一个创建的会话不会自动对焦.
我希望任何一个会话都可以在另一个会话停止后自动对焦,就像两个会话的自动白平衡和自动曝光工作一样.如果您使用下面的示例代码观察日志窗口,您可以看到通过的键值观察消息; 但是在最高会话运行时从不改变焦点消息.
旁注:不幸的是我在我使用的第三方库中有一个错误,这使我无法简单地重新创建会话,因为我在它们之间切换(它正在泄漏其AVCaptureSessions,最终导致应用程序被杀死).完整的故事是这个库正在为我创建一个捕获会话,它有一个公共API来启动和停止会话,我希望创建另一个会话.下面的代码演示了问题,但没有使用第三方库.
我创建了一个测试应用程序,其中包含下面列出的代码和一个XIB文件,该文件有两个视图,一个在另一个之上,另一个按钮连接到switchSessions方法,用于演示该问题.
这可能与此处描述的问题有关, 焦点(自动对焦)不在相机中工作(AVFoundation AVCaptureSession),尽管没有提到两个捕获会话.
头文件:
#import <UIKit/UIKit.h>
@class AVCaptureSession;
@class AVCaptureStillImageOutput;
@class AVCaptureVideoPreviewLayer;
@class AVCaptureDevice;
@class AVCaptureDeviceInput;
@interface AVCaptureSessionFocusBugViewController : UIViewController {
IBOutlet UIView *_topView;
IBOutlet UIView *_bottomView;
AVCaptureDevice *_device;
AVCaptureSession *_topSession;
AVCaptureStillImageOutput *_outputTopSession;
AVCaptureVideoPreviewLayer *_previewLayerTopSession;
AVCaptureDeviceInput *_inputTopSession;
AVCaptureSession *_bottomSession;
AVCaptureStillImageOutput *_outputBottomSession;
AVCaptureVideoPreviewLayer *_previewLayerBottomSession;
AVCaptureDeviceInput *_inputBottomSession;
}
- (IBAction)switchSessions:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
实施文件:
#import "AVCaptureSessionFocusBugViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface AVCaptureSessionFocusBugViewController ()
- (void)setupCaptureSession:(AVCaptureSession **)session
output:(AVCaptureStillImageOutput **)output
previewLayer:(AVCaptureVideoPreviewLayer **)previewLayer
input:(AVCaptureDeviceInput **)input
view:(UIView *)view;
- (void)tearDownSession:(AVCaptureSession **)session
output:(AVCaptureStillImageOutput **)output
previewLayer:(AVCaptureVideoPreviewLayer …Run Code Online (Sandbox Code Playgroud) 我相信大多数人之前都使用过Android手机拍照.每当用户改变移动电话的位置并保持稳定时,相机就会自动对焦.我很难在我的应用程序中复制这个.在启动应用程序时,只调用一次autofocus()方法.过去3天我一直在寻找解决方案,在阅读谷歌文档时,我偶然发现了传感器方法调用(例如当用户向前或向后倾斜移动设备时).我可以使用这个API来实现我需要的东西,但它听起来太脏了,太复杂了.我相信还有另一种方法.
我发现互联网上的所有示例仅在用户按下屏幕或按钮时关注.我也经历了几个关于SO的问题,希望能找到我想要的东西,但我没有成功.我看过这个问题,并且String与我的手机不兼容.由于某种原因,我可以使用的唯一聚焦模式是固定和自动.
我希望这里的某个人会对这个问题有所了解,因为我不知所措.
非常感谢您的宝贵时间.
我正在从事视频应用.我想在相机自动对焦时丢弃视频帧.在自动聚焦期间,捕获的图像变得模糊,并且该帧的图像处理变差,但是一旦完成自动聚焦,图像处理就变得极好.有人给我解决方案吗?
理论上,自动对焦在移动Safari(http://caniuse.com/#feat=autofocus)中完全不受支持.然而,我们正在看到这种非常奇怪的行为,当一个touchstart事件被绑定时document(无论该函数是否有任何行为),当页面上任何地方发生点击时,第一个输入autofocus变得聚焦并且屏幕键盘显示.
这可以在iOS模拟器中使用iOS 8重现.这是重现问题的最小html和javascript:
<html>
<head>
<script>
document.addEventListener("touchstart", function() {});
</script>
</head>
<body>
<input type="text">
<input type="text" autofocus="autofocus">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这里有一个jsfiddle:http://jsfiddle.net/qd858nob/
只需单击输入外的任何位置,第二个输入将变为自动对焦.理想情况下,我很乐意找到解决此问题的全局解决方案,而无需从所有输入元素中删除自动对焦.
我们正在使用grunt-html-angular-validateHTML棉绒包。它在后台使用W3C 在线验证器工具,到目前为止,它在验证我们的角度模板方面做得很好。
今天,它在检查从存储库中提取的最新更改时失败,并显示以下错误:
验证src / login / login.html ...错误[L37:C108]
属性自动聚焦在元素输入上的值{{regCodeRequired}}无效。
这是失败的相关行:
<div class="auth-reg-code-block" ng-if="regCodeRequired">
<input class="form-control" type="text" name="regCode"
id="regCode" ng-model="user.regCode" autofocus="{{regCodeRequired}}"
placeholder="Registration Code" required>
</div>
Run Code Online (Sandbox Code Playgroud)
基本上,这是用于输入用于两因素验证的注册码的字段。regCodeRequired是一个布尔变量,true一旦用户通过了第一个登录/密码验证步骤,该变量就会设置为。
而且我看到输入侧重于输入(使用chrome 39)-它正在工作。
题:
我很确定验证工具有理由抱怨,但我不确定如何进行。我们使用autofocus属性不正确吗?我们应该如何解决验证错误?
我已经遍历了W3C验证程序错误,试图找到一种解释,但是那里什么autofocus也没有。另外,w3cjsgithub仓库中什么也没有。
这是以下配置htmlangular:
htmlangular: {
options: {
relaxerror: [
'Element head is missing a required instance of child element title.',
'Attribute href without an explicit value seen.',
'& did not start …Run Code Online (Sandbox Code Playgroud) 我正在开发一个具有相机功能的Android应用程序.
首先,我在SO,XDA等上阅读了很多内容,然后请不要将我重定向到其他无用的帖子.
我试图实现类似"固定焦点模式"的东西,以便:
FOCUS_MODE_AUTO(或其他)开始我的应用程序;我尝试了不同的解决方案,即:
mCamera.cancelAutoFocus()在AutoFocusCallback防止焦点调整;FocusArea:new Camera.Area(new Rect(-50, -50, 50, 50), 1000)将焦点固定在当前区域.我的目标是API 20,我正在研究三星Galaxy S5.在此设备上,支持的对焦模式为: - 自动 - 无限 - 宏 - 连续 - 视频 - 连续图像
我发现更频繁的建议是重新编译Android ...
我正在尝试使文本输入自动聚焦(在选择相关的单选选项时启用输入)。
在将启用文本输入的选项之间切换时,自动对焦有效。但是,当从禁用文本输入的选项切换到启用文本输入的选项时,自动对焦失败。
在下面的示例链接中:
失败案例:
成功案例:
我正在使用Javascript创建我的页面.这是一个登录页面,我需要在用户名输入文本上使用自动对焦.此操作适用于IE和Chrome,但不适用于Mozilla!这是我用JS添加的HTML:
'<input id="username" class="loginInput" data-bind="value: userName, valueUpdate: \'afterkeydown\'" type="text" name="User" autofocus><!--User Input text end /-->'
Run Code Online (Sandbox Code Playgroud)
当我使用Mozilla加载页面时,此输入以这种方式设置:
<input id="username" class="loginInput" type="text" autofocus="" name="User" data-bind="value: userName, valueUpdate: 'afterkeydown'">
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么以这种方式设置"autofocus"属性.我甚至尝试使用JQuery添加属性$("#username").attr('autofocus','autofocus'),仅适用于Chrome和IE.
当我从另一个页面进入登录页面并且每个浏览器都出现自动对焦问题时,会出现第二个问题.
你能帮助我吗?
我有一个react-bootstrap带有<input>. 我想在<input>
以下工作正常,但在控制台中显示警告
<input type="text" autofocus='true' />
Run Code Online (Sandbox Code Playgroud)
Warning: Invalid DOM property `autofocus`. Did you mean `autoFocus`?
Run Code Online (Sandbox Code Playgroud)
以下选项不起作用,因为它们在打开模态时不会聚焦输入:
<input type="text" autoFocus='true' />
<input type="text" autoFocus={true} />
<input type="text" autoFocus />
Run Code Online (Sandbox Code Playgroud)
设置自动对焦的推荐方法是什么。或者我应该如何使运行良好的示例的警告静音?
注意:这是反应 16.8.6
javascript autofocus bootstrap-modal reactjs react-bootstrap