BlackBerry OS5 APIを使用してカメラに焦点を合わせることは可能ですか?
-
28-10-2019 - |
質問
デバイスのカメラのプレビューを取り、そのフィードを分析するアプリを開発しています。カメラのプレビューを作成できますが、カメラを自動的に調整することはできません。
ネイティブのBlackBerryカメラアプリは、写真を撮る前に画像に焦点を合わせて「写真を撮る」メディアキーに応答するため、基礎となるハードウェアが自動フォーカスを実行できることを知っています。
しかし、私は写真を撮ろうとはしていません。バーコードの入力フィードを継続的にスキャンしようとしています。
これが私のコードです:
Player _player = Manager.createPlayer("capture://video");
_player.realize();
_player.start();
_vc = (VideoControl) _player.getControl("VideoControl");
//this is added to the screen
_viewFinder = (Field) _vc.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
FocusControl focusControl = (FocusControl) _player.getControl("javax.microedition.amms.control.camera.FocusControl");
//this has no effect
focusControl.setFocus(FocusControl.AUTO);
BlackBerry Storm 9500とBOLD 9700でOS5を実行していることをテストしました。
解決 2
OS5でカメラを集中させる唯一の方法は、VideoControl.getSnapshot()を使用することです。他の方法はありません。
他のヒント
これを試して
this.player = Manager.createPlayer("capture://video");
this.player.realize();
this.videoControl = ((VideoControl)this.player.getControl("VideoControl"));
this.field = ((Field)this.videoControl.initDisplayMode(0, "net.rim.device.api.ui.Field"));
this.videoControl.setVisible(true);
this.player.start();
try {
//get focuscontrol
FocusControl focusControl = (FocusControl)getCurrentObject().player.getControl("javax.microedition.amms.control.camera.FocusControl");
if (focusControl == null) {
//no focus control
Log.Debug("Focus control not available.");
} else {
if (focusControl.isMacroSupported()) {
//setting macro
Log.Debug("Setting macro mode.");
focusControl.setMacro(true);
} else {
//no macro
Log.Debug("Macro mode not supported.");
}
if (focusControl.isAutoFocusSupported()) {
//setting autofocus
Log.Debug("Using autofocus.");
focusControl.setFocus(-1000);
} else {
//no autofocus
Log.Debug("Autofocus not supported.");
}
}
わたしにはできる !!!
所属していません StackOverflow