void Start() { StartCoroutine(HttpLongPollNotification("http://vcm-12481.vm.duke.edu/push/")); MLImageTracker.Start(); MLImageTracker.Enable(); MLImageTracker.AddTarget("sea", imageTarget, 0.279f, (target, result) => { if (!_imageObjectAdded && result.Status == MLImageTargetTrackingStatus.Tracked) { Debug.Log("Image recognized."); DisplayAssets(); _imageObjectAdded = true; } }, true); MLResult camera = MLCamera.Start(); if (camera.IsOk) { MLCamera.Connect(); Debug.Log("Camera Enabled"); } // MLCamera.OnRawImageAvailable += delegate(byte[] jpegBytes) { StartCoroutine(Upload(jpegBytes)); }; // StartCoroutine(Capture()); }
/// <summary> // Adds an image target to be tracked. /// </summary> public static MLImageTargetStarterKit AddTarget(string id, Texture2D texture, float longerDimension, MLImageTracker.Target.OnImageResultDelegate callback, bool isStationary = false) { if (MLImageTracker.IsStarted) { MLImageTargetStarterKit newTargetStarterKit = new MLImageTargetStarterKit(); callback += newTargetStarterKit.HandleStatusUpdates; MLImageTracker.Target newTarget = MLImageTracker.AddTarget(id, texture, longerDimension, callback, isStationary); if (newTarget == null) { Debug.LogErrorFormat("MLImageTrackerStarterKit.AddTarget was unable to create the new image target with id: {0}.", id); return(null); } newTargetStarterKit.InitializeWithTarget(newTarget); return(newTargetStarterKit); } else { Debug.LogError("Error: MLImageTrackerStarterKit.AddTarget failed because MLImageTracker was not started."); return(null); } }
/// <summary> /// Adds a new image target to be tracked. /// </summary> private void AddTarget() { #if PLATFORM_LUMIN _imageTarget = MLImageTracker.AddTarget(gameObject.GetInstanceID().ToString(), image, longerDimensionInSceneUnits, HandleAllTargetStatuses, isStationary); if (_imageTarget == null) { Debug.LogErrorFormat("MLImageTrackerBehavior.AddTarget failed to add target {0} to the image tracker.", gameObject.name); return; } #endif }