Log in or register to post comments

Unity AR Camera Control

May 24, 2013 - 7:59am #1

Hi,

This may seem weird as it will mean the model will not align with the video feed but I would like to do the following:

I would like the AR Camera to always be rotated by 90 degrees downwards (ie. relative to its own axis). Does that make sense? So wherever the camera would be pointing normally I want it to instead point 90 degrees down.

I have been trying for the last two days, but cant seem to locate the script where these kind of things are set.

Any ideas much appreciated.... Thank you!

 

Unity AR Camera Control

May 31, 2013 - 2:02am #7

Please in future do not reuse an existing thread as it simply causes confusion and delays.

For Play Mode on desktop you need the Pro version, since native plugins are not supported in the free version on desktops.

 

N

Unity AR Camera Control

May 30, 2013 - 3:17pm #6

I have error with Unity Licence.:
Licence error pluging are only support by unity pro

Everybody can help me to solve this problem?

Unity AR Camera Control

May 24, 2013 - 2:22pm #5

Thanks for helping again Alessandro.

Iknow its a bit unsual :) and does appear to go against the general logic of AR. Its a bizarre way of using AR but I am hoping to be able to create a quite immersive AR experience if I can get it working.....hopefully with your help again......:)

When I opened that file in Unity I couldnt see any maths as such in the code. Although looking online it seems that in some peoples version of that file there is. This is what I have:

/*==============================================================================
Copyright (c) 2010-2013 QUALCOMM Austria Research Center GmbH.
All Rights Reserved.
Qualcomm Confidential and Proprietary
==============================================================================*/

using System.Collections.Generic;

/// <summary>
/// The ImageTracker encapsulates methods to manage DataSets and provides access to
/// the ImageTargetBuilder and TargetFinder classes
/// </summary>
public abstract class ImageTracker : Tracker
{
    #region PROPERTIES

    /// <summary>
    /// exposes the ImageTargetBuilder member to other classes
    /// </summary>
    public abstract ImageTargetBuilder ImageTargetBuilder { get; }

    /// <summary>
    /// exposes the ImageTargetBuilder member to other classes
    /// </summary>
    public abstract TargetFinder TargetFinder { get; }

    #endregion // PROPERTIES



    #region PUBLIC_METHODS

    /// <summary>
    /// Creates a new empty dataset.
    /// </summary>
    public abstract DataSet CreateDataSet();


    /// <summary>
    /// Destroy the given dataset.
    /// Returns false if the given dataset is active.
    /// </summary>
    public abstract bool DestroyDataSet(DataSet dataSet, bool destroyTrackables);


    /// <summary>
    /// Activates the given dataset.
    /// Datasets can only be activated when the tracker is not running.
    /// </summary>
    public abstract bool ActivateDataSet(DataSet dataSet);


    /// <summary>
    /// Deactivates the given dataset.
    /// This can only be done when the tracker is not running.
    /// </summary>
    public abstract bool DeactivateDataSet(DataSet dataSet);


    /// <summary>
    /// Returns the currently activated datasets. 
    /// </summary>
    public abstract IEnumerable<DataSet> GetActiveDataSets();


    /// <summary>
    /// Returns all datasets.
    /// </summary>
    public abstract IEnumerable<DataSet> GetDataSets();


    /// <summary>
    /// Deactivates the currently active dataset and
    /// destroys all datasets
    /// </summary>
    public abstract void DestroyAllDataSets(bool destroyTrackables);

    #endregion // PUBLIC_METHODS
}

Is this the one you mean? If so I guess I need to find where those datasets are created. Which one do I need?

Another attempt I made was to update the file Tracker.cs in the following way hoping this might do the trick. I just added an extra line at the bottom....

    #region PROTECTED_METHODS

    /// <summary>
    /// Position the camera relative to a Trackable.
    /// </summary>
    protected void PositionCamera(TrackableBehaviour trackableBehaviour,
                                  Camera arCamera,
                                  QCARManagerImpl.PoseData camToTargetPose)
    {
        arCamera.transform.localPosition =
                trackableBehaviour.transform.rotation *
                Quaternion.AngleAxis(90, Vector3.left) *
                Quaternion.Inverse(camToTargetPose.orientation) *
                (-camToTargetPose.position) +
                trackableBehaviour.transform.position;

        arCamera.transform.rotation =
                trackableBehaviour.transform.rotation *
                Quaternion.AngleAxis(90, Vector3.left) *
                Quaternion.Inverse(camToTargetPose.orientation);
		//ROB: extra line added to take whatever the rotation is and go down by 90 degrees
		arCamera.transform.Rotate(Vector3.right, 90);
    }   

 I had set the AR Camera to Auto and only have one ImageTarget. This extra bit of coded didnt seem to do anything though. The AR still worked as normal!

Strangely though when I comment out the this entire bit of code it didnt seem to do anything either, the AR still worked as normal!!!! Which makes me think I am doing something wrong and my new code is not being accessed??? I am opening the code in the unity editor and saving it as the same file and then saving the project and the scene and then selecting the new scene to build in build settings and then running it....Can the AR work without this section of code? ..

Sorry about this any help and further direction would be much appricated.

Thanks again...

 

 

Unity AR Camera Control

May 24, 2013 - 11:59am #4

Well, actually the scenario you describe sounds a bit unusual, as the tracker determines the relative position and relative orientation of the target with respect to the camera, so rotating the camera artificially might lead to results that are in conflict with the base idea of tracking.

However, if you want to experiment this path, you could start by looking at the code in ImageTracker.cs; here is where all the core mathematics occur, and you might be able to find your way by modifying the code in there (but not advisable...)

The ImageTracker.cs script is located in the Qualcomm Augmented Reality / scripts folder

 

Unity AR Camera Control

May 24, 2013 - 11:29am #3

Hi AlessandroB,

Thanks. I know what you are suggesting but theat will not work for what I want to do. I actually want the camera to be always pointing 90 degrees down relative to itself. ie i want to simulate the virtual camera pointing down from the phone.  Moving only the model will not work although on firtst thought that is what I thought I needed to do too.

Do you know where the camera position and rotation is set within the Qualcomm scripts when using a target image? If so I might be well on my way......maybe.

Thanks.

 

 

Unity AR Camera Control

May 24, 2013 - 10:07am #2

Hi, have you tried just by rotating the 3D model 90 degrees in the scene view ?

 

Log in or register to post comments