[MediaVision][TCSACR-504] Add new APIs for deep learning face recognition 06/282206/8
authorHaesu Gwon <haesu.gwon@samsung.com>
Wed, 28 Sep 2022 07:17:13 +0000 (16:17 +0900)
committerTan Nguyen <nguyen.vtan@samsung.com>
Wed, 12 Oct 2022 07:41:34 +0000 (07:41 +0000)
Change-Id: I5835d2a08cbd5c22b88915a69d2605b30b87c268

tct-suite-vs/Tizen.MediaVision.Tests/res/copy_res.sh [new file with mode: 0755]
tct-suite-vs/Tizen.MediaVision.Tests/res/face_recognition/backbone/facenet.tflite [new file with mode: 0644]
tct-suite-vs/Tizen.MediaVision.Tests/shared/res/copy_res.sh [new file with mode: 0644]
tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSDeepLearningFaceRecognizer.cs [new file with mode: 0644]

diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/res/copy_res.sh b/tct-suite-vs/Tizen.MediaVision.Tests/res/copy_res.sh
new file mode 100755 (executable)
index 0000000..004e6a1
--- /dev/null
@@ -0,0 +1,36 @@
+LOCATION='/home/owner/share'
+# Change the destination of the resource folder(absolute path).
+DESTINATION='/home/owner/media'
+
+# Change the list of the files in the resource folder.
+FILE_LIST=(
+)
+
+# Change the list of the directories in the resource folder.
+DIR_LIST=(
+    'res'
+)
+
+if [ "$1" == "-i" ]
+then
+    for value in "${FILE_LIST[@]}";do
+        cp $LOCATION/$value $DESTINATION
+    done
+    # Copy resource for DeepLearningFaceRecognizer
+    for value in "${DIR_LIST[@]}";do
+        cp -R $LOCATION/$value $DESTINATION
+    done
+    # create training directioy for DeepLearningFaceRecognizer
+    mkdir -p $DESTINATION/'res/face_recognition/training'
+elif [ "$1" == "-u" ]
+then
+    for value in "${FILE_LIST[@]}";do
+        rm $DESTINATION/$value
+    done
+    for value in "${DIR_LIST[@]}";do
+        rm -rf $DESTINATION/$value
+    done
+else
+    echo "===> Please enter -i for install or -u for uninstall!"
+    exit
+fi
diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/res/face_recognition/backbone/facenet.tflite b/tct-suite-vs/Tizen.MediaVision.Tests/res/face_recognition/backbone/facenet.tflite
new file mode 100644 (file)
index 0000000..4c19477
Binary files /dev/null and b/tct-suite-vs/Tizen.MediaVision.Tests/res/face_recognition/backbone/facenet.tflite differ
diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/shared/res/copy_res.sh b/tct-suite-vs/Tizen.MediaVision.Tests/shared/res/copy_res.sh
new file mode 100644 (file)
index 0000000..1b4c254
--- /dev/null
@@ -0,0 +1,33 @@
+LOCATION='/opt/usr/globalapps/Tizen.MediaVision.Tests/shared'
+# Change the destination of the resource folder for face recognition.
+DESTINATION='/home/owner/media'
+
+# Change the list of the files in the resource folder.
+FILE_LIST=(
+)
+
+# Change the list of the directories in the resource folder.
+DIR_LIST=(
+    'res/face_recognition/backbone'
+)
+
+if [ "$1" == "-i" ]
+then
+    for value in "${FILE_LIST[@]}";do
+        cp $LOCATION/$value $DESTINATION
+    done
+    for value in "${DIR_LIST[@]}";do
+        cp -R $LOCATION/$value $DESTINATION
+    done
+elif [ "$1" == "-u" ]
+then
+    for value in "${FILE_LIST[@]}";do
+        rm $DESTINATION/$value
+    done
+    for value in "${DIR_LIST[@]}";do
+        rm -rf $DESTINATION/$value
+    done
+else
+    echo "===> Please enter -i for install or -u for uninstall!"
+    exit
+fi
diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSDeepLearningFaceRecognizer.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSDeepLearningFaceRecognizer.cs
new file mode 100644 (file)
index 0000000..33f5422
--- /dev/null
@@ -0,0 +1,235 @@
+// Copyright 2022 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+    [TestFixture]
+    [Description("Tizen.Multimedia.Vision.DeepLearningFaceRecognizer test class")]
+    public class DeepLearningFaceRecognizerTests
+    {
+        private DeepLearningFaceRecognizer _recognizer;
+        private MediaVisionSource _source;
+
+        private async Task PrepareModelAndSourceAsync()
+        {
+            _source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/04.jpg");
+        }
+
+        [SetUp]
+        public void Init()
+        {
+            try
+            {
+                Task t = Task.Run(async () => await PrepareModelAndSourceAsync());
+                t.Wait();
+
+                _recognizer = new DeepLearningFaceRecognizer();
+            }
+            catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false)
+            {
+                Assert.Pass("Face recognition is not supported");
+            }
+        }
+
+        [TearDown]
+        public void Destroy()
+        {
+            _recognizer?.Dispose();
+            _source?.Dispose();
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Object should not be null after initializing")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.DeepLearningFaceRecognizer C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void DeepLearningFaceRecognizer_INIT()
+        {
+            var recognizer = new DeepLearningFaceRecognizer();
+
+            Assert.IsNotNull(recognizer, "Should not be null");
+            Assert.IsInstanceOf<DeepLearningFaceRecognizer>(recognizer, "It should be the instance of DeepLearningFaceRecognizer.");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test RegisterFace whether throws exception or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.RegisterFace M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void RegisterFace_NO_EXCEPTION()
+        {
+             Assert.That(() => _recognizer.RegisterFace(_source, "tc_test"), Throws.Nothing,
+                "Should not throw exception");
+
+            _recognizer.UnregisterFace("tc_test");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test RegisterFace whether throws ObjectDisposedException if DeepLearningFaceRecognizer is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.RegisterFace M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void RegisterFace_THROWS_IF_ALREADY_DISPOSED()
+        {
+            _recognizer.Dispose();
+
+            Assert.That(() => _recognizer.RegisterFace(_source, "test"),
+                Throws.TypeOf<ObjectDisposedException>(), "Should throw ObjectDisposedException");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test RegisterFace whether throws ArgumentNullException if argument is null.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.RegisterFace M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void RegisterFace_THROWS_IF_NULL_PARAM()
+        {
+            Assert.That(() => _recognizer.RegisterFace(null, "test"),
+                Throws.ArgumentNullException, "Should throw ArgumentNullException");
+
+            Assert.That(() => _recognizer.RegisterFace(_source, null),
+                Throws.ArgumentNullException, "Should throw ArgumentNullException");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test UnregisterFace whether throws exception or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.UnregisterFace M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void UnregisterFace_NO_EXCEPTION()
+        {
+            _recognizer.RegisterFace(_source, "tc_test");
+
+             Assert.That(() => _recognizer.UnregisterFace("tc_test"), Throws.Nothing,
+                "Should not throw exception");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test UnregisterFace whether throws ObjectDisposedException if DeepLearningFaceRecognizer is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.UnregisterFace M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void UnregisterFace_THROWS_IF_ALREADY_DISPOSED()
+        {
+            _recognizer.RegisterFace(_source, "tc_test");
+
+            _recognizer.Dispose();
+
+            Assert.That(() => _recognizer.UnregisterFace("tc_test"),
+                Throws.TypeOf<ObjectDisposedException>(), "Should throw ObjectDisposedException");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test UnregisterFace whether throws ArgumentNullException if argument is null.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.UnregisterFace M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void UnregisterFace_THROWS_IF_NULL_PARAM()
+        {
+            Assert.That(() => _recognizer.UnregisterFace(null),
+                Throws.ArgumentNullException, "Should throw ArgumentNullException");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test Recognize whether throws exception or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.Recognize M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Recognize_NO_EXCEPTION()
+        {
+            _recognizer.RegisterFace(_source, "tc_test");
+
+            Assert.That(() => _recognizer.Recognize(_source), Throws.Nothing,
+                "Should not throw exception");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test Recognize whether throws ObjectDisposedException if DeepLearningFaceRecognizer is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.Recognize M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Recognize_THROWS_IF_ALREADY_DISPOSED()
+        {
+            _recognizer.RegisterFace(_source, "tc_test");
+
+            _recognizer.Dispose();
+
+            Assert.That(() => _recognizer.Recognize(_source),
+                Throws.TypeOf<ObjectDisposedException>(), "Should throw ObjectDisposedException");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test Recognize whether throws ArgumentNullException if argument is null.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognizer.Recognize M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Recognize_THROWS_IF_NULL_PARAM()
+        {
+            _recognizer.RegisterFace(_source, "tc_test");
+
+            Assert.That(() => _recognizer.Recognize(null),
+                Throws.ArgumentNullException, "Should throw ArgumentNullException");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether Label returns expected value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognitionResult.Label M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Label_READ_ONLY()
+        {
+            _recognizer.RegisterFace(_source, "tc_test");
+            var result = _recognizer.Recognize(_source);
+
+            Assert.That(() => result.Label, Throws.Nothing,
+                "Should not throw nothing");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether ToString returns expected value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Vision.DeepLearningFaceRecognitionResult.ToString M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void ToString_CHECK_VALUE()
+        {
+            _recognizer.RegisterFace(_source, "tc_test");
+            var result = _recognizer.Recognize(_source);
+
+            Assert.AreEqual($"Label={result.Label}", result.ToString(),
+                "Should be same string");
+        }
+    }
+}