Log in or register to post comments

Vuforia 4.0 register tracker event handler

March 4, 2015 - 1:36am #1

I cannot find out the api to register the tracker event handler like below:

qcarBehavior.RegisterTrackerEventHandler (thistrue);

but there is the unregister api, so do i miss something?

Felix

Vuforia 4.0 register tracker event handler

March 20, 2015 - 12:12am #6

If it cannot find the "Vuforia" namespace, it may mean that:

1. you're still using Vuforia 3.0.9 (or older), 

OR,

2. you have not correctly imported the Vuforia 4.0 plugin into your project.

 

see also:

https://developer.vuforia.com/library//articles/Solution/Vuforia-40-Migration

 

Vuforia 4.0 register tracker event handler

March 19, 2015 - 11:55pm #5

Thanks for reply AlessandroB, I added that namespace at the top of script, but I got another error.

Assets/Qualcomm Augmented Reality/Scripts/CameraImageAccess.cs(3,7): error CS0246: The type or namespace name `Vuforia' could not be found. Are you missing a using directive or an assembly reference?
 

Here is my script 

using UnityEngine;
using System.Collections;
using Vuforia;
 
public class CameraImageAccess : MonoBehaviour 
{
private Image.PIXEL_FORMAT m_PixelFormat = Image.PIXEL_FORMAT.RGB888;
private bool m_RegisteredFormat = false;
private bool m_LogInfo = true;
void Start()
{
QCARBehaviour qcarBehaviour = (QCARBehaviour) FindObjectOfType(typeof(QCARBehaviour));
if (qcarBehaviour)
{
qcarBehaviour.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);
}
}
public void OnTrackablesUpdated()
{
if (!m_RegisteredFormat)
{
CameraDevice.Instance.SetFrameFormat(m_PixelFormat, true);
m_RegisteredFormat = true;
}
if (m_LogInfo)
{
CameraDevice cam = CameraDevice.Instance;
Image image = cam.GetCameraImage(m_PixelFormat);
if (image == null)
{
Debug.Log(m_PixelFormat + " image is not available yet");
}
else
{
string s = m_PixelFormat + " image: \n";
s += "  size: " + image.Width + "x" + image.Height + "\n";
s += "  bufferSize: " + image.BufferWidth + "x" + image.BufferHeight + "\n";
s += "  stride: " + image.Stride;
Debug.Log(s);
m_LogInfo = false;
}
}
}
}

Vuforia 4.0 register tracker event handler

March 19, 2015 - 11:39pm #4

In Vuforia 4.0 or above, a new "Vuforia" namespace has been introduced;

you need to add this line at the top of your script:

 

using Vuforia;

 

 

Vuforia 4.0 register tracker event handler

March 19, 2015 - 10:25pm #3

Hi, 

       I am new to vuforia, I had below error 

      Assets/Qualcomm Augmented Reality/Scripts/CameraImageAccess.cs(14,39): error CS1061: Type `QCARBehaviour' does not contain a definition for `RegisterTrackablesUpdatedCallback' and no extension method `RegisterTrackablesUpdatedCallback' of type `QCARBehaviour' could be found (are you missing a using directive or an assembly reference?)

Please help me...
Here is my script
using UnityEngine;
using System.Collections;
 
public class CameraImageAccess : MonoBehaviour 
{
private Image.PIXEL_FORMAT m_PixelFormat = Image.PIXEL_FORMAT.RGB888;
private bool m_RegisteredFormat = false;
private bool m_LogInfo = true;
void Start()
{
QCARBehaviour qcarBehaviour = (QCARBehaviour) FindObjectOfType(typeof(QCARBehaviour));
if (qcarBehaviour)
{
qcarBehaviour.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);
}
}
public void OnTrackablesUpdated()
{
if (!m_RegisteredFormat)
{
CameraDevice.Instance.SetFrameFormat(m_PixelFormat, true);
m_RegisteredFormat = true;
}
if (m_LogInfo)
{
CameraDevice cam = CameraDevice.Instance;
Image image = cam.GetCameraImage(m_PixelFormat);
if (image == null)
{
Debug.Log(m_PixelFormat + " image is not available yet");
}
else
{
string s = m_PixelFormat + " image: \n";
s += "  size: " + image.Width + "x" + image.Height + "\n";
s += "  bufferSize: " + image.BufferWidth + "x" + image.BufferHeight + "\n";
s += "  stride: " + image.Stride;
Debug.Log(s);
m_LogInfo = false;
}
}
}
}

 

Vuforia 4.0 register tracker event handler

March 4, 2015 - 12:17pm #2

See API reference:

https://developer.vuforia.com/resources/api/unity/class_vuforia_1_1_q_c_a_r_abstract_behaviour

The RegisterTrackerEventHandler method is still available;

however, Vuforia 4.0 also introduces new APIs, that you should consider using:

  • RegisterQCARStartedCallback( )
  • RegisterQCARInitializedCallback( )
  • RegisterTrackablesUpdatedCallback( )

 

Log in or register to post comments