Beispiel #1
0
        /// <summary>
        /// Tracks the given image tracking model on the current frame and <see cref="ImageTrackingConfiguration"/>.
        /// </summary>
        /// <param name="source">The current image of sequence where the image tracking model will be tracked.</param>
        /// <param name="trackingModel">The image tracking model which processed as target of tracking.</param>
        /// <param name="config">The configuration used for tracking. This value can be null.</param>
        /// <returns>A task that represents the asynchronous tracking operation.</returns>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="source"/> is null.<br/>
        ///     -or-<br/>
        ///     <paramref name="trackingModel"/> is null.
        /// </exception>
        /// <exception cref="NotSupportedException">The feature is not supported.</exception>
        /// <exception cref="ObjectDisposedException">
        ///     <paramref name="source"/> has already been disposed of.<br/>
        ///     -or-<br/>
        ///     <paramref name="trackingModel"/> has already been disposed of.<br/>
        ///     -or-<br/>
        ///     <paramref name="config"/> has already been disposed of.
        /// </exception>
        /// <exception cref="ArgumentException"><paramref name="trackingModel"/> has no target.</exception>
        /// <seealso cref="ImageTrackingModel.SetTarget(ImageObject)"/>
        /// <feature>http://tizen.org/feature/vision.image_recognition</feature>
        /// <since_tizen> 4 </since_tizen>
        public static async Task <Quadrangle> TrackAsync(MediaVisionSource source,
                                                         ImageTrackingModel trackingModel, ImageTrackingConfiguration config)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (trackingModel == null)
            {
                throw new ArgumentNullException(nameof(trackingModel));
            }

            TaskCompletionSource <Quadrangle> tcs = new TaskCompletionSource <Quadrangle>();

            using (var cb = ObjectKeeper.Get(GetCallback(tcs)))
            {
                InteropImage.Track(source.Handle, trackingModel.Handle, EngineConfiguration.GetHandle(config),
                                   cb.Target).Validate("Failed to perform image tracking.");

                return(await tcs.Task);
            }
        }