Log in or register to post comments

Video Playback+Cloud AR Need Help !! Please

July 14, 2017 - 10:24am #1

Hello Everyone,

im new here and im new with Augmented Reality

currently, im working with my last project in colleg my project is combine 3D Object and Video in one app (android) using cloud AR and I have 3 days left to finish it.

Im  reallty stuck day by day, I confuse how to add video playback + cloud recognition Augmented Reality.

I've search out there, but I Can't any tutorial how to make video playback+Cloud AR, many of the tutorials is about Video Playback+AR (not with Cloud)

what should I do ?  can anyone teach me how to add videoplayback with cloud recognition ? please..

 

in my project im using the "SimpleCloudHandler.cs", the  script will recognize the trackable name  on image target  with the metadata in the vuforia cloud database, example :

if am using the trackable name "Cube' on image target so the metadata must be "Cube"  and then show the 3D content according by each marker.

and here the script :

 

using System;
using UnityEngine;
using Vuforia;
using UnityEngine.UI;

/// <summary>
/// This MonoBehaviour implements the Cloud Reco Event handling for this sample.
/// It registers itself at the CloudRecoBehaviour and is notified of new search results.
/// </summary>
public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler
{
#region PRIVATE_MEMBER_VARIABLES

// CloudRecoBehaviour reference to avoid lookups
private CloudRecoBehaviour mCloudRecoBehaviour;
// ImageTracker reference to avoid lookups
private ObjectTracker mImageTracker;

private bool mIsScanning = false;

private string mTargetMetadata = "";

#endregion // PRIVATE_MEMBER_VARIABLES

public AudioSource dubbing1;



#region EXPOSED_PUBLIC_VARIABLES

/// <summary>
/// can be set in the Unity inspector to reference a ImageTargetBehaviour that is used for augmentations of new cloud reco results.
/// </summary>
public ImageTargetBehaviour ImageTargetTemplate;

#endregion

#region UNTIY_MONOBEHAVIOUR_METHODS

/// <summary>
/// register for events at the CloudRecoBehaviour
/// </summary>
void Start()
{
  // register this event handler at the cloud reco behaviour
  CloudRecoBehaviour cloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
  if (cloudRecoBehaviour)
  {
   cloudRecoBehaviour.RegisterEventHandler(this);
  }

  // remember cloudRecoBehaviour for later
  mCloudRecoBehaviour = cloudRecoBehaviour;

}

#endregion // UNTIY_MONOBEHAVIOUR_METHODS


#region ICloudRecoEventHandler_IMPLEMENTATION

/// <summary>
/// called when TargetFinder has been initialized successfully
/// </summary>
public void OnInitialized()
{
  // get a reference to the Image Tracker, remember it
  mImageTracker = (ObjectTracker)TrackerManager.Instance.GetTracker<ObjectTracker>();
}

/// <summary>
/// visualize initialization errors
/// </summary>
public void OnInitError(TargetFinder.InitState initError)
{
}

/// <summary>
/// visualize update errors
/// </summary>
public void OnUpdateError(TargetFinder.UpdateState updateError)
{
}

/// <summary>
/// when we start scanning, unregister Trackable from the ImageTargetTemplate, then delete all trackables
/// </summary>
public void OnStateChanged(bool scanning) {
  mIsScanning = scanning;
  if (scanning) {
   // clear all known trackables
   ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker> ();
   tracker.TargetFinder.ClearTrackables (false);
  }
}

/// <summary>
/// Handles new search results
/// </summary>
/// <param name="targetSearchResult"></param>
public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
{
  // duplicate the referenced image target
  GameObject newImageTarget = Instantiate(ImageTargetTemplate.gameObject) as GameObject;

  GameObject augmentation = null;

  string model_name = targetSearchResult.MetaData;


  if( augmentation != null )
   augmentation.transform.parent = newImageTarget.transform;

  // enable the new result with the same ImageTargetBehaviour:
  ImageTargetAbstractBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, newImageTarget);

  Debug.Log("Metadata value is " + model_name );
  mTargetMetadata = model_name;


  switch( model_name ){

  case "prasasti_telaga_batu":

   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_kudukan_bukit").gameObject);
   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_boom_baru").gameObject);
   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_talang_tuo").gameObject);
   break;

  case "prasasti_kudukan_bukit":

   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_telaga_batu").gameObject);
   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_boom_baru").gameObject);
   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_talang_tuo").gameObject);
   break;


  case "prasasti_boom_baru":

   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_telaga_batu").gameObject);
   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_kudukan_bukit").gameObject);
   Destroy (imageTargetBehaviour.gameObject.transform.Find ("prasasti_talang_tuo").gameObject);
   break;
  
}

  if (!mIsScanning)
  {
   // stop the target finder
   mCloudRecoBehaviour.CloudRecoEnabled = true;
  }
}


#endregion // ICloudRecoEventHandler_IMPLEMENTATION

void OnGUI() {
  GUI.Box (new Rect(100,200,200,50), "Metadata: " + mTargetMetadata);
}



}

Please, anyone can help me ? I really Appreciate if you guys can help me..

what should I do ?, Should I Change the code in "SimpleCloudHandler" or in "DefaultTrackableHandler" on image target ?

Thank you for your attention, and sorry for my bad englis guys.

Log in or register to post comments