Well, I don't know about Metaio, but Vuforia has this feature you seek.
Vuforia has this concept of User-defined targets. You can download the Vuforia SDK or Unity extension of Vuforia ot do so.
I personally use Vuforia Unity and the ARCamera from there just needs to be changed so that it fits the User Defined settings.
After that you simply need to add this script that allows access to the camera Images as follows:
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;
}
}
}
If you're planning to use the Vuforia SDK instead then you should Use the image class so works much like the native version.
Register for the desired image format using the CameraDevice.SetFrameFormat
method: CameraDevice.Instance.SetFrameFormat(Image.PIXEL_FORMAT.RGB888, true);
Call this method after QCARBehaviour
has a chance to run its Start method.
- Use the Unity script-ordering feature, or do this once in an
Update
callback.
- Retrieve the image using the
CameraDevice.GetCameraImage
method.
- Take this action from the
ITrackerEventHandler.OnTrackablesUpdated
callback. That way you can ensure that you retrieve the latest camera image that matches the current frame.
- Always make sure that the camera image is not null, since it can take a few frames for the image to become available after registering for an image format.
Thumbs up, if this was helpful.