Log in or register to post comments

AR Camera Field Of View

January 10, 2013 - 6:09am #1

Can i change the field of view of ar camera? so that i can make a zoom in/zoom out effect? i try to change the field of view, it works on unity editor, but when i run the app on my device, the field of view didnt make a zoom effect

AR Camera Field Of View

June 9, 2017 - 8:16am #12

AlessandroB wrote:

Hi, if you really need to do that, you may take a look and modify the code in QCARBehaviour.cs (code reported here for ease of reference):

 

private void UpdateProjection(ScreenOrientation orientation)
    {
        if (!QCARRuntimeUtilities.IsQCAREnabled())
        {
            // Skip this when running in the free editor version 
            // that does not support native plugins
            return;
        }
 
        // This member stores the screen orientation used for the last projection matrix
        // update. It is used to counter rotate the poses later.
        mProjectionOrientation = orientation;
 
        // cache the current surface orientation:
        QCARRuntimeUtilities.CacheSurfaceOrientation(orientation);
 
        Matrix4x4 projectionMatrix = QCARUnity.GetProjectionGL(camera.nearClipPlane,
                                    camera.farClipPlane, mProjectionOrientation);
 
        if (mViewportRect.width != Screen.width)
        {
            float viewportDistort = mViewportRect.width / Screen.width;
            projectionMatrix[0] *= viewportDistort;
        }
 
        if (mViewportRect.height != Screen.height)
        {
            float viewportDistort = mViewportRect.height / Screen.height;
            projectionMatrix[5] *= viewportDistort;
        }
 
        this.camera.projectionMatrix = projectionMatrix;
    }
 
So, you will need to modify the projectionMatrix so to reproduce the desired field of view.
 
Some caution notes:
- changing this behaviour will break the consistency between real camera (device camera) and virtual camera; this may result in other potentail side effects.
- QCARBehaviour is a script that usually should not be modified, as it runs some of the core functionalities, so just be aware of that.
 
 

Hi Alessandro, could you tell me where can I find this script?

AR Camera Field Of View

November 12, 2015 - 5:58am #11

Hi, we have the same Questions. 
We need to zoom in the camera a bit (or make the FoV smaller).

But as mentioned below the QCARBehaviour.cs Script does not exist anymore, we are working with v5.0.5.

Any ideas?

 

Thank you and greetings,

Marco Brunetti.
 

 

 

AR Camera Field Of View

November 3, 2015 - 2:20am #10

I've got a question regarding this. Does the device camera FOV from vuforia is calculated by using the tracker or can the device camera FOV be read at runtime ?

AR Camera Field Of View

September 29, 2015 - 1:40am #9

hi, unlike you said, vuforia isn't adjusting ARCamera's fov as it's supposed to do, using v4.2.3

 

edit: nevermind the issue I had, was that after scene start I adjusted marker's scale and therefore it looked like it was a camera issue

AR Camera Field Of View

November 12, 2013 - 11:50am #8

Hi,

I'm trying the zoom in and zoom out too. I have tried to use another unity camera but the problem I have found are the parameters of one and other. For me is difficult create the same view in the Unity Camera than ARCamera. The field of view of both are different. For example, setting the same position, rotation, fov, etc. I see different views. If I play with fov I could see a similar view like ARCamera shows. But it is not identical. So, the ARcamera Fov = 63 and Unity Camera fov = 31. Now is similar but not the same.

How could I resolve it? 

Regards,

Jordi 

AR Camera Field Of View

March 11, 2013 - 12:06pm #7

Thank you for your reply.  This has opened up a lot of possibilities. I like the thought of scaling the object dynamically to the camera's FOV. I'm also thinking about an alternative way to possibly handle it with a GUI sprite sheet.

Basically, it's like a FPS game with a 3D model parked up close to the main camera. I'm just using a large collider box around the model as the trigger toggle button. When touched, an animation plays.  Problem is, like I mentioned before the FOV is always different per device and that model is either partially obscurred off the screen or noticeably smaller and pushed way into the screen... depending on which ipad I have been testing on.   

I will try a few things and let you know if I figure anything out.  

Is anyone else running into this problem? I'm curious if something like this happens on Andrioid models as well as iOS.  

AR Camera Field Of View

March 11, 2013 - 10:21am #6

Hi Jim,

the problem with using the 63 degrees FOV (or any custom value you may like) is that you risk to break the "visual effect" of making the 3D virtual objects appear consistent with the "real world";

this is because the "real world" appears in your screen as captured by the real device camera (which has its own optics and thus its own perspective FOV);

however, if you test on several devices and you see that the 63 degrees looks acceptable (and does not break the AR illusion), then of course you are free to use such FOV (in the end it's all a matter of how good it looks to the final user, and you can visually judge it much better than any "computer graphics theory" book :-) )

So, just be aware of the risk to break the AR illusion, but after all, if it looks OK, you can certainly go with it.

 

An alternative approach could be perhaps to dynamically adjust the scale of your "3D buttons" based on the screen aspect ratio (this is probably the best way of doing it).

 

AR Camera Field Of View

March 11, 2013 - 10:00am #5

I am having a similar issue in the way I am doing onscreen buttons, using Unity primative cubes with colliders and without mesh renderers as buttons (children of the AR camera) and a GUI overlay over top of the whole thing. Sometimes I use actual 3D models as buttons in this same way. This is the case on a current project in which one of my models is parented to the camera and is supposed to appear in the bottom right hand corner.

But I have found that when I go from device to device even among those with the same resolution, the aspect looks completely different.  I would like to force it into a specific field of view aspect at the start. 

But I don't take your cautions lightly. Can you recommend the simplest and least invasive method for accomplishing this? For example, I've found that a field of view of 63 in the Unity editor looks ideal to go from device to device for what I am trying to accomplish. 

Thank you! 

 

Jim O'Donnell

Hi, if you really need to do

January 15, 2013 - 9:43am #4

Hi, if you really need to do that, you may take a look and modify the code in QCARBehaviour.cs (code reported here for ease of reference):

 

private void UpdateProjection(ScreenOrientation orientation)
    {
        if (!QCARRuntimeUtilities.IsQCAREnabled())
        {
            // Skip this when running in the free editor version 
            // that does not support native plugins
            return;
        }
 
        // This member stores the screen orientation used for the last projection matrix
        // update. It is used to counter rotate the poses later.
        mProjectionOrientation = orientation;
 
        // cache the current surface orientation:
        QCARRuntimeUtilities.CacheSurfaceOrientation(orientation);
 
        Matrix4x4 projectionMatrix = QCARUnity.GetProjectionGL(camera.nearClipPlane,
                                    camera.farClipPlane, mProjectionOrientation);
 
        if (mViewportRect.width != Screen.width)
        {
            float viewportDistort = mViewportRect.width / Screen.width;
            projectionMatrix[0] *= viewportDistort;
        }
 
        if (mViewportRect.height != Screen.height)
        {
            float viewportDistort = mViewportRect.height / Screen.height;
            projectionMatrix[5] *= viewportDistort;
        }
 
        this.camera.projectionMatrix = projectionMatrix;
    }
 
So, you will need to modify the projectionMatrix so to reproduce the desired field of view.
 
Some caution notes:
- changing this behaviour will break the consistency between real camera (device camera) and virtual camera; this may result in other potentail side effects.
- QCARBehaviour is a script that usually should not be modified, as it runs some of the core functionalities, so just be aware of that.
 
 

Hey Alessandro, For my use

January 15, 2013 - 8:20am #3

Hey Alessandro,

For my use case, I need to do something like this. I'm wondering if you can provide any advice on possibilities for workarounds...like maybe making a second camera with the desired field of view and attaching it to the ARCamera?

Thanks!

Hi,Vuforia automatically

January 10, 2013 - 7:58am #2

Hi,

Vuforia automatically enforces the field of view to be at the same value as the real camera; this is to make it consistent with the device camera (the real camera) field of view.

So, even if you change it, your value will be overridden.

 

Log in or register to post comments