Doing SLAM and image target at the same time..

+4 votes
asked Jan 16, 2018 by amartinez (160 points)
edited Jan 16, 2018 by amartinez

I had tried to implement both of the samples given for Multi targets and SLAM..
so this is the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EasyAR;

private GameObject arSceneTracker;
    private ARSceneTrackerBehaviour arSceneBaseBehaviour;
    private void Awake()
    {
        EasyARBehaviour easyARBehaviour = FindObjectOfType<EasyARBehaviour>();
        easyARBehaviour.Initialize();
        arSceneTracker = new GameObject("ARSceneTracker");
        arSceneTracker.transform.parent = transform;
        //plus multi target
       
        foreach (var behaviour in ARBuilder.Instance.ARCameraBehaviours)
        {
            behaviour.TargetFound += OnTargetFound;
            behaviour.TargetLost += OnTargetLost;
        }
        foreach (var behaviour in ARBuilder.Instance.ImageTrackerBehaviours)
        {
            behaviour.TargetLoad += OnTargetLoad;
            behaviour.TargetUnload += OnTargetUnload;
        }
        foreach (var behaviour in ARBuilder.Instance.ObjectTrackerBehaviours)
        {
            behaviour.TargetLoad += OnTargetLoad;
            behaviour.TargetUnload += OnTargetUnload;
        }

    }
    public void StartSLAM()
    {
        arSceneBaseBehaviour = arSceneTracker.AddComponent<ARSceneTrackerBehaviour>();
        arSceneBaseBehaviour.Bind(ARBuilder.Instance.CameraDeviceBehaviours[0]);
        arSceneBaseBehaviour.StartTrack();
    }
    public void StopSLAM()
    {
        arSceneBaseBehaviour.StopTrack();
        DestroyImmediate(arSceneBaseBehaviour);
    }

    void OnTargetFound(ARCameraBaseBehaviour arcameraBehaviour, TargetAbstractBehaviour targetBehaviour, Target target)
    {
        Debug.Log("<Global Handler> Found: " + target.Id);
    }

    void OnTargetLost(ARCameraBaseBehaviour arcameraBehaviour, TargetAbstractBehaviour targetBehaviour, Target target)
    {
        Debug.Log("<Global Handler> Lost: " + target.Id);
    }

    void OnTargetLoad(ImageTrackerBaseBehaviour trackerBehaviour, ImageTargetBaseBehaviour targetBehaviour, Target target, bool status)
    {
        Debug.Log("<Global Handler> Load target (" + status + "): " + target.Id + " (" + target.Name + ") " + " -> " + trackerBehaviour);
    }

    void OnTargetUnload(ImageTrackerBaseBehaviour trackerBehaviour, ImageTargetBaseBehaviour targetBehaviour, Target target, bool status)
    {
        Debug.Log("<Global Handler> Unload target (" + status + "): " + target.Id + " (" + target.Name + ") " + " -> " + trackerBehaviour);
    }

    void OnTargetLoad(ObjectTrackerBaseBehaviour trackerBehaviour, ObjectTargetBaseBehaviour targetBehaviour, Target target, bool status)
    {
        Debug.Log("<Global Handler> Load target (" + status + "): " + target.Id + " (" + target.Name + ") " + " -> " + trackerBehaviour);
    }

    void OnTargetUnload(ObjectTrackerBaseBehaviour trackerBehaviour, ObjectTargetBaseBehaviour targetBehaviour, Target target, bool status)
    {
        Debug.Log("<Global Handler> Unload target (" + status + "): " + target.Id + " (" + target.Name + ") " + " -> " + trackerBehaviour);
    }

the first thing i notice is that for these two to work together I need to scan the image first(Image Tracking/ Image Target) then I can start the SLAM application. If I start the SLAM application first before I scan the image target, the image target will not work. My question is: Is there a way for me for these two to work at the same time or simultaneously?
 

*edit

In addition,

a. Scanning the image first, then starting the SLAM application

- If I accidentally lost the image target (either due to some lighting or etc..) i can't scan the image target again. I need to stop the SLAM application first before I can make the image target work.

1 Answer

0 votes
answered Nov 19, 2018 by arhitcsg (140 points)
I am almost looking for the same thing to do but with cloud recognition and SLAM did you find any solution for your problem ?
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...