Announcement

Collapse
No announcement yet.

Camera Zoom

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Camera Zoom

    Is there a way to control the zoom-level / field-of-view for Vuforia?

  • #2
    I am interested in that too. Anyone knows? Is there a command like one for flash ?

    Comment


    • #3
      Short answer is: Yes, you can control zoom using the Vuforia Java API (at least, for a Moto G5 Plus).

      Very long answer:

      First, check out the documentation of the Vuforia Java API here:

      https://library.vuforia.com/content/...377de21cd7edbb

      In particular, look at the CameraDevice and CameraField classes.

      Get the unique instance of CameraDevice using CameraDevice.getInstance().

      CameraDevice provides access to a large number of fields that describe and control the behavior of the camera through its getNumFields(), getCameraField(), setField(), and a variety of getField... methods.

      Each CameraField will have an associated key, value, and data type. Some are read-only, others read-write. I put together an op mode that logs all of the fields, with their keys, data types, and initial values, to a log file. For the Moto G5 Plus, there are 237 different fields. The available fields are expected to differ among different phones.

      Three fields of interest (given as key, data type, and initial value) are:

      key="opti-zoom", type=String, initial value="opti-zoom-off"
      key="zoom", type=String, initial value="0"
      key="zoom-ratios", type=String, initial value="100,102,104, etc etc etc all the way up to 400"

      I believe that "zoom-ratios" is a read-only field that just tells you what zoom ratio you'll get for a particular value of "zoom". So for zoom="0", the zoom ratio is 100%. The 20th item in the "zoom-ratios" field is 200, so I think if you set zoom to "19", you'll get a zoom ratio of 200%.

      So I tried this: Initialized Vuforia, then immediately after "waitForStart()" put the following code:

      CameraDevice.getInstance.setField("opti-zoom", "opti-zoom-on");
      CameraDevice.getInstance.setField("zoom", "19");

      It worked: immediately after pressing the "Start" arrowhead, the picture zoomed in significantly (I'm guessing 200%).

      I don't know how this zoom will interact with the Vuforia localization engine. Here's one possible pitfall:

      You can get your camera's long-axis and short-axis field-of-view angles (in radians) as follows:

      float fovRad = CameraDevice.getInstance().getCameraCalibration(). getFieldOfViewRads().getData();

      When I do this before zooming, I get a long axis fov (converted to degrees) of about 60 degrees (which seems to be about right). You'd expect this to decrease by 50% after zooming to 200%, but that doesn't happen. It stays the same after zooming in. So the Vuforia localization engine may or may not realize that it's dealing with a zoomed-in image. One would have to do additional testing to find out.

      Comment


      • #4
        Correction: in the preceding post fovRad should be declared as a float[], not just a float.

        Comment


        • #5
          jkenney - thanks for detail answer. I will try these functions and find out more. I assume default there is no zoom so FOV is max by default. Is there a way to zoom out so that cam area can see three minerals?

          Comment


          • #6
            FTC12676 I think you're correct that the default is maximal fov -- zoom starts at 0 and can only go up. We just look at center and right mineral; if neither is gold, we just go left.

            Comment

            Working...
            X