Beispiel #1
0
        /// <summary>
        /// Returns the TrackableResult that match this trackable.
        /// </summary>
        /// <param name="detectedTrackables">The detected trackables.</param>
        /// <returns>The TrackableResult that match this trackable.</returns>
        internal override TrackableResult FindMatchedTrackable(IEnumerable <TrackableResult> detectedTrackables)
        {
            var detectedVuMarks = detectedTrackables
                                  .Where(tr => tr is VuMarkTargetResult &&
                                         tr.Trackable.Name == this.TrackableName)
                                  .Cast <VuMarkTargetResult>();

            TrackableResult machedTrackable = null;

            foreach (var vtr in detectedVuMarks)
            {
                if (this.IDType == vtr.DataType)
                {
                    if (this.IDType == VuMarkDataTypes.Bytes ||
                        (this.IDType == VuMarkDataTypes.String && vtr.StringValue == this.StringValue) ||
                        (this.IDType == VuMarkDataTypes.Numeric && vtr.NumericValue == this.NumericValue))
                    {
                        machedTrackable = vtr;
                        break;
                    }
                }
            }

            return(machedTrackable);
        }
Beispiel #2
0
        private TrackableResult UpdateWorldCenterResult(out Matrix?cameraTransform)
        {
            TrackableResult result = null;
            Matrix?         additionalTransform = null;

            cameraTransform = null;

            if (this.WorldCenterMode == WorldCenterMode.FirstTarget)
            {
                result = this.TrackableResults.FirstOrDefault();
            }
            else if (this.WorldCenterMode == WorldCenterMode.SpecificTarget &&
                     this.WorldCenterTrackable != null)
            {
                result = this.WorldCenterTrackable.FindMatchedTrackable(this.platformSpecificARService.TrackableResults);

                var resultTransform = this.WorldCenterTrackable.Owner.FindComponent <Transform3D>(false);
                if (resultTransform != null)
                {
                    additionalTransform = Matrix.CreateFromTRS(resultTransform.Position, resultTransform.Orientation, Vector3.One);
                }
            }

            if (result != null)
            {
                cameraTransform = Matrix.Invert(result.Pose);

                if (additionalTransform.HasValue)
                {
                    cameraTransform *= additionalTransform.Value;
                }
            }

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Create a trackable result based on a <see cref="QCAR_TrackableResult"/>.
        /// </summary>
        /// <param name="trackableResult">The Vuforia trackable result</param>
        /// <param name="dataset">The dataset that contains the definition of the targets</param>
        /// <returns>Returns a <see cref="TrackableResult"/>.</returns>
        internal static TrackableResult CreateTrackableResult(QCAR_TrackableResult trackableResult, DataSet dataset)
        {
            TrackableResult result;

            var trackable = dataset.Trackables.First(t => t.Id == trackableResult.TemplateId);

            if (trackable is ImageTarget)
            {
                result = new TrackableResult(trackableResult, trackable);
            }
            else if (trackable is VuMarkTarget)
            {
                result = new VuMarkTargetResult(trackableResult, (VuMarkTarget)trackable);
            }
            else
            {
                throw new NotImplementedException("Invalid target type");
            }

            return(result);
        }