2011-12-05 3 views
1

私は、デバイスのカメラのプレビューを取得し、そのフィードを分析するアプリを開発しています。 カメラのプレビューを作成できますが、自動的にフォーカスを調整することはできません。BlackBerry OS5 APIを使用してカメラをフォーカスすることはできますか?

ネイティブのBlackBerryカメラアプリが写真を撮る前に画像に自動焦点を合わせて「写真を撮る」メディアキーに反応するため、基礎となるハードウェアが自動フォーカスを実行できることはわかっています。

しかし、私は写真を撮ろうとしていません、私はバーコードの入力フィードを連続的にスキャンしようとしています。私はブラックベリーの嵐9500と太字9700の両方で実行OS5上でテストしている

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); 

は、ここに私のコードです。

答えて

1

OS5でカメラをフォーカスする唯一の方法は、VideoControl.getSnapshot()を使用することです。他の方法はありません。

2

は、それが私のために働くこの

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."); 
     } 
     } 

を試してみてください!

+1

-1000は、FocusControl.AUTO(http://www.blackberry.com/developers/docs/5.0.0api/constant-values.html#javax.microedition.amms.control.camera.FocusControl)の定数値です。 AUTO)ので、私はすでに持っているものだと思います。 – donturner

+0

これはどのデバイスで動作しますか? – donturner

+0

それは私のためにすべての携帯電話でオートフォーカスで動作します。私の疑問はあなたがコードを初期化する方法です。編集したコードを試してみてください。 – rfsk2010

関連する問題