Hi,
disabling QCARBehaviour is a correct way of disabling ARCamera and Trackers.
However, a more "selective" way of stopping the trackers (and optionally also the ARcamera) is via this API:
ImageTracker imgTracker = TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) as ImageTracker;
imgTracker.Stop();
MarkerTracker mkTracker = TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER) as MarkerTracker;
mkTracker.Stop();
CameraDevice.Instance.Stop();
CameraDevice.Instance.Deinit();
Then if you want to prevent QCAR from restarting the Trackers when the app is resumed, you could use some logic like in this example (you can attach the script to the ARCamera):
public class StopTracker : MonoBehaviour {
private bool mTrackerON = true;
private bool mWasPaused = false;
void OnApplicationPause(bool b) {
Debug.Log ("====== App was Paused ======");
mWasPaused = true;
}
void Update() {
if (mWasPaused) {
// updating after it was paused
// this means we have just resumed
Debug.Log("====== App was just resumed ===== ");
if (!mTrackerON) {
//counter-act default starting of tracker
ImageTracker imgTracker = TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) as ImageTracker;
imgTracker.Stop();
MarkerTracker mkTracker = TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER) as MarkerTracker;
mkTracker.Stop();
CameraDevice.Instance.Stop();
CameraDevice.Instance.Deinit();
Debug.Log("====== Force Stop ARCamera and Trackers ======");
}
mWasPaused = false;
}
}
void OnGUI() {
if (GUI.Button(new Rect(50,50,100,30), "Stop Tracker")) {
// Stop the Trackers and the ARCamera
ImageTracker imgTracker = TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) as ImageTracker;
imgTracker.Stop();
MarkerTracker mkTracker = TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER) as MarkerTracker;
mkTracker.Stop();
CameraDevice.Instance.Stop();
CameraDevice.Instance.Deinit();
mTrackerON = false;
}
if (GUI.Button(new Rect(150,50,100,30), "Start Tracker")) {
// Start the Trackers and ARCamera
CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_DEFAULT);
CameraDevice.Instance.Start();
ImageTracker imgTracker = TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) as ImageTracker;
imgTracker.Start();
MarkerTracker mkTracker = TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER) as MarkerTracker;
mkTracker.Start();
mTrackerON = true;
}
}
}
The basic idea is to detect when the app is paused, and save this event in the mWasPaused boolean; then, when the app is resumeid, as soon as Update() is called you can check if the mWasPaused is true, which means that app was previously paused and now it has been resmed (since Update() is being called);
under this condition, you can then enforce stopping the trackers and the camera.
I've tried this script on Android, but hopefully this should also work on iOS devices.
Hi,
disabling QCARBehaviour is a correct way of disabling ARCamera and Trackers.
However, a more "selective" way of stopping the trackers (and optionally also the ARcamera) is via this API:
Then if you want to prevent QCAR from restarting the Trackers when the app is resumed, you could use some logic like in this example (you can attach the script to the ARCamera):
The basic idea is to detect when the app is paused, and save this event in the mWasPaused boolean; then, when the app is resumeid, as soon as Update() is called you can check if the mWasPaused is true, which means that app was previously paused and now it has been resmed (since Update() is being called);
under this condition, you can then enforce stopping the trackers and the camera.
I've tried this script on Android, but hopefully this should also work on iOS devices.