--- /dev/null
+Apple
+Backpack
+Balloon
+Banana
+Barrel
+Baseball_bat
+Beer
+Bench
+Bicycle
+Book
+Bookcase
+Boot
+Camel
+Camera
+Cannon
+Canoe
+Car
+Castle
+Coat
+Computer_keyboard
+Cosmetics
+Couch
+Cowboy_hat
+Crab
+Cucumber
+Desk
+Dog
+Doll
+Door
+Dragonfly
+Drum
+Earrings
+Football
+Fountain
+Frog
+Guitar
+Ice_cream
+Jacket
+Jellyfish
+Kite
+Lamp
+Lemon
+Lipstick
+Mushroom
+Necklace
+Orange
+Parachute
+Pillow
+Pizza
+Rabbit
+Sandal
+Saxophone
+Scarf
+Shirt
+Shorts
+Snake
+Sock
+Spoon
+Strawberry
+Suit
+Sunglasses
+Surfboard
+Tank
+Taxi
+Television
+Tent
+Tie
+Tiger
+Traffic_light
+Train
+Umbrella
+Whale
+Wheel
+Wine
--- /dev/null
+Car
+Wheel
+Suit
+Dog
+Guitar
+Bicycle
+Sunglasses
+Door
+Jacket
+Train
+Desk
+Drum
+Book
+Tie
+Shorts
+Shirt
+Camera
+Wine
+Beer
+Football
+Castle
+Bench
+Coat
+Tent
+Bookcase
+Doll
+Umbrella
+Computer_keyboard
+Couch
+Balloon
+Fountain
+Television
+Necklace
+Canoe
+Scarf
+Cowboy_hat
+Mushroom
+Traffic_light
+Surfboard
+Lamp
+Ice_cream
+Taxi
+Boot
+Frog
+Dragonfly
+Sandal
+Strawberry
+Pizza
+Pillow
+Snake
+Rabbit
+Baseball_bat
+Lipstick
+Apple
+Tank
+Parachute
+Spoon
+Tiger
+Orange
+Saxophone
+Cosmetics
+Cannon
+Camel
+Miniskirt
+Crab
+Jellyfish
+Banana
+Backpack
+Whale
+Sock
+Lemon
+Earrings
[Test]
[Category("P2")]
[Description("Tests throwing null argument exception when null parameter of source is given")]
- [Property("SPEC", "Tizen.Multimedia.Vision.arcodeDetector.DetectAsync M")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.BarcodeDetector.DetectAsync M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
--- /dev/null
+// Copyright 2019 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.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Multimedia.Vision.FaceDetectionResult test class")]
+ public class FaceDetectionResultTests : InferenceFaceTestBase
+ {
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Confidence returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FaceDetectionResult.Confidence A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Confidence_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/face_detector/fd.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _fdConfig.LoadInferenceModel();
+
+ var fdResult = await FaceDetector.DetectAsync(source, _fdConfig);
+ Assert.IsInstanceOf<IEnumerable<FaceDetectionResult>>(fdResult, "It should be created.");
+
+ foreach (var result in fdResult)
+ {
+ Assert.IsInstanceOf<float>(result.Confidence, "It should be created.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Location returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FaceDetectionResult.Location A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Location_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/face_detector/fd.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _fdConfig.LoadInferenceModel();
+
+ var fdResult = await FaceDetector.DetectAsync(source, _fdConfig);
+ Assert.IsInstanceOf<IEnumerable<FaceDetectionResult>>(fdResult, "It should be created.");
+
+ foreach (var result in fdResult)
+ {
+ Assert.IsInstanceOf<Rectangle>(result.Location, "It should be created.");
+ }
+ }
+ }
+ }
+}
// you entered into with Samsung.
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
namespace Tizen.Multimedia.Vision.Tests
{
[TestFixture]
[Description("Tizen.Multimedia.Vision.FaceDetector test class")]
- public class FaceDetectorTests
+ public partial class FaceDetectorTests
{
- private FaceDetectionConfiguration _config = null;
+ private FaceDetectionConfiguration _config;
+ private InferenceModelConfiguration _fdConfig;
+ private bool _isFaceRecognitionSupported = true;
+ private bool _isInferenceSupported = true;
[SetUp]
public void Init()
}
catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false)
{
- Assert.Pass("FaceRecognition is not supported");
+ _isFaceRecognitionSupported = false;
+ }
+
+ try
+ {
+ _fdConfig = new InferenceModelConfiguration();
+ }
+ catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.Inference) == false ||
+ FeatureChecker.IsSupported(Features.InferenceFaceDetection) == false)
+ {
+ _isInferenceSupported = false;
+ }
+
+ if (_fdConfig.SupportedBackend.Any())
+ {
+ _fdConfig.WeightFilePath = TestHelper.TFLitePath + "face_detector/fd_tflite_model1.tflite";
+ _fdConfig.MeanValue = 127.5;
+ _fdConfig.StdValue = 127.5;
+ _fdConfig.ConfidenceThreshold = 0.3;
+ _fdConfig.Backend = InferenceBackendType.TFLite;
+ _fdConfig.Target = InferenceTargetType.CPU;
+ _fdConfig.TensorSize = new Size(300, 300);
+ _fdConfig.TensorChannels = 3;
+ _fdConfig.InputNodeName = "normalized_input_image_tensor";
+ _fdConfig.OutputNodeName = new string[]
+ {
+ "TFLite_Detection_PostProcess",
+ "TFLite_Detection_PostProcess:1",
+ "TFLite_Detection_PostProcess:2",
+ "TFLite_Detection_PostProcess:3"
+ };
+ }
+ else
+ {
+ _isInferenceSupported = false;
}
}
[TearDown]
public void Destroy()
{
+ _isFaceRecognitionSupported = true;
+ _isInferenceSupported = true;
+
_config?.Dispose();
+ _fdConfig?.Dispose();
}
[Test]
[Property("COVPARAM", "MediaVisionSource")]
public async Task DetectAsync_CHECK_RETURN_VALUE()
{
+ if (!_isFaceRecognitionSupported)
+ {
+ Assert.Pass("FaceRecognition is not supported");
+ }
var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg");
if (frame.Buffer == null || frame.Buffer.Length == 0)
[Property("COVPARAM", "MediaVisionSource, FaceDetectionConfiguration")]
public async Task DetectAsync_with_Roi_CHECK_RETURN_VALUE()
{
+ if (!_isFaceRecognitionSupported)
+ {
+ Assert.Pass("FaceRecognition is not supported");
+ }
+
var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg");
if (frame.Buffer == null || frame.Buffer.Length == 0)
{
[Property("COVPARAM", "MediaVisionSource")]
public async Task DetectAsync_CHECK_NULL_ARGUMENT_EXCEPTION()
{
+ if (!_isFaceRecognitionSupported)
+ {
+ Assert.Pass("FaceRecognition is not supported");
+ }
+
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceDetector.DetectAsync(null));
}
[Property("COVPARAM", "MediaVisionSource, FaceDetectionConfiguration")]
public async Task DetectAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION()
{
+ if (!_isFaceRecognitionSupported)
+ {
+ Assert.Pass("FaceRecognition is not supported");
+ }
+
_config.MinHeight = 10;
_config.MinWidth = 10;
_config.Roi = new Rectangle(60, 150, 520, 100);
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceDetector.DetectAsync(null, _config));
}
- }
+ [Test]
+ [Category("P1")]
+ [Description("Check whether face is detected correctly.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FaceDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ [Property("COVPARAM", "MediaVisionSource, InferenceModelConfiguration")]
+ public async Task DetectAsync_INFERENCE_CHECK_RETURN_VALUE()
+ {
+ if (!_isInferenceSupported)
+ {
+ Assert.Pass("Face detection using inference model is not supported");
+ }
+
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/face_detector/fd.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _fdConfig.LoadInferenceModel();
+
+ IEnumerable<FaceDetectionResult> result = null;
+
+ try
+ {
+ result = await FaceDetector.DetectAsync(source, _fdConfig);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Failed to detect face." + e.Message);
+ }
+
+ Assert.IsInstanceOf<IEnumerable<FaceDetectionResult>>(result, "It should be created.");
+
+ if (result.Any())
+ {
+ Assert.That(result.Count() > 0, "It should be greater than 0.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether FaceDetector throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FaceDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ [Property("COVPARAM", "MediaVisionSource, InferenceModelConfiguration")]
+ public void DetectAsync_INFERENCE_THROWS_IF_SOURCE_IS_NULL()
+ {
+ if (!_isInferenceSupported)
+ {
+ Assert.Pass("Face detection using inference model is not supported");
+ }
+
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await FaceDetector.DetectAsync(null, _fdConfig));
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether FaceDetector throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FaceDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ [Property("COVPARAM", "MediaVisionSource, InferenceModelConfiguration")]
+ public async Task DetectAsync_INFERENCE_THROWS_IF_CONFIG_IS_NULL()
+ {
+ if (!_isInferenceSupported)
+ {
+ Assert.Pass("Face detection using inference model is not supported");
+ }
+
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/face_detector/fd.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await FaceDetector.DetectAsync(source,
+ (InferenceModelConfiguration)null));
+ }
+ }
+ }
}
--- /dev/null
+// Copyright 2019 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.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Multimedia.Vision.FacialLandmarkDetector test class")]
+ public class FacialLandmarkDetectorTests : InferenceFaceTestBase
+ {
+ [Test]
+ [Category("P1")]
+ [Description("Check whether facial landmark is detected correctly.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FacialLandmarkDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task DetectAsync_CHECK_RETURN_VALUE()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/facial_landmark_detector/fld.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _fldConfig.LoadInferenceModel();
+
+ IEnumerable<Point> result = null;
+
+ try
+ {
+ result = await FacialLandmarkDetector.DetectAsync(source, _fldConfig);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Failed to detect facial landmark." + e.Message);
+ }
+
+ Assert.IsInstanceOf<IEnumerable<Point>>(result, "It should be created.");
+
+ if (result.Any())
+ {
+ Assert.That(result.Count() > 0, "It should be greater than 0.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Tests facial landmark detect with the result of face detector")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FacialLandmarkDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task DetectAsync_WITH_FACEDETECTOR_CHECK_RETURN_VALUE()
+ {
+ // First, we use face detector to get the location of each face.
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/face_detector/fd.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _fdConfig.LoadInferenceModel();
+
+ var fdResult = await FaceDetector.DetectAsync(source, _fdConfig);
+
+ // Now, we got the location of face, so it can be used the input of facial landmark detector.
+ // But, FacialLandmarkDetector can detect only one face at once, so we use the first result.
+ if (fdResult.Any())
+ {
+ var result = fdResult.FirstOrDefault();
+ _fldConfig.Roi = result.Location;
+ _fldConfig.TensorSize = new Size(result.Location.Width, result.Location.Height);
+ }
+
+ _fldConfig.LoadInferenceModel();
+
+ IEnumerable<Point> fldResult = null;
+
+ try
+ {
+ fldResult = await FacialLandmarkDetector.DetectAsync(source, _fldConfig);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Failed to detect facial landmark." + e.Message);
+ }
+
+ Assert.IsInstanceOf<IEnumerable<Point>>(fldResult, "It should be created.");
+
+ if (fldResult.Any())
+ {
+ Assert.That(fldResult.Count() > 0, "It should be greater than 0.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether FacialLandmarkDetector throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FacialLandmarkDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void DetectAsync_INFERENCE_THROWS_IF_SOURCE_IS_NULL()
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await FacialLandmarkDetector.DetectAsync(null, _fdConfig));
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether FacialLandmarkDetector throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.FacialLandmarkDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task DetectAsync_INFERENCE_THROWS_IF_CONFIG_IS_NULL()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/facial_landmark_detector/fld.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await FacialLandmarkDetector.DetectAsync(source, null));
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright 2019 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.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using Tizen.Multimedia.Util;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Multimedia.Vision.ImageClassificationResult test class")]
+ public class ImageClassificationResultTests : InferenceImageTestBase
+ {
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Indice returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ImageClassificationResult.Indice A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Indice_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _icConfig.LoadInferenceModel();
+
+ var icResult = await ImageClassifier.ClassifyAsync(source, _icConfig);
+ Assert.IsInstanceOf<IEnumerable<ImageClassificationResult>>(icResult, "It should be created.");
+
+ foreach (var result in icResult)
+ {
+ Assert.IsInstanceOf<int>(result.Indice, "It should be created.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Name returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ImageClassificationResult.Name A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Name_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _icConfig.LoadInferenceModel();
+
+ var icResult = await ImageClassifier.ClassifyAsync(source, _icConfig);
+ Assert.IsInstanceOf<IEnumerable<ImageClassificationResult>>(icResult, "It should be created.");
+
+ foreach (var result in icResult)
+ {
+ Assert.IsInstanceOf<string>(result.Name, "It should be created.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Confidence returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ImageClassificationResult.Confidence A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Confidence_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _icConfig.LoadInferenceModel();
+
+ var icResult = await ImageClassifier.ClassifyAsync(source, _icConfig);
+ Assert.IsInstanceOf<IEnumerable<ImageClassificationResult>>(icResult, "It should be created.");
+
+ foreach (var result in icResult)
+ {
+ Assert.IsInstanceOf<float>(result.Confidence, "It should be created.");
+ }
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright 2019 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.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Multimedia.Vision.ImageClassifier test class")]
+ public class ImageClassifierTests : InferenceImageTestBase
+ {
+ [Test]
+ [Category("P1")]
+ [Description("Check whether image is classified correctly.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ImageClassifier.ClassifyAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task ClassifyAsync_CHECK_RETURN_VALUE()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _icConfig.LoadInferenceModel();
+
+ IEnumerable<ImageClassificationResult> result = null;
+
+ try
+ {
+ result = await ImageClassifier.ClassifyAsync(source, _icConfig);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Failed to classify image." + e.Message);
+ }
+
+ Assert.IsInstanceOf<IEnumerable<ImageClassificationResult>>(result, "It should be created.");
+
+ if (result.Any())
+ {
+ Assert.That(result.Count() > 0, "It should be greater than 0.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether image is classified correctly with the result of object detection.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ImageClassifier.ClassifyAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task ClassifyAsync_WITH_FACEDETECTOR_CHECK_RETURN_VALUE()
+ {
+ // First, we use object detector to get the location of each object.
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/object_detector/od.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _odConfig.LoadInferenceModel();
+
+ var odResult = await ObjectDetector.DetectAsync(source, _odConfig);
+
+ // Now, we got the location of object, so it can be used the input of image classifier.
+ // But, ImageClassifier can classify only one image at once, so we use the first result.
+ if (odResult.Any())
+ {
+ _icConfig.Roi = odResult.FirstOrDefault().Location;
+ }
+
+ _icConfig.LoadInferenceModel();
+
+ IEnumerable<ImageClassificationResult> icResult = null;
+
+ try
+ {
+ icResult = await ImageClassifier.ClassifyAsync(source, _icConfig);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Failed to classify image." + e.Message);
+ }
+
+ Assert.IsInstanceOf<IEnumerable<ImageClassificationResult>>(icResult, "It should be created.");
+
+ if (icResult.Any())
+ {
+ Assert.That(icResult.Count() > 0, "It should be greater than 0.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether ImageClassifier throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ImageClassifier.ClassifyAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void ClassifyAsync_INFERENCE_THROWS_IF_SOURCE_IS_NULL()
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await ImageClassifier.ClassifyAsync(null, _icConfig));
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether ImageClassifier throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ImageClassifier.ClassifyAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task ClassifyAsync_INFERENCE_THROWS_IF_CONFIG_IS_NULL()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/facial_landmark_detector/fld.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await ImageClassifier.ClassifyAsync(source, null));
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright 2019 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.IO;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Multimedia.Vision.InferenceModelConfiguration test class")]
+ public class InferenceModelConfigurationTests
+ {
+ private InferenceModelConfiguration _config;
+
+ [SetUp]
+ public void Init()
+ {
+ try
+ {
+ _config = new InferenceModelConfiguration();
+ }
+ catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.Inference) == false)
+ {
+ Assert.Pass("Inference is not supported");
+ }
+ }
+
+ [TearDown]
+ public void Destroy()
+ {
+ _config?.Dispose();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Create the InferenceModelConfiguration Instance and check whether instance is created properly.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.InferenceModelConfiguration C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void InferenceModelConfiguration_CONSTRUCTOR()
+ {
+ var model = new InferenceModelConfiguration();
+ Assert.IsNotNull(model, "Object should not be null after initializing");
+ Assert.IsInstanceOf<InferenceModelConfiguration>(model, "Should return InferenceModelConfiguration instance");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether model data is loaded correctly.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.LoadInferenceModel M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task LoadInferenceModel_CHECK_RETURN_VALUE()
+ {
+ var config = new InferenceModelConfiguration();
+
+ if (!_config.SupportedBackend.Any() || _config.SupportedBackend.Contains(InferenceBackendType.TFLite))
+ {
+ Assert.Pass("Backend engine is not supported.");
+ }
+
+ config.WeightFilePath = TestHelper.TFLitePath + "face_detector/fd_tflite_model1.tflite";
+ config.MeanValue = 127.5;
+ config.StdValue = 127.5;
+ config.ConfidenceThreshold = 0.3;
+ config.Backend = InferenceBackendType.TFLite;
+ config.Target = InferenceTargetType.CPU;
+ config.TensorSize = new Size(300, 300);
+ config.TensorChannels = 3;
+ config.InputNodeName = "normalized_input_image_tensor";
+ config.OutputNodeName = new string[]
+ {
+ "TFLite_Detection_PostProcess",
+ "TFLite_Detection_PostProcess:1",
+ "TFLite_Detection_PostProcess:2",
+ "TFLite_Detection_PostProcess:3"
+ };
+
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/face_detector/fd.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ config.LoadInferenceModel();
+
+ var result = await FaceDetector.DetectAsync(source, config);
+
+ if (result.Any())
+ {
+ Assert.That(result.Count() > 0, "It should be greater than 0.");
+ }
+ }
+
+ config.Dispose();
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether LoadInferenceModel throws exception if file not found")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.LoadInferenceModel M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void LoadInferenceModel_THROWS_IF_FILE_NOT_FOUND()
+ {
+ using (var config = new InferenceModelConfiguration()
+ {
+ WeightFilePath = TestHelper.TFLitePath + "face_detector/not.found",
+ //MeanValue = 127.5,
+ //StdValue = 127.5,
+ //ConfidenceThreshold = 0.3,
+ //Backend = InferenceBackendType.TFLite,
+ //Target = InferenceTargetType.CPU,
+ //TensorSize = new Size(300, 300),
+ //TensorChannels = 3,
+ //InputNodeName = "normalized_input_image_tensor",
+ //OutputNodeName = new string[]
+ //{
+ // "TFLite_Detection_PostProcess",
+ // "TFLite_Detection_PostProcess:1",
+ // "TFLite_Detection_PostProcess:2",
+ // "TFLite_Detection_PostProcess:3"
+ //}
+ })
+ {
+ Assert.Throws<FileNotFoundException>(() => config.LoadInferenceModel());
+ }
+ }
+
+ // FileFormatException and InvalidDataException of LoadInferenceModel() cannot be tested currently.
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether SupportedBackend returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.SupportedBackend A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void SupportedBackend_READ_ONLY()
+ {
+ var supportedBackend = _config.SupportedBackend;
+ Assert.IsInstanceOf<IEnumerable<InferenceBackendType>>(supportedBackend);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether ConfigurationFilePath returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.ConfigurationFilePath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void ConfigurationFilePath_READ_WRITE()
+ {
+ var path = TestHelper.TFLitePath + "face_detector/fd_tflite_model1.tflite";
+ _config.ConfigurationFilePath = path;
+
+ Assert.IsInstanceOf<string>(_config.ConfigurationFilePath);
+ Assert.AreEqual(path, _config.ConfigurationFilePath, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether ConfigurationFilePath throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.ConfigurationFilePath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void ConfigurationFilePath_THROWS_IF_PARAM_IS_NULL()
+ {
+ Assert.Throws<ArgumentNullException>(() => _config.ConfigurationFilePath = null);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether WeightFilePath returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.WeightFilePath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void WeightFilePath_READ_WRITE()
+ {
+ var path = TestHelper.TFLitePath + "face_detector/fd_tflite_model1.tflite";
+ _config.WeightFilePath = path;
+
+ Assert.IsInstanceOf<string>(_config.WeightFilePath);
+ Assert.AreEqual(path, _config.WeightFilePath, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether WeightFilePath throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.WeightFilePath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void WeightFilePath_THROWS_IF_PARAM_IS_NULL()
+ {
+ Assert.Throws<ArgumentNullException>(() => _config.WeightFilePath = null);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether CategoryFilePath returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.CategoryFilePath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void CategoryFilePath_READ_WRITE()
+ {
+ var path = TestHelper.TFLitePath + "face_detector/fd_tflite_model1.tflite";
+ _config.CategoryFilePath = path;
+
+ Assert.IsInstanceOf<string>(_config.CategoryFilePath);
+ Assert.AreEqual(path, _config.CategoryFilePath, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether CategoryFilePath throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.CategoryFilePath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void CategoryFilePath_THROWS_IF_PARAM_IS_NULL()
+ {
+ Assert.Throws<ArgumentNullException>(() => _config.CategoryFilePath = null);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether MeanValue returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.MeanValue A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void MeanValue_READ_WRITE()
+ {
+ _config.MeanValue = 1.0;
+
+ Assert.IsInstanceOf<double>(_config.MeanValue);
+ Assert.AreEqual(1.0, _config.MeanValue, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether MeanValue throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.MeanValue A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void MeanValue_THROWS_IF_PARAM_IS_INVALID()
+ {
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.MeanValue = -1.0);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether StdValue returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.StdValue A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void StdValue_READ_WRITE()
+ {
+ _config.StdValue = 1.0;
+
+ Assert.IsInstanceOf<double>(_config.StdValue);
+ Assert.AreEqual(1.0, _config.StdValue, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether StdValue throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.StdValue A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void StdValue_THROWS_IF_PARAM_IS_INVALID()
+ {
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.StdValue = -1.0);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Backend returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Backend A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Backend_READ_WRITE()
+ {
+ var supportedBackend = _config.SupportedBackend;
+
+ foreach (var backend in supportedBackend)
+ {
+ _config.Backend = backend;
+
+ Assert.IsInstanceOf<InferenceBackendType>(_config.Backend);
+ Assert.AreEqual(backend, _config.Backend, "Should be got same value.");
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Backend returns correct default value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Backend A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PDV")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Backend_CHECK_DEFAULT_VALUE()
+ {
+ Assert.IsNotNull(_config.Backend, "Backend should not be null.");
+ Assert.IsInstanceOf<InferenceBackendType>(_config.Backend);
+ Assert.AreEqual(InferenceBackendType.OpenCV, _config.Backend, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether Backend throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Backend A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Backend_THROWS_IF_PARAM_IS_INVALID()
+ {
+ Assert.Throws<ArgumentException>(() => _config.Backend = (InferenceBackendType)10);
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether Backend throws exception if backend is not supported")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Backend A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Backend_THROWS_IF_BACKEND_IS_NOT_SUPPORTED()
+ {
+ var supportedBackend = _config.SupportedBackend;
+
+ foreach (InferenceBackendType backend in Enum.GetValues(typeof(InferenceBackendType)))
+ {
+ if (!supportedBackend.Contains(backend))
+ {
+ Assert.Throws<NotSupportedException>(() => _config.Backend = backend);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Target returns correct default value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Target A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PDV")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Target_CHECK_DEFAULT_VALUE()
+ {
+ Assert.That(_config.Target, Is.EqualTo(InferenceTargetType.CPU));
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Target returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Target A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Target_READ_WRITE()
+ {
+ _config.Target = InferenceTargetType.CPU;
+ Assert.IsInstanceOf<InferenceTargetType>(_config.Target, "Should return InferenceTargetType instance");
+ Assert.AreEqual(InferenceTargetType.CPU, _config.Target, "Should be got same value.");
+
+ _config.Target = InferenceTargetType.GPU;
+ Assert.IsInstanceOf<InferenceTargetType>(_config.Target, "Should return InferenceTargetType instance");
+ Assert.AreEqual(InferenceTargetType.GPU, _config.Target, "Should be got same value.");
+
+ _config.Target = InferenceTargetType.Custom;
+ Assert.IsInstanceOf<InferenceTargetType>(_config.Target, "Should return InferenceTargetType instance");
+ Assert.AreEqual(InferenceTargetType.Custom, _config.Target, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether Target throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Target A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Target_THROWS_IF_PARAM_IS_INVALID()
+ {
+ Assert.Throws<ArgumentException>(() => _config.Target = (InferenceTargetType)10);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether TensorSize returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.TensorSize A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void TensorSize_READ_WRITE()
+ {
+ var size = new Size(300, 300);
+ _config.TensorSize = size;
+
+ Assert.IsInstanceOf<Size>(_config.TensorSize, "Should return Size instance");
+ Assert.AreEqual(size.Width, _config.TensorSize.Width, "Should be got same value.");
+ Assert.AreEqual(size.Height, _config.TensorSize.Height, "Should be got same value.");
+
+ // Size(-1, -1) means that original image size will be used.
+ var size2 = new Size(-1, -1);
+ _config.TensorSize = size2;
+
+ Assert.IsInstanceOf<Size>(_config.TensorSize, "Should return Size instance");
+ Assert.AreEqual(size2.Width, _config.TensorSize.Width, "Should be got same value.");
+ Assert.AreEqual(size2.Height, _config.TensorSize.Height, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether TensorSize throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.TensorSize A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void TensorSize_THROWS_IF_PARAM_IS_INVALID()
+ {
+ Assert.Throws<ArgumentException>(() => _config.TensorSize = new Size(-1, -10));
+ Assert.Throws<ArgumentException>(() => _config.TensorSize = new Size(-1, 10));
+ Assert.Throws<ArgumentException>(() => _config.TensorSize = new Size(-10, -1));
+ Assert.Throws<ArgumentException>(() => _config.TensorSize = new Size(10, -1));
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether TensorSize throws exception if parameter is out of range")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.TensorSize A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void TensorSize_THROWS_IF_PARAM_IS_OUT_OF_RANGE()
+ {
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorSize = new Size(0, 0));
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorSize = new Size(0, 10));
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorSize = new Size(10, 0));
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorSize = new Size(10, -2));
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorSize = new Size(-2, 10));
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorSize = new Size(-2, -2));
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether TensorChannels returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.TensorChannels A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void TensorChannels_READ_WRITE()
+ {
+ var size = 3;
+ _config.TensorChannels = size;
+
+ Assert.IsInstanceOf<int>(_config.TensorChannels, "Should return int instance");
+ Assert.AreEqual(size, _config.TensorChannels, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether TensorChannels throws exception if parameter is out of range")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.TensorChannels A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void TensorChannels_THROWS_IF_PARAM_IS_OUT_OF_RANGE()
+ {
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorChannels = 0);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TensorChannels = -10);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether InputNodeName returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.InputNodeName A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void InputNodeName_READ_WRITE()
+ {
+ var name = "inputNode";
+ _config.InputNodeName = name;
+
+ Assert.IsInstanceOf<string>(_config.InputNodeName, "Should return string instance");
+ Assert.AreEqual(name, _config.InputNodeName, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether InputNodeName throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.InputNodeName A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void InputNodeName_THROWS_IF_PARAM_IS_NULL()
+ {
+ Assert.Throws<ArgumentNullException>(() => _config.InputNodeName = null);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether OutputNodeName returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.OutputNodeName A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void OutputNodeName_READ_WRITE()
+ {
+ var names = new string[]
+ {
+ "outputNode1",
+ "outputNode2",
+ };
+
+ _config.OutputNodeName = names;
+
+ Assert.IsInstanceOf<string[]>(_config.OutputNodeName, "Should return string instance");
+ AssertHelper.AreEqual(names, _config.OutputNodeName.ToArray());
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether OutputNodeName throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.OutputNodeName A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void OutputNodeName_THROWS_IF_PARAM_IS_NULL()
+ {
+ Assert.Throws<ArgumentNullException>(() => _config.OutputNodeName = null);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether MaxOutputNumber returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.MaxOutputNumber A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void MaxOutputNumber_READ_WRITE()
+ {
+ int max = 10;
+
+ _config.MaxOutputNumber = max;
+
+ Assert.IsInstanceOf<int>(_config.MaxOutputNumber, "Should return int instance");
+ Assert.AreEqual(max, _config.MaxOutputNumber, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether MaxOutputNumber returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.MaxOutputNumber A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void MaxOutputNumber_READ_WRITE_OVER_MAX()
+ {
+ _config.MaxOutputNumber = 100;
+
+ Assert.IsInstanceOf<int>(_config.MaxOutputNumber, "Should return int instance");
+ Assert.AreEqual(10, _config.MaxOutputNumber, "Should be got same value.");
+
+ _config.MaxOutputNumber = -100;
+
+ Assert.IsInstanceOf<int>(_config.MaxOutputNumber, "Should return int instance");
+ Assert.AreEqual(1, _config.MaxOutputNumber, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether ConfidenceThreshold returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.ConfidenceThreshold A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void ConfidenceThreshold_READ_WRITE()
+ {
+ double threshold = 0.5;
+
+ _config.ConfidenceThreshold = threshold;
+
+ Assert.IsInstanceOf<double>(_config.ConfidenceThreshold, "Should return double instance");
+ Assert.AreEqual(threshold, _config.ConfidenceThreshold, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether ConfidenceThreshold throws exception if parameter is out of range")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.ConfidenceThreshold A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void ConfidenceThreshold_THROWS_IF_PARAM_IS_OUT_OF_RANGE()
+ {
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.ConfidenceThreshold = -0.1);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.ConfidenceThreshold = 1.1);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Roi returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Roi A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Roi_READ_WRITE()
+ {
+ var roi = new Rectangle(new Point(10, 10), new Size(100, 100));
+ _config.Roi = roi;
+
+ Assert.IsInstanceOf<Rectangle>(_config.Roi, "Should return Rectangle instance");
+ Assert.AreEqual(roi.Width, _config.Roi.Value.Width, "Should be got same value.");
+ Assert.AreEqual(roi.Height, _config.Roi.Value.Height, "Should be got same value.");
+ Assert.AreEqual(roi.X, _config.Roi.Value.X, "Should be got same value.");
+ Assert.AreEqual(roi.Y, _config.Roi.Value.Y, "Should be got same value.");
+
+ var roi2 = new Rectangle(20, 20, 200, 200);
+ _config.Roi = roi2;
+
+ Assert.IsInstanceOf<Rectangle>(_config.Roi, "Should return Rectangle instance");
+ Assert.AreEqual(roi2.Width, _config.Roi.Value.Width, "Should be got same value.");
+ Assert.AreEqual(roi2.Height, _config.Roi.Value.Height, "Should be got same value.");
+ Assert.AreEqual(roi2.X, _config.Roi.Value.X, "Should be got same value.");
+ Assert.AreEqual(roi2.Y, _config.Roi.Value.Y, "Should be got same value.");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Roi returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Roi A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PDV")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Roi_CHECK_DEFAULT_VALUE()
+ {
+ Assert.AreEqual(_config.Roi, null, "Default value should be null");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether Roi throws exception if parameter is out of range")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.InferenceModelConfiguration.Roi A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Roi_THROWS_IF_PARAM_IS_OUT_OF_RANGE()
+ {
+ Assert.Throws<ArgumentOutOfRangeException>(
+ () => _config.Roi = new Rectangle(new Point(-1, 10), new Size(100, 100)));
+ Assert.Throws<ArgumentOutOfRangeException>(
+ () => _config.Roi = new Rectangle(new Point(10, -1), new Size(100, 100)));
+ Assert.Throws<ArgumentOutOfRangeException>(
+ () => _config.Roi = new Rectangle(new Point(10, 10), new Size(0, 100)));
+ Assert.Throws<ArgumentOutOfRangeException>(
+ () => _config.Roi = new Rectangle(new Point(10, 10), new Size(100, 0)));
+ }
+ }
+}
--- /dev/null
+// Copyright 2019 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.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using Tizen.Multimedia.Util;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Multimedia.Vision.ObjectDetectionResult test class")]
+ public class ObjectDetectionResultTests : InferenceImageTestBase
+ {
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Indice returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ObjectDetectionResult.Indice A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Indice_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _odConfig.LoadInferenceModel();
+
+ var odResult = await ObjectDetector.DetectAsync(source, _odConfig);
+ Assert.IsInstanceOf<IEnumerable<ObjectDetectionResult>>(odResult, "It should be created.");
+
+ foreach (var result in odResult)
+ {
+ Assert.IsInstanceOf<int>(result.Indice, "It should be created.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Name returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ObjectDetectionResult.Name A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Name_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _odConfig.LoadInferenceModel();
+
+ var odResult = await ObjectDetector.DetectAsync(source, _odConfig);
+ Assert.IsInstanceOf<IEnumerable<ObjectDetectionResult>>(odResult, "It should be created.");
+
+ foreach (var result in odResult)
+ {
+ Assert.IsInstanceOf<string>(result.Name, "It should be created.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Confidence returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ObjectDetectionResult.Confidence A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Confidence_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _odConfig.LoadInferenceModel();
+
+ var odResult = await ObjectDetector.DetectAsync(source, _odConfig);
+ Assert.IsInstanceOf<IEnumerable<ObjectDetectionResult>>(odResult, "It should be created.");
+
+ foreach (var result in odResult)
+ {
+ Assert.IsInstanceOf<float>(result.Confidence, "It should be created.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Location returns correct value.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ObjectDetectionResult.Location A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task Location_READ_ONLY()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/image_classifier/ic.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _odConfig.LoadInferenceModel();
+
+ var odResult = await ObjectDetector.DetectAsync(source, _odConfig);
+ Assert.IsInstanceOf<IEnumerable<ObjectDetectionResult>>(odResult, "It should be created.");
+
+ foreach (var result in odResult)
+ {
+ Assert.IsInstanceOf<Rectangle>(result.Location, "It should be created.");
+ }
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright 2019 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.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Multimedia.Vision.ObjectDetector test class")]
+ public class ObjectDetectorTests : InferenceImageTestBase
+ {
+ [Test]
+ [Category("P1")]
+ [Description("Check whether object is detected correctly.")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ObjectDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task DetectAsync_CHECK_RETURN_VALUE()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.TFLitePath + "/object_detector/od.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ _odConfig.LoadInferenceModel();
+
+ IEnumerable<ObjectDetectionResult> result = null;
+
+ try
+ {
+ result = await ObjectDetector.DetectAsync(source, _odConfig);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Failed to detect object." + e.Message);
+ }
+
+ Assert.IsInstanceOf<IEnumerable<ObjectDetectionResult>>(result, "It should be created.");
+
+ if (result.Any())
+ {
+ Assert.That(result.Count() > 0, "It should be greater than 0.");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether ObjectDetector throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ObjectDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void DetectAsync_INFERENCE_THROWS_IF_SOURCE_IS_NULL()
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await ObjectDetector.DetectAsync(null, _odConfig));
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether ObjectDetector throws exception if parameter is invalid")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.ObjectDetector.DetectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task DetectAsync_INFERENCE_THROWS_IF_CONFIG_IS_NULL()
+ {
+ var frame = await TestHelper.GetBitampFrameFromImage($"{TestHelper.TFLitePath}/facial_landmark_detector/fld.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
+ {
+ Assert.Fail("Failed to get buffer data from face image");
+ }
+
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () => await ObjectDetector.DetectAsync(source, null));
+ }
+ }
+ }
+}
[Test]
[Category("P2")]
[Description("Tests throwing argument exception when trying to remove source which is not added")]
- [Property("SPEC", "Tizen.Multimedia.SurveillanceEngine.RemoveSource M")]
+ [Property("SPEC", "Tizen.Multimedia.Vision.SurveillanceEngine.RemoveSource M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public const string BarcodeGeneration = "http://tizen.org/feature/vision.barcode_generation";
public const string FaceRecognition = "http://tizen.org/feature/vision.face_recognition";
public const string ImageRecognition = "http://tizen.org/feature/vision.image_recognition";
+ public const string Inference = "http://tizen.org/feature/vision.inference";
+ public const string InferenceFaceDetection = "http://tizen.org/feature/vision.inference.face";
+ public const string ImageClassification = "http://tizen.org/feature/vision.inference.image";
}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ public class InferenceFaceTestBase
+ {
+ protected InferenceModelConfiguration _fdConfig;
+ protected InferenceModelConfiguration _fldConfig;
+
+ [SetUp]
+ public void InitBase()
+ {
+ try
+ {
+ _fdConfig = new InferenceModelConfiguration();
+ _fldConfig = new InferenceModelConfiguration();
+ }
+ catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.Inference) == false ||
+ FeatureChecker.IsSupported(Features.InferenceFaceDetection) == false)
+ {
+ Assert.Pass("Face detection using inference model is not supported");
+ }
+
+ foreach (var iter in _fdConfig.SupportedBackend)
+ {
+ Log.Info("Tizen.MediaVision.Tests", $"Supported engine : {iter}");
+ }
+
+ if (_fdConfig.SupportedBackend.Any() &&
+ _fdConfig.SupportedBackend.Contains(InferenceBackendType.TFLite))
+ {
+ Configure();
+ }
+ else
+ {
+ Assert.Pass("Backend engine is not supported.");
+ }
+ }
+
+ [TearDown]
+ public void DestroyBase()
+ {
+ _fdConfig?.Dispose();
+ _fldConfig?.Dispose();
+ }
+
+ private void Configure()
+ {
+ _fdConfig.WeightFilePath = TestHelper.TFLitePath + "face_detector/fd_tflite_model1.tflite";
+ _fdConfig.MeanValue = 127.5;
+ _fdConfig.StdValue = 127.5;
+ _fdConfig.ConfidenceThreshold = 0.3;
+ _fdConfig.Backend = InferenceBackendType.TFLite;
+ _fdConfig.Target = InferenceTargetType.CPU;
+ _fdConfig.TensorSize = new Size(300, 300);
+ _fdConfig.TensorChannels = 3;
+ _fdConfig.InputNodeName = "normalized_input_image_tensor";
+ _fdConfig.OutputNodeName = new string[]
+ {
+ "TFLite_Detection_PostProcess",
+ "TFLite_Detection_PostProcess:1",
+ "TFLite_Detection_PostProcess:2",
+ "TFLite_Detection_PostProcess:3"
+ };
+
+ _fldConfig.WeightFilePath = TestHelper.TFLitePath + "facial_landmark_detector/fld_tflite_model1.tflite";
+ _fldConfig.MeanValue = 0.0;
+ _fldConfig.StdValue = 1.0;
+ _fldConfig.Backend = InferenceBackendType.TFLite;
+ _fldConfig.Target = InferenceTargetType.CPU;
+ _fldConfig.TensorSize = new Size(128, 128);
+ _fldConfig.TensorChannels = 3;
+ _fldConfig.InputNodeName = "INPUT_TENSOR_NAME";
+ _fldConfig.OutputNodeName = new string[] { "OUTPUT_TENSOR_NAME" };
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Vision.Tests
+{
+ public class InferenceImageTestBase
+ {
+ protected InferenceModelConfiguration _odConfig;
+ protected InferenceModelConfiguration _icConfig;
+
+ [SetUp]
+ public void InitBase()
+ {
+ try
+ {
+ _odConfig = new InferenceModelConfiguration();
+ _icConfig = new InferenceModelConfiguration();
+ }
+ catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.Inference) == false ||
+ FeatureChecker.IsSupported(Features.ImageClassification) == false)
+ {
+ Assert.Pass("object detection is not supported");
+ }
+
+ if (_odConfig.SupportedBackend.Any() &&
+ _odConfig.SupportedBackend.Contains(InferenceBackendType.TFLite))
+ {
+ Configure();
+ }
+ else
+ {
+ Assert.Pass("Backend engine is not supported.");
+ }
+ }
+
+ [TearDown]
+ public void DestroyBase()
+ {
+ _odConfig?.Dispose();
+ _icConfig?.Dispose();
+ }
+
+ private void Configure()
+ {
+ _odConfig.WeightFilePath = TestHelper.TFLitePath + "object_detector/od_tflite_model.tflite";
+ _odConfig.CategoryFilePath = TestHelper.TFLitePath + "object_detector/od_label.txt";
+ _odConfig.MeanValue = 127.0;
+ _odConfig.StdValue = 127.0;
+ _odConfig.ConfidenceThreshold = 0.6;
+ _odConfig.Backend = InferenceBackendType.TFLite;
+ _odConfig.Target = InferenceTargetType.CPU;
+ _odConfig.TensorSize = new Size(224, 224);
+ _odConfig.TensorChannels = 3;
+ _odConfig.InputNodeName = "input_2";
+ _odConfig.OutputNodeName = new string[] { "dense_3/Softmax" };
+
+ _icConfig.WeightFilePath = TestHelper.TFLitePath + "image_classifier/ic_tflite_model.tflite";
+ _icConfig.CategoryFilePath = TestHelper.TFLitePath + "image_classifier/ic_label.txt";
+ _icConfig.MeanValue = 127.5;
+ _icConfig.StdValue = 127.5;
+ _icConfig.ConfidenceThreshold = 0.3;
+ _icConfig.Backend = InferenceBackendType.TFLite;
+ _icConfig.Target = InferenceTargetType.CPU;
+ _icConfig.TensorSize = new Size(300, 300);
+ _icConfig.TensorChannels = 3;
+ _icConfig.InputNodeName = "normalized_input_image_tensor";
+ _icConfig.OutputNodeName = new string[]
+ {
+ "TFLite_Detection_PostProcess",
+ "TFLite_Detection_PostProcess:1",
+ "TFLite_Detection_PostProcess:2",
+ "TFLite_Detection_PostProcess:3"
+ };
+ }
+ }
+}
{
internal static string ResourcePath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Tests/shared/res/";
internal static string TrustedPath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Tests/shared/trusted/";
+ internal static string TFLitePath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Tests/shared/res/inference_tflite/";
+ internal static string OpenCVPath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Tests/shared/res/inference_opencv/";
public enum ImageUtilColorspace
{
-<?xml version="1.0" encoding="utf-8"?>\r
-<manifest xmlns="http://tizen.org/ns/packages" api-version="6" package="Tizen.MediaVision.Tests" version="1.0.0">\r
- <profile name="common" />\r
- <ui-application appid="Tizen.MediaVision.Tests"\r
- exec="Tizen.MediaVision.Tests.dll"\r
- type="dotnet"\r
- multiple="false"\r
- taskmanage="true"\r
- launch_mode="single">\r
- <icon>Tizen.MediaVision.Tests.png</icon>\r
- <label>Tizen.MediaVision.Tests</label>\r
- </ui-application>\r
- <privileges>\r
- <privilege>http://tizen.org/privilege/mediastorage</privilege>\r
- <privilege>http://tizen.org/privilege/externalstorage</privilege>\r
- <privilege>http://tizen.org/privilege/appmanager.launch</privilege>\r
- </privileges>\r
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="Tizen.MediaVision.Tests" version="1.0.0" api-version="6" xmlns="http://tizen.org/ns/packages">
+ <profile name="common" />
+ <ui-application appid="Tizen.MediaVision.Tests" exec="Tizen.MediaVision.Tests.dll" multiple="false" taskmanage="true" type="dotnet" launch_mode="single">
+ <icon>Tizen.MediaVision.Tests.png</icon>
+ <label>Tizen.MediaVision.Tests</label>
+ <splash-screens />
+ </ui-application>
+ <shortcut-list />
+ <privileges>
+ <privilege>http://tizen.org/privilege/mediastorage</privilege>
+ <privilege>http://tizen.org/privilege/externalstorage</privilege>
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ <privilege>http://tizen.org/privilege/content.write</privilege>
+ </privileges>
+ <provides-appdefined-privileges />
</manifest>
\ No newline at end of file