Log in or register to post comments

Augmented 3d object is getting overlapped with multitarget

March 19, 2014 - 5:25am #1

My 3D Augmented object  is getting overlapped with the cuboid image target. I want to hide the image target so that I can show my augmented object properly. 

My Image target is overlapping the augmented object. I want to mask out the image target

Augmented 3d object is getting overlapped with multitarget

April 1, 2014 - 2:44am #15

Ok, so, if you also trigger the autofocus, and still see same flickering, I would tend to exclude that is is a focus issue anymore;

maybe worth still checking this article for a complete check-list of all the possible factors that can influence tracking stability:

https://developer.vuforia.com/forum/faq/how-can-i-improve-detection-and-tracking-stability

 

 

Augmented 3d object is getting overlapped with multitarget

April 1, 2014 - 2:39am #14

Thanks for the reply. I checked the log there is no such message. And even if the device does not support continuous autofocus I have made a button which toggles autofocus mode if you look in my code. I call the  TriggerFocusOnce() method when focus is pressed. The augmented 3d object is still flickering.

Augmented 3d object is getting overlapped with multitarget

April 1, 2014 - 1:21am #13

The code looks correct. If you look at the device Logs, do you see the message "Cont. Autofocus not supported" ?  or is the continuous autofocus working ?

 

Augmented 3d object is getting overlapped with multitarget

March 31, 2014 - 11:05pm #12

This is my code as you suggested. I call the TriggerFocusOnce() method when focus is pressed

 

using UnityEngine;
using System.Collections;
 
 public class Focus : MonoBehaviour, ITrackerEventHandler{
#region PRIVATE_MEMBER_VARIABLES
 
private const string AUTOFOCUS_ON = "Autofocus On";
private const string AUTOFOCUS_OFF = "Autofocus Off";
 
// Contains if the device supports continous autofocus
private bool mContinousAFSupported = true;
 
// Contains the currently set auto focus mode.
private CameraDevice.FocusMode mFocusMode =
CameraDevice.FocusMode.FOCUS_MODE_NORMAL;
 
// reference to the CloudRecoBehaviour
//private CloudRecoBehaviour mCloudRecoBehaviour;
 
private string mAutoFocusText = "";
#endregion // PRIVATE_MEMBER_VARIABLES
 
// Use this for initialization
public void Start()
{
// register for the OnInitialized event at the QCARBehaviour
QCARBehaviour qcarBehaviour = (QCARBehaviour)FindObjectOfType(typeof(QCARBehaviour));
if (qcarBehaviour)
{
qcarBehaviour.RegisterTrackerEventHandler(this);
}
 
// obtain reference to the cloud reco behaviour:
// mCloudRecoBehaviour = (CloudRecoBehaviour)FindObjectOfType(typeof(CloudRecoBehaviour));
 
}
 
// Update is called once per frame
void Update () {
 
}
 
#region ITrackerEventHandler_IMPLEMENTATION
public void OnInitialized()
{
// try to set continous auto focus as default
if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO))
{
mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO;
mAutoFocusText = AUTOFOCUS_OFF;
}
else
{
Debug.LogError("could not switch to continuous autofocus");
mContinousAFSupported = false;
mAutoFocusText = "Cont. Auto Focus not supported";
}
}
 
public void OnTrackablesUpdated()
{
// not used
}
 
#endregion //ITrackerEventHandler_IMPLEMENTATION
 
#region PRIVATE_METHODS
 
public void TriggerFocusOnce()
{
// trigger focus once
if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO))
{
mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO;
mAutoFocusText = AUTOFOCUS_ON;
}
}
 
public void ToggleAutoFocusMode()
{
if (!mContinousAFSupported)
{
mAutoFocusText = "Cont. Auto Focus not supported ";
}
 
if (mFocusMode != CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO)
{
if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO))
{
mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO;
mAutoFocusText = AUTOFOCUS_OFF;
}
}
else
{
if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL))
{
mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_NORMAL;
mAutoFocusText = AUTOFOCUS_ON;
}
}
}
#endregion // PRIVATE_METHODS
}
 

Augmented 3d object is getting overlapped with multitarget

March 23, 2014 - 8:48am #11

To answer your first question:

We are using iPad and iPhone as our tracking device. Will this help us on those devices?

Which specific iPhone and iPad models (e.g. iPhone 4S, 5, ... ) ? Depending on the device, you might have different autofocus capabilities.

Concerning your code:

the code is correct, however, putting the CameraDevice.Instance.SetFocusMode() in the Start() method of your script may be "risky", as this might be executed too early, i.e. before the Vuforia camera has been initialized, thuis not having the desired effect.

A safer approach is to create another script and implement the ITrackerEventHandler interface and call the CameraDevice.Instance.SetFocusMode() inside the OnInitialized() method, as this method is guaranteed to be called after Vuforia has been initialized.

Another little tip:

it is a best practice to check the returned value of the CameraDevice.Instance.SetFocusMode(), which is a boolean telling you if the mode was successfully set; if the function returns false, it means that it failed to set the mode, which might indicate that the speciifc device does not support that mode (in which case, the best next option is to use another focus mode called TRIGGER_AUTO)

 

 

 

 

Augmented 3d object is getting overlapped with multitarget

March 23, 2014 - 1:36am #10

Still flickering on the iPad and iPhone not flickering that much on Nexus 4

 #region UNTIY_MONOBEHAVIOUR_METHODS
    
    void Start()
    {
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
        {
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
        }

        CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
    }

 

Code is written on defalut trackable handler

 

Augmented 3d object is getting overlapped with multitarget

March 22, 2014 - 9:04pm #9

Hi,

 

We are using iPad and iPhone as our tracking device. Will this help us on those devices?

Augmented 3d object is getting overlapped with multitarget

March 22, 2014 - 6:48am #8

Hi, 

have you tried settings the Focus Mode to CONTINUOUS_AUTO ?

The focus mode can play a significant role in this. If the camera is out of focus, the image may be blurry and tracking may be affected.

See also this page:

https://developer.vuforia.com/resources/dev-guide/continuous-autofocus-and-other-focus-modes

 

The Unity code to enable a specific focus mode is this:

CameraDevice.Instance.SetFocusMode( your_selected_mode );

Also, the Vuforia samples illustrate how you can trigger an autofocus event by tapping on the device screen; if your device does not support CONTINUOUS_AUTOFOCUS, than the next best option is to use TRIGGER_AUTO.

 

Augmented 3d object is flickering a lot on the cuboid target and

March 22, 2014 - 5:22am #7

Thanks for the reply AlessandroB. I modified my code accordingly and it worked perfectly fine. But there is a new problem. The 3D augmented model is flickering a lot on the cuboid target and is unstable. The image target has a 5 star rating though. The lighting in the room is also good. Also we have tried it with different cuboid targets but the augmented model is flickering. 

Augmented 3d object is getting overlapped with multitarget

March 19, 2014 - 8:09am #6

Ok, so, the easiest way of hiding (masking out / not rendering) the Multi Target faces, so that they don't conflict with your model,

is simply to disable / (or not enable) the Renderer components of the targets.

If you look at the MultiTarget sample, the target has a DefaultTrackableEventHandler script attached;

in this script, the Renderer components are enabled whenever the target is found, and disabled whenever the target is lost;

in the code you will see there are 2 methods, called OnTrackingFound() and OnTrackingLost() which handle the above logic.

So, what I would suggest is to try and modify the OnTrackingFound() logic, so that, instead of enabling ALL the renderer components in the child-hierarchy of the Multi-Target, you could first Find your Augmentation 3D model (child of the Multi-Target), and then only retrieve the Renderer components of it, and only enable them;

so bascially, you should modify the script along the lines of  this example:

private void OnTrackingFound()
{
    // First: Find the augmentation object:
    Transform augmentationModelTrf = this.transform.FindChild ("bowlspoon2");
    GameObject augmentationModel = augmentationModelTrf.gameObject;

    
    Renderer[] rendererComponents = augmentationModel.GetComponentsInChildren<Renderer>(true);
    Collider[] colliderComponents = augmentationModel.GetComponentsInChildren<Collider>(true);

    // Enable rendering:
    foreach (Renderer component in rendererComponents)
    {
        component.enabled = true;
    }

    // Enable colliders:
    foreach (Collider component in colliderComponents)
    {
        component.enabled = true;
    }

    Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
 }

 

Augmented 3d object is getting overlapped with multitarget

March 19, 2014 - 7:35am #5

Augmented 3d object is getting overlapped with multitarget

March 19, 2014 - 7:32am #4

Are you using Vuforia Unity or Android native ?

Screenshot

March 19, 2014 - 6:45am #3

The cuboid target is hiding the backside of the 3D augmented object. I don't want to move the 3D object forward as it dosen't look good when looked from side view. You can find the screenshot on this link  https://www.dropbox.com/s/0ba4v7mc4o7cfhc/screenshot.png

Augmented 3d object is getting overlapped with multitarget

March 19, 2014 - 6:05am #2

You can achieve that by implement a depth mask effect, e.g. with a depth mask shader.

This is normally already shown in the Multi Targets sample. If you want something different, could you explain it better, maybe attaching some image / graphics to illustrate it ?

 

 

Log in or register to post comments