/// <summary> /// Sets the Image Tracker's settings to match the provided settings. /// </summary> /// <param name="customSettings">The new MLImageTracker.Settings wanted.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successfully updated the image tracker settings. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed to update the settings due to invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if failed to update the settings due to lack of privilege(s). /// </returns> public static MLResult UpdateTrackerSettings(MLImageTracker.Settings customSettings) { var currentSettings = GetCurrentTrackerSettings(); Instance.trackerSettings = new NativeBindings.MLImageTrackerSettingsNative(customSettings); MLResult.Code resultCode = NativeBindings.MLImageTrackerUpdateSettings(Instance.handle, ref Instance.trackerSettings); MLResult result = MLResult.Create(resultCode); if (!result.IsOk) { Instance.trackerSettings = new NativeBindings.MLImageTrackerSettingsNative(currentSettings); } return(result); }
/// <summary> /// Starts the image tracker with the defined settings. /// </summary> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to internal invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if image tracker was not created due to lack of privilege(s). /// </returns> public static MLResult Start() { var settings = NativeBindings.MLImageTrackerSettingsNative.Create(); MLResult.Code resultCode = NativeBindings.MLImageTrackerInitSettings(ref settings); MLResult result = MLResult.Create(resultCode); if (result.IsOk) { MLImageTracker.Settings defaultTrackerSettings = MLImageTracker.Settings.Create(settings.MaxSimultaneousTargets); return(Start(defaultTrackerSettings)); } else { return(result); } }
/// <summary> /// Starts the image tracker with the specified settings. /// </summary> /// <param name="customSettings">The settings to start the image tracker with.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to internal invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if image tracker was not created due to lack of privilege(s). /// </returns> public static MLResult Start(MLImageTracker.Settings customSettings) { var settings = new NativeBindings.MLImageTrackerSettingsNative(customSettings); bool hasInstanceWithDifferentSettings = false; if ((MLImageTracker._instance != null) && (settings != MLImageTracker.Instance.trackerSettings)) { MLPluginLog.Warning("MLImageTracker.Start, starting image tracking multiple times with different settings. New settings will be ignored."); hasInstanceWithDifferentSettings = true; } CreateInstance(); if (!hasInstanceWithDifferentSettings) { MLImageTracker.Instance.trackerSettings = settings; } return(MLImageTracker.BaseStart(true)); }
/// <summary> /// Initializes a new instance of the <see cref="MLImageTrackerSettingsNative" /> struct. /// </summary> /// <param name="customSettings">The Image Tracker settings to use.</param> public MLImageTrackerSettingsNative(MLImageTracker.Settings customSettings) { this.MaxSimultaneousTargets = customSettings.MaxSimultaneousTargets; this.EnableTracker = true; }