[MediaVision] Added supported feature check routine and fixed bugs
authorTae-Young Chung <ty83.chung@samsung.com>
Mon, 17 Apr 2017 05:17:46 +0000 (14:17 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 21 Apr 2017 04:20:54 +0000 (13:20 +0900)
1. Added supported feature check routine to each configuration class
2. Fixed wrong exception throwing
3. Fixed wrong described exception and errata
4. Fixed double dispose() when MediaVisionSource() throws exception

Change-Id: Ia69b9ed1678f930297bcf19bcdc39d2158ddc086
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
19 files changed:
packaging/csapi-multimedia.spec
src/Tizen.Multimedia/MediaVision/BarcodeDetectionConfiguration.cs
src/Tizen.Multimedia/MediaVision/BarcodeGenerationConfiguration.cs
src/Tizen.Multimedia/MediaVision/EngineConfiguration.cs
src/Tizen.Multimedia/MediaVision/FaceDetectionConfiguration.cs
src/Tizen.Multimedia/MediaVision/FaceRecognitionConfiguration.cs
src/Tizen.Multimedia/MediaVision/FaceRecognitionModel.cs
src/Tizen.Multimedia/MediaVision/FaceTrackingModel.cs
src/Tizen.Multimedia/MediaVision/ImageFillConfiguration.cs
src/Tizen.Multimedia/MediaVision/ImageObject.cs
src/Tizen.Multimedia/MediaVision/ImageRecognitionConfiguration.cs
src/Tizen.Multimedia/MediaVision/ImageTracker.cs
src/Tizen.Multimedia/MediaVision/ImageTrackingModel.cs
src/Tizen.Multimedia/MediaVision/MediaVisionError.cs
src/Tizen.Multimedia/MediaVision/MediaVisionSource.cs
src/Tizen.Multimedia/MediaVision/PersonRecognizer.cs
src/Tizen.Multimedia/MediaVision/SurveillanceConfiguration.cs
src/Tizen.Multimedia/MediaVision/SurveillanceEngine.cs
src/Tizen.Multimedia/Tizen.Multimedia.project.json

index 5325faa..485f729 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       csapi-multimedia
 Summary:    Tizen Multimedia API for C#
-Version:    1.0.52
+Version:    1.0.53
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index a02bcc5..832d094 100644 (file)
@@ -28,7 +28,7 @@ namespace Tizen.Multimedia
         /// Initializes a new instance of the <see cref="BarcodeDetectionConfiguration"/> class.
         /// </summary>
         /// <exception cref="System.NotSupportedException">The feature is not supported.</exception>
-        public BarcodeDetectionConfiguration()
+        public BarcodeDetectionConfiguration() : base("barcode_detection")
         {
         }
 
index 88d2cfe..6ccbbb4 100644 (file)
@@ -32,7 +32,7 @@ namespace Tizen.Multimedia
         /// Initializes a new instance of the <see cref="BarcodeGenerationConfiguration"/> class.
         /// </summary>
         /// <exception cref="System.NotSupportedException">The feature is not supported.</exception>
-        public BarcodeGenerationConfiguration()
+        public BarcodeGenerationConfiguration() : base("barcode_generation")
         {
         }
 
index 604f2ba..ef126b1 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 using System;
+using Tizen.System;
 using System.Runtime.InteropServices;
 using static Tizen.Multimedia.Interop.MediaVision;
 
@@ -28,8 +29,42 @@ namespace Tizen.Multimedia
         private IntPtr _handle = IntPtr.Zero;
         private bool _disposed = false;
 
-        internal EngineConfiguration()
+        private const string _featurePath = "http://tizen.org/feature/vision.";
+
+        private bool IsSupportedEngineType(string type)
         {
+            bool isSupported = false;
+
+            string featureType = _featurePath + type;
+
+            bool ret = SystemInfo.TryGetValue(featureType, out isSupported);
+
+            return (isSupported && ret) ? true : false;
+        }
+
+        private bool IsSupportedEngineType(string type1, string type2)
+        {
+            return (IsSupportedEngineType(type1) && IsSupportedEngineType(type2)) ? true : false;
+        }
+
+        internal EngineConfiguration(string engineType)
+        {
+            if (IsSupportedEngineType(engineType) == false)
+            {
+                throw new NotSupportedException($"{engineType} : Not Supported");
+            }
+
+            EngineConfig.Create(out _handle).Validate("Failed to create media vision engine.");
+        }
+
+        internal EngineConfiguration(string engineType1, string engineType2)
+        {
+
+            if (IsSupportedEngineType(engineType1, engineType2) == false)
+            {
+                throw new NotSupportedException($"{engineType1} or {engineType2} : Not Supported");
+            }
+
             EngineConfig.Create(out _handle).Validate("Failed to create media vision engine.");
         }
 
index 510219d..fedb11a 100644 (file)
@@ -35,7 +35,7 @@ namespace Tizen.Multimedia
         /// Initializes a new instance of the <see cref="FaceDetectionConfiguration"/> class.
         /// </summary>
         /// <exception cref="NotSupportedException">The feature is not supported.</exception>
-        public FaceDetectionConfiguration()
+        public FaceDetectionConfiguration() : base("face_recognition")
         {
         }
 
index 56b2049..581e6b2 100644 (file)
@@ -27,7 +27,7 @@ namespace Tizen.Multimedia
         /// Initializes a new instance of the <see cref="FaceRecognitionConfiguration"/> class.
         /// </summary>
         /// <exception cref="System.NotSupportedException">The feature is not supported.</exception>
-        public FaceRecognitionConfiguration()
+        public FaceRecognitionConfiguration() : base("face_recognition")
         {
         }
 
index bccb800..7b8b9e9 100644 (file)
@@ -155,7 +155,7 @@ namespace Tizen.Multimedia
         {
             if (source == null)
             {
-                throw new ArgumentException("Invalid source");
+                throw new ArgumentNullException(nameof(source));
             }
 
             InvokeAdd(source, label, null).Validate("Failed to add face example image");
@@ -180,7 +180,7 @@ namespace Tizen.Multimedia
         {
             if (source == null)
             {
-                throw new ArgumentException("Invalid source");
+                throw new ArgumentNullException(nameof(source));
             }
 
             InvokeAdd(source, label, area).Validate("Failed to add face example image");
index bddeac3..2d26630 100644 (file)
@@ -45,7 +45,7 @@ namespace Tizen.Multimedia
         /// </remarks>
         /// <param name="modelPath">Path to the model to load.</param>
         /// <exception cref="ArgumentNullException"><paramref name="modelPath"/> is null.</exception>
-        /// <exception cref="System.IO.FileNotFoundException"><paramref name="modelPath"/> is invalid.</exception>
+        /// <exception cref="FileNotFoundException"><paramref name="modelPath"/> is invalid.</exception>
         /// <exception cref="NotSupportedException">
         ///     The feature is not supported.\n
         ///     - or -\n
@@ -88,6 +88,7 @@ namespace Tizen.Multimedia
         /// </summary>
         /// <remarks>
         /// <paramref name="region"/> needs to be the position of the face to be tracked when called first time for the tracking model.
+        /// <paramref name="region"/> is fitted to the valid region of <paramref name="source"/> if <paramref name="region"/> has invalid points.
         /// </remarks>
         /// <param name="source">The source where face location is specified.
         ///     Usually it is the first frame of the video or the first image in the continuous
@@ -95,7 +96,6 @@ namespace Tizen.Multimedia
         /// <param name="region">The region determining position of the face to be tracked on the source.
         ///     If null, then tracking model will try to find previously tracked face by itself.</param>
         /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
-        /// <exception cref="ArgumentException"><paramref name="region"/> has invalid points.</exception>
         /// <exception cref="ObjectDisposedException">
         ///     The <see cref="FaceTrackingModel"/> has already been disposed of.\n
         ///     - or -\n
index 27d1c86..d83a280 100644 (file)
@@ -38,7 +38,7 @@ namespace Tizen.Multimedia
         /// Initializes a new instance of the <see cref="ImageFillConfiguration"/> class.
         /// </summary>
         /// <exception cref="System.NotSupportedException">The feature is not supported.</exception>
-        public ImageFillConfiguration()
+        public ImageFillConfiguration() : base("image_recognition")
         {
         }
 
index 9974f42..d186639 100644 (file)
@@ -153,7 +153,7 @@ namespace Tizen.Multimedia
         ///     <paramref name="source"/> has already been disposed of.\n
         ///     - or -\n
         ///     <paramref name="config"/> has already been disposed of.
-        /// </exception
+        /// </exception>
         public void Fill(MediaVisionSource source, ImageFillConfiguration config)
         {
             InvokeFill(source, config, null);
@@ -170,7 +170,7 @@ namespace Tizen.Multimedia
         ///     The <see cref="ImageObject"/> has already been disposed of.\n
         ///     - or -\n
         ///     <paramref name="source"/> has already been disposed of.\n
-        /// </exception
+        /// </exception>
         public void Fill(MediaVisionSource source, Rectangle rect)
         {
             InvokeFill(source, null, rect);
@@ -190,7 +190,7 @@ namespace Tizen.Multimedia
         ///     <paramref name="source"/> has already been disposed of.\n
         ///     - or -\n
         ///     <paramref name="config"/> has already been disposed of.
-        /// </exception
+        /// </exception>
         public void Fill(MediaVisionSource source, ImageFillConfiguration config, Rectangle rect)
         {
             InvokeFill(source, config, rect);
@@ -208,19 +208,6 @@ namespace Tizen.Multimedia
             return InteropImage.Fill(Handle, config, source, ref rect);
         }
 
-        /// <summary>
-        /// Fills the image object.\n
-        /// Extracts data from @a source image which will be needed for recognition of depicted object in @a location.
-        /// </summary>
-        /// <param name="source">The source image where image object is depicted.</param>
-        /// <param name="config">The configuration used for extract recognition data from source. This value can be null.</param>
-        /// <param name="area">Location of the image object on the source image, or NULL if the object is shown in full</param>
-        /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
-        /// <exception cref="ObjectDisposedException">
-        ///     The <see cref="ImageObject"/> has already been disposed of.\n
-        ///     - or -\n
-        ///     <paramref name="source"/> has already been disposed of.
-        /// </exception
         private void InvokeFill(MediaVisionSource source, ImageFillConfiguration config, Rectangle? area)
         {
             if (source == null)
index 687e494..e75cf6c 100644 (file)
@@ -59,7 +59,7 @@ namespace Tizen.Multimedia
         /// Initializes a new instance of the <see cref="ImageRecognitionConfiguration"/> class.
         /// </summary>
         /// <exception cref="NotSupportedException">The feature is not supported.</exception>
-        public ImageRecognitionConfiguration()
+        public ImageRecognitionConfiguration() : base("image_recognition")
         {
         }
 
index 1ca7170..7ec69e3 100644 (file)
@@ -43,7 +43,7 @@ namespace Tizen.Multimedia
         ///     - or -\n
         ///     <paramref name="trackingModel"/> has already been disposed of.
         /// </exception>
-        /// <exception cref="InvalidOperationException"><paramref name="trackingModel"/> has no target.</exception>
+        /// <exception cref="ArgumentException"><paramref name="trackingModel"/> has no target.</exception>
         /// <seealso cref="ImageTrackingModel.SetTarget(ImageObject)"/>
         public static async Task<Quadrangle> TrackAsync(MediaVisionSource source,
             ImageTrackingModel trackingModel)
@@ -71,7 +71,7 @@ namespace Tizen.Multimedia
         ///     - or -\n
         ///     <paramref name="config"/> has already been disposed of.
         /// </exception>
-        /// <exception cref="InvalidOperationException"><paramref name="trackingModel"/> has no target.</exception>
+        /// <exception cref="ArgumentException"><paramref name="trackingModel"/> has no target.</exception>
         /// <seealso cref="ImageTrackingModel.SetTarget(ImageObject)"/>
         public static async Task<Quadrangle> TrackAsync(MediaVisionSource source,
             ImageTrackingModel trackingModel, ImageTrackingConfiguration config)
index add2130..7d4f14e 100644 (file)
@@ -45,7 +45,7 @@ namespace Tizen.Multimedia
         /// </remarks>
         /// <param name="modelPath">Path to the model to load.</param>
         /// <exception cref="ArgumentNullException"><paramref name="modelPath"/> is null.</exception>
-        /// <exception cref="System.IO.FileNotFoundException"><paramref name="modelPath"/> is invalid.</exception>
+        /// <exception cref="FileNotFoundException"><paramref name="modelPath"/> is invalid.</exception>
         /// <exception cref="NotSupportedException">
         ///     The feature is not supported.\n
         ///     - or -\n
index 4de8705..8298cfd 100644 (file)
@@ -66,7 +66,7 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Permission denied
         /// </summary>
-        PermissionDenied = ErrorCode.PermissionDenied,
+        PermissionDenied = ErrorCode.NotPermitted,
         /// <summary>
         /// Not supported format
         /// </summary>
index 04c7068..3932b2a 100644 (file)
@@ -43,6 +43,7 @@ namespace Tizen.Multimedia
             catch(Exception)
             {
                 InteropSource.Destroy(_handle);
+                _disposed = true;
                 throw;
             }
         }
@@ -202,7 +203,6 @@ namespace Tizen.Multimedia
             {
                 return;
             }
-
             InteropSource.Destroy(_handle);
             _disposed = true;
         }
index a6cb655..ca2bdee 100644 (file)
@@ -104,7 +104,7 @@ namespace Tizen.Multimedia
         ///     - or -\n
         ///     <paramref name="config"/> has already been disposed of.
         /// </exception>
-        /// <exception cref="System.IO.FileNotFoundException">
+        /// <exception cref="ArgumentException">
         /// <see cref="PersonRecognitionConfiguration.FaceRecognitionModelPath"/> of <paramref name="config"/> does not exists.
         /// </exception>
         /// <exception cref="UnauthorizedAccessException">
index 3024ae2..8f1aae3 100644 (file)
@@ -21,7 +21,7 @@ namespace Tizen.Multimedia
     /// </summary>
     public class SurveillanceEngineConfiguration : EngineConfiguration
     {
-        internal SurveillanceEngineConfiguration()
+        internal SurveillanceEngineConfiguration() : base("face_recognition", "image_recognition")
         {
         }
     }
index 37023f4..19518be 100644 (file)
@@ -101,9 +101,6 @@ namespace Tizen.Multimedia
         internal abstract void OnEventDetected(IntPtr trigger, IntPtr source,
             int streamId, IntPtr eventResult, IntPtr userData);
 
-        /// <summary>
-        /// Subscribes trigger to process sources pushed from video identified by @a videoStreamId.
-        /// </summary>
         internal void InvokeAddSource(SurveillanceSource source, SurveillanceEngineConfiguration config)
         {
             if (source == null)
index d7fdcc7..f1eae2a 100755 (executable)
@@ -3,7 +3,8 @@
     "ElmSharp": "1.1.0-*",
     "NETStandard.Library": "1.6.1",
     "Tizen": "1.0.3",
-    "Tizen.Applications": "1.3.2"
+    "Tizen.Applications": "1.3.2",
+    "Tizen.System.Information": "1.0.3"
   },
   "frameworks": {
     "netstandard1.3": {}