是否可以使用 BlackBerry OS5 API 对相机进行对焦?

发布于 2024-12-19 13:31:21 字数 739 浏览 2 评论 0原文

我正在开发一个应用程序,它可以预览设备的相机并分析该信息。 我可以创建相机预览,但无法让相机自动调整焦点。

我知道底层硬件可以执行自动对焦,因为本机黑莓相机应用程序通过在拍照之前自动对焦图像来响应“拍照”媒体键。

但是,我并不是要拍照,而是要连续扫描输入源中的条形码。

这是我的代码:

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

我已经在运行 OS5 的 BlackBerry Storm 9500 和 Bold 9700 上进行了测试。

I am developing an app which takes a preview of the device's camera and analyses that feed.
I can create the camera preview, but cannot get the camera to adjust its focus automatically.

I know that the underlying hardware is possible of performing an auto focus because the native BlackBerry camera app responds to the 'take photo' media key by auto focussing the image prior to taking the photo.

However, I'm not trying to take a photo, I'm trying to continuously scan the input feed for a barcode.

Here's my code:

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

I have tested on BlackBerry Storm 9500 and Bold 9700 both running OS5.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮生面具三千个 2024-12-26 13:31:21

试试这个

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

它对我有用!

Try this

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

It works for me !!!

幸福不弃 2024-12-26 13:31:21

OS5 中相机聚焦的唯一方法是使用 VideoControl.getSnapshot()。没有其他办法。

The only way to focus the camera in OS5 is to use VideoControl.getSnapshot(). There is no other way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文