Remove dllimport which uses native image-util apis directly.
Instead, use JpegDecorder of CSharp's Multimedia.Util.
Change-Id: I6930ddc9e7bc02b69dbe8cfa4c8c0c88eae9a7db
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
if (isNotSupportedTC)
return;
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "barcode/barcode.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "barcode/barcode.jpg"))
{
Point point = new Point(0, 0);
Size size = new Size((int)source.Width, (int)source.Height);
if (isNotSupportedTC)
return;
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "barcode/barcode.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "barcode/barcode.jpg"))
{
config.Target = BarcodeDetectionTarget.All;
if (isNotSupportedTC)
return;
- byte[] bytes;
- int width, height;
- int ret = TestHelper.GetBytesFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg", out bytes, out width, out height);
- if (ret != 0)
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
{
Assert.IsTrue(false, "Failed to get buffer data from face image");
}
- using (var source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888))
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
{
var faceLists = await FaceDetector.DetectAsync(source);
Assert.IsInstanceOf<Rectangle[]>(faceLists, "Should be Rectangle[]");
if (isNotSupportedTC)
return;
- byte[] bytes;
- int width, height;
- int ret = TestHelper.GetBytesFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg", out bytes, out width, out height);
- if (ret != 0)
+ var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg");
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
{
Assert.IsTrue(false, "Failed to get buffer data from face image");
}
config.MinWidth = 10;
config.Roi = new Rectangle(60, 150, 520, 100);
- using (var source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888))
+ using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
{
var faceLists = await FaceDetector.DetectAsync(source, config);
Assert.IsInstanceOf<Rectangle[]>(faceLists, "Should be Rectangle[]");
using System;
using System.IO;
using NUnit.Framework;
-using NUnit.Framework.TUnit;
+using System.Threading.Tasks;
using Tizen.System;
namespace Tizen.Multimedia.Vision.Tests
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_RETURN_VALUE()
+ public static async Task Save_CHECK_RETURN_VALUE()
{
string path = TestHelper.TrustedPath + "face_recognition_model_test";
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
model.Add(source1, 1);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION()
+ public static async Task Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION()
{
string restrictedPath = TestHelper.ResourcePath + "face_recog/unauthorizedPath";
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P2/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P2/00.jpg"))
{
model.Add(source1, 1);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTIOn()
+ public static async Task Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTIOn()
{
string fakePath = "/tmp/fake/fake_model";
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
model.Add(source1, 1);
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
[Property("COVPARAM", "MediaVisionSource, int")]
- public static void Add_CHECK_RETURN_VALUE()
+ public static async Task Add_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
model.Add(source1, 1);
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
[Property("COVPARAM", "MediaVisionSource, int, Rectangle")]
- public static void Add_with_Roi_CHECK_RETURN_VALUE()
+ public static async Task Add_with_Roi_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
/* Suppose that ROI is a whole image */
Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source1.Width, (int)source1.Height));
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MCST")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Reset_CHECK_RETURN_VALUE()
+ public static async Task Reset_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
model.Add(source1, 1);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Remove_CHECK_RETURN_VALUE()
+ public static async Task Remove_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
model.Add(source1, 1);
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
[Property("COVPARAM", "")]
- public static void Learn_CHECK_RETURN_VALUE()
+ public static async Task Learn_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
model.Add(source1, 1);
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
[Property("COVPARAM", "FaceRecognitionConfiguration")]
- public static void Learn_with_Configuration_CHECK_RETURN_VALUE()
+ public static async Task Learn_with_Configuration_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
model.Add(source1, 1);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "PRO")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Labels_READ_ONLY()
+ public static async Task Labels_READ_ONLY()
{
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
- using (MediaVisionSource source2 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
+ using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"))
{
/* Suppose that ROI is a whole image */
// you entered into with Samsung.
using System;
-using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using Tizen.System;
private static FaceRecognitionModel model = null;
private static bool isNotSupportedTC = false;
+ private static async Task PrepareModel()
+ {
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+ }
+
[SetUp]
public static void Init()
{
try
{
model = new FaceRecognitionModel();
-
- TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
- TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
-
- model.Learn();
}
catch (NotSupportedException)
{
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ await PrepareModel();
+
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
var result = await FaceRecognizer.RecognizeAsync(source, model);
Assert.IsTrue(result.Success, "Success should be true");
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ await PrepareModel();
+
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
var result = await FaceRecognizer.RecognizeAsync(source, model);
Assert.IsTrue(result.Success, "Success should be true");
if (isNotSupportedTC)
return;
+ await PrepareModel();
+
Rectangle faceArea = new Rectangle(0, 0, 325, 325);
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
var result = await FaceRecognizer.RecognizeAsync(source, model);
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ await PrepareModel();
+
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
var result = await FaceRecognizer.RecognizeAsync(source, model);
Assert.IsTrue(result.Success, "Success should be true");
try
{
model = new FaceRecognitionModel();
-
- TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
- TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
-
- model.Learn();
}
catch (NotSupportedException)
{
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
var result = await FaceRecognizer.RecognizeAsync(source, model);
Assert.IsTrue(result.Success, "Should be success");
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
using (var localModel = new FaceRecognitionModel())
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
await AssertHelper.ThrowsAsync<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(source, localModel));
}
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height));
var result = await FaceRecognizer.RecognizeAsync(source, model, roi);
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100));
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceRecognizer.RecognizeAsync(null, null, roi));
}
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
using (var localModel = new FaceRecognitionModel())
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100));
await AssertHelper.ThrowsAsync<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(source, localModel, roi));
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration();
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration();
await AssertHelper.ThrowsAsync<ArgumentNullException>( () => FaceRecognizer.RecognizeAsync(null, null, engineConfig));
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
using (var localModel = new FaceRecognitionModel())
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration();
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height));
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100));
FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration();
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
using (var localModel = new FaceRecognitionModel())
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"))
{
Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100));
if (isNotSupportedTC)
return;
- byte[] bytes;
- int width, height;
- int ret = TestHelper.GetBytesFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg", out bytes, out width, out height);
- if (ret != 0)
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg"));
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
{
Assert.IsTrue(false, "Failed to get buffer data from face image");
}
- using (MediaVisionSource source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888))
+ using (MediaVisionSource source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
{
var faceDetectionResult = await FaceDetector.DetectAsync(source);
Assert.IsTrue(faceDetectionResult.Length > 0, "No face detected");
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceRecognizer.RecognizeEyeConditionAsync(null, new Rectangle(0, 0, 100, 100)));
}
if (isNotSupportedTC)
return;
- byte[] bytes;
- int width, height;
- int ret = TestHelper.GetBytesFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg", out bytes, out width, out height);
- if (ret != 0)
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg"));
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
{
Assert.IsTrue(false, "Failed to get buffer data from face image");
}
- using (MediaVisionSource source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888))
+ using (MediaVisionSource source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
{
var faceDetectionResult = await FaceDetector.DetectAsync(source);
Assert.IsTrue(faceDetectionResult.Length > 0, "No face detected");
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration();
Rectangle roi = new Rectangle(new Point(10, 10), new Size(50, 50));
if (isNotSupportedTC)
return;
- byte[] bytes;
- int width, height;
- int ret = TestHelper.GetBytesFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg", out bytes, out width, out height);
- if (ret != 0)
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg"));
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
{
Assert.IsTrue(false, "Failed to get buffer data from face image");
}
- using (MediaVisionSource source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888))
+ using (MediaVisionSource source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
{
var faceDetectionResult = await FaceDetector.DetectAsync(source);
Assert.IsTrue(faceDetectionResult.Length > 0, "No face detected");
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceRecognizer.RecognizeFacialExpressionAsync(null, new Rectangle(0, 0, 100, 100)));
}
if (isNotSupportedTC)
return;
- byte[] bytes;
- int width, height;
- int ret = TestHelper.GetBytesFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg", out bytes, out width, out height);
- if (ret != 0)
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
+ var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg"));
+ if (frame.Buffer == null || frame.Buffer.Length == 0)
{
Assert.IsTrue(false, "Failed to get buffer data from face image");
}
- using (MediaVisionSource source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888))
+ using (MediaVisionSource source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888))
{
var faceDetectionResult = await FaceDetector.DetectAsync(source);
if (isNotSupportedTC)
return;
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1);
+ await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2);
+
+ model.Learn();
+
Rectangle roi = new Rectangle(new Point(10, 10), new Size(50, 50));
FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration();
private static bool isNotSupportedTC = false;
+ private static async Task PrepareMediaVisionSources()
+ {
+ await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "face_track/");
+ }
+
[SetUp]
public static void Init()
{
{
model = new FaceTrackingModel();
sources = new List<MediaVisionSource>();
- TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "face_track/");
}
catch (NotSupportedException)
{
if (isNotSupportedTC)
return;
+ await PrepareMediaVisionSources();
+
Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image");
Point[] faceInitailpoints = {
if (isNotSupportedTC)
return;
+ await PrepareMediaVisionSources();
+
Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image");
foreach (var frame in sources)
using System;
using System.IO;
+using System.Threading.Tasks;
using NUnit.Framework;
using Tizen.System;
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Prepare_CHECK_RETURN_VALUE()
+ public static async Task Prepare_CHECK_RETURN_VALUE()
{
Point[] faceInitailpoints = {
new Point(440, 130),
Quadrangle faceLocation = new Quadrangle(faceInitailpoints);
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
{
model.Prepare(source, faceLocation);
}
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_RETURN_VALUE()
+ public static async Task Save_CHECK_RETURN_VALUE()
{
Point[] faceInitailpoints = {
new Point(440, 130),
string path = TestHelper.TrustedPath + "face_tracking_model_test";
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
{
model.Prepare(source, faceLocation);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION()
+ public static async Task Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION()
{
Point[] faceInitailpoints = {
new Point(440, 130),
string restrictedPath = TestHelper.ResourcePath + "face_track/face_track_model";
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
{
model.Prepare(source, faceLocation);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION()
+ public static async Task Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION()
{
Point[] faceInitailpoints = {
new Point(440, 130),
string fakePath = "/tmp/fake/face_fake_model";
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"))
{
model.Prepare(source, faceLocation);
private static List<MediaVisionSource> sources = null;
private static bool isNotSupportedTC = false;
+ private static async Task PrepareModel()
+ {
+ int ret = await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "face_track/");
+ Assert.IsFalse(ret != 0, "Failed to get buffer data from face image");
+
+ Point[] faceInitailpoints = {
+ new Point(440, 130),
+ new Point(530, 130),
+ new Point(530, 240),
+ new Point(440, 240) };
+
+ Quadrangle faceLocation = new Quadrangle(faceInitailpoints);
+
+ model.Prepare(sources[0], faceLocation);
+ }
+
[SetUp]
public static void Init()
{
{
model = new FaceTrackingModel();
sources = new List<MediaVisionSource>();
-
- int ret = TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "face_track/");
- Assert.IsFalse(ret!=0, "Failed to get buffer data from face image");
-
- Point[] faceInitailpoints = {
- new Point(440, 130),
- new Point(530, 130),
- new Point(530, 240),
- new Point(440, 240) };
-
- Quadrangle faceLocation = new Quadrangle(faceInitailpoints);
-
- model.Prepare(sources[0], faceLocation);
}
catch (NotSupportedException)
{
if (isNotSupportedTC)
return;
+ await PrepareModel();
+
Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image");
foreach (var frame in sources)
if (isNotSupportedTC)
return;
+ await PrepareModel();
+
Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image");
foreach (var frame in sources)
if (isNotSupportedTC)
return;
+ await PrepareModel();
+
Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image");
foreach (var frame in sources)
using System;
using System.IO;
+using System.Threading.Tasks;
using NUnit.Framework;
using Tizen.System;
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "PRO")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
- public static void RecognitionRate_READ_ONLY()
+ public static async Task RecognitionRate_READ_ONLY()
{
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
Assert.IsNotNull(source, "source should be not null");
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
[Property("COVPARAM", "MediaVisionSource")]
- public static void Fill_CHECK_RETURN_VALUE()
+ public static async Task Fill_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
obj.Fill(source);
}
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
[Property("COVPARAM", "MediaVisionSource, Rectangle")]
- public static void Fill_with_Roi_CHECK_RETURN_VALUE()
+ public static async Task Fill_with_Roi_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height));
obj.Fill(source, roi);
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
[Property("COVPARAM", "MediaVisionSource, ImageFillConfiguration")]
- public static void Fill_with_Configuration_CHECK_RETURN_VALUE()
+ public static async Task Fill_with_Configuration_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
ImageFillConfiguration engineCfg = new ImageFillConfiguration();
engineCfg.ObjectScaleFactor = 1.5;
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
[Property("COVPARAM", "MediaVisionSource, ImageFillConfiguration, Rectangle")]
- public static void Fill_with_Roi_Configuration_CHECK_RETURN_VALUE()
+ public static async Task Fill_with_Roi_Configuration_CHECK_RETURN_VALUE()
{
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height));
ImageFillConfiguration engineCfg = new ImageFillConfiguration();
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
- public static void Save_CHECK_RETURN_VALUE()
+ public static async Task Save_CHECK_RETURN_VALUE()
{
string path = TestHelper.TrustedPath + "image_ojbect_test";
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
obj.SetLabel(1);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION()
+ public static async Task Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION()
{
string restrictedPath = TestHelper.ResourcePath + "image/unautorized_model";
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
obj.SetLabel(1);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION()
+ public static async Task Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION()
{
string fakePath = "/tmp/fake/fake_model";
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
obj.SetLabel(1);
if (isNotSupportedTC)
return;
- using (MediaVisionSource sourceTarget = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
- using (MediaVisionSource sourceScene = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
+ using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
{
obj.Fill(sourceTarget);
if (isNotSupportedTC)
return;
- using (MediaVisionSource sourceTarget = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
- using (MediaVisionSource sourceScene = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
+ using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
{
obj.Fill(sourceTarget);
if (isNotSupportedTC)
return;
- using (MediaVisionSource sourceTarget = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
- using (MediaVisionSource sourceScene = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
+ using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
{
obj.Fill(sourceTarget);
if (isNotSupportedTC)
return;
- using (MediaVisionSource sourceScene = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
+ using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
{
ImageObject[] images = new ImageObject[0];
await AssertHelper.ThrowsAsync<ArgumentException>(() => ImageRecognizer.RecognizeAsync(sourceScene, images));
if (isNotSupportedTC)
return;
- using (MediaVisionSource sourceTarget = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
- using (MediaVisionSource sourceScene = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
+ using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
{
obj.Fill(sourceTarget);
if (isNotSupportedTC)
return;
- using (MediaVisionSource sourceScene = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
+ using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg"))
{
ImageObject[] images = new ImageObject[0];
private static List<MediaVisionSource> sources = null;
private static bool isNotSupportedTC = false;
+ private static async Task PrepareMediaVisionSources()
+ {
+ await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "image_track/");
+ }
+
[SetUp]
public static void Init()
{
{
model = new ImageTrackingModel();
sources = new List<MediaVisionSource>();
- TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "image_track/");
}
catch (NotSupportedException)
{
if (isNotSupportedTC)
return;
+ await PrepareMediaVisionSources();
+
Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from images");
using (var Obj = new ImageObject())
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
Obj.Fill(source);
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image_track/frame01.jpg"))
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image_track/frame01.jpg"))
{
await AssertHelper.ThrowsAsync<ArgumentException>(() => ImageTracker.TrackAsync(source, model));
}
if (isNotSupportedTC)
return;
+ await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "image_track/");
+
Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from images");
using (var Obj = new ImageObject())
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
Obj.Fill(source);
if (isNotSupportedTC)
return;
- using (var source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image_track/frame01.jpg"))
+ using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image_track/frame01.jpg"))
{
ImageTrackingConfiguration engineConfig = new ImageTrackingConfiguration();
engineConfig.HistoryAmount = 1;
using System;
using System.IO;
using NUnit.Framework;
+using System.Threading.Tasks;
using NUnit.Framework.TUnit;
using Tizen.System;
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
- public static void SetTarget_CHECK_RETURN_VALUE()
+ public static async Task SetTarget_CHECK_RETURN_VALUE()
{
using (var obj = new ImageObject())
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
obj.Fill(source);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
- public static void Refresh_CHECK_RETURN()
+ public static async Task Refresh_CHECK_RETURN()
{
using (var obj = new ImageObject())
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
obj.Fill(source);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
- public static void Save_CHECK_RETURN_VALUE()
+ public static async Task Save_CHECK_RETURN_VALUE()
{
string path = TestHelper.TrustedPath + "image_track_test";
using (var obj = new ImageObject())
- using (MediaVisionSource source = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
+ using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"))
{
obj.Fill(source);
private static MediaVisionSource source_2 = null;
private static bool isNotSupportedTC = false;
+ private static async Task PrepareMediaVisionSources()
+ {
+ source_1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg");
+ Assert.IsNotNull(source_1, "fail to get mediavisionsource from an image");
+
+ source_2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_2.jpg");
+ Assert.IsNotNull(source_2, "fail to get mediavisionsource from an image");
+ }
+
[SetUp]
public static void Init()
{
try
{
detector = new MovementDetector();
-
- TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg", out source_1);
- Assert.IsNotNull(source_1, "fail to get mediavisionsource from an image");
-
- TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_2.jpg", out source_2);
- Assert.IsNotNull(source_2, "fail to get mediavisionsource from an image");
}
catch (NotSupportedException)
{
if (isNotSupportedTC)
return;
+ await PrepareMediaVisionSources();
+
_waitFlag = false;
detector.Detected += EventHandlerMovementDetected;
private static MediaVisionSource source_2 = null;
private static bool isNotSupportedTC = false;
+ private static async Task PrepareMediaVisionSources()
+ {
+ source_1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg");
+ Assert.IsNotNull(source_1, "fail to get mediavisionsource from an image");
+
+ source_2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/pers_det.jpg");
+ Assert.IsNotNull(source_2, "fail to get mediavisionsource from an image");
+ }
+
[SetUp]
public static void Init()
{
try
{
detector = new PersonAppearanceDetector();
-
- TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg", out source_1);
- Assert.IsNotNull(source_1, "fail to get mediavisionsource from an image");
-
- TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/pers_det.jpg", out source_2);
- Assert.IsNotNull(source_2, "fail to get mediavisionsource from an image");
}
catch (NotSupportedException)
{
if (isNotSupportedTC)
return;
+ await PrepareMediaVisionSources();
+
_waitFlag = false;
detector.Detected += EventHandlerPersonAppearancetDetected;
SurveillanceSource recognizerSource = new SurveillanceSource();
recognizer.AddSource(recognizerSource, config);
- MediaVisionSource source = null;
- TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/p1_09.jpg", out source);
+ MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/p1_09.jpg");
Assert.IsNotNull(source, "fail to get mediavisionsource from source");
recognizerSource.Push(source);
SurveillanceSource detectorSource = new SurveillanceSource();
detector.AddSource(detectorSource);
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"))
{
detectorSource.Push(source1);
await Task.Delay(10);
SurveillanceSource detectorSource = new SurveillanceSource();
detector.AddSource(detectorSource);
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"))
{
detectorSource.Push(source1);
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
- public static void Push_CHECK_INVALID_OPERATIONT_EXCEPTION()
+ public static async Task Push_CHECK_INVALID_OPERATIONT_EXCEPTION()
{
if (isNotSupportedTC)
return;
SurveillanceSource detectorSource = new SurveillanceSource();
- using (MediaVisionSource source1 = TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"))
+ using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"))
{
Assert.Throws<InvalidOperationException>(() => detectorSource.Push(source1));
}
using System;
using System.Collections.Generic;
using System.IO;
-using System.Runtime.InteropServices;
-using NUnit.Framework;
+using System.Linq;
+using System.Threading.Tasks;
+using Tizen.Multimedia.Util;
using NUnit.Framework.TUnit;
namespace Tizen.Multimedia.Vision.Tests
NV61 /**< NV61- planar */
}
- public class NativeImageUtil
+ internal static async Task<BitmapFrame> GetBitampFrameFromImage(string path)
{
- [DllImport("libcapi-media-image-util.so.0", EntryPoint = "image_util_decode_jpeg")]
- internal static extern int DecodeJpeg(string path, ImageUtilColorspace colorspace, out IntPtr buffer, out int width, out int height, out int size);
+ JpegDecoder jpegDecoder = new JpegDecoder();
- [DllImport("libc.so.6", EntryPoint = "free")]
- internal static extern void BufferFree(IntPtr userData);
- }
+ jpegDecoder.SetColorSpace(ColorSpace.Rgb888);
- internal static int GetBytesFromImage(string path, out byte[] buffer, out int width, out int height)
- {
- IntPtr byteStrPtr = IntPtr.Zero;
- int byteStrSize;
- int ret = NativeImageUtil.DecodeJpeg(path, ImageUtilColorspace.RGB888, out byteStrPtr, out width, out height, out byteStrSize);
- if (ret != 0)
- {
- Log.Info(LogUtils.TAG, "Failed to decode image");
- buffer = null;
- return ret;
- }
+ var frame = (await jpegDecoder.DecodeAsync(path)).FirstOrDefault();
- buffer = new byte[byteStrSize];
- Marshal.Copy(byteStrPtr, buffer, 0, byteStrSize);
- NativeImageUtil.BufferFree(byteStrPtr);
- return ret;
- }
- internal static void GetMediaSourceFromImage(string path, out MediaVisionSource source)
- {
- byte[] bytes;
- int width, height;
- int ret = GetBytesFromImage(path, out bytes, out width, out height);
- if (ret != 0)
- {
- Assert.IsTrue(false, "Failed to get buffer data from face image : " + path);
- }
+ jpegDecoder.Dispose();
- source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888);
+ return frame;
}
- internal static MediaVisionSource GetMediaSourceFromImage(string path)
+ internal static async Task<MediaVisionSource> GetMediaSourceFromImage(string path)
{
- byte[] bytes;
- int width, height;
- int ret = GetBytesFromImage(path, out bytes, out width, out height);
- if (ret != 0)
- {
- Assert.IsTrue(false, "Failed to get buffer data from face image : " + path);
- }
+ var frame = (await GetBitampFrameFromImage(path));
- MediaVisionSource source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888);
+ MediaVisionSource source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888);
return source;
}
- internal static int FillMediaSourceFromImages(List<MediaVisionSource> sources, string path)
+ internal static async Task<int> FillMediaSourceFromImages(List<MediaVisionSource> sources, string path)
{
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] images = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
foreach (var image in images)
{
- byte[] bytes;
- int width, height;
-
- int ret = GetBytesFromImage(image.FullName, out bytes, out width, out height);
- if (ret == 0)
+ var frame = (await GetBitampFrameFromImage(image.FullName)); ;
+ if (frame.Buffer != null && frame.Buffer.Length > 0)
{
- MediaVisionSource source = new MediaVisionSource(bytes, (uint)width, (uint)height, ColorSpace.Rgb888);
+ MediaVisionSource source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888);
sources.Add(source);
Log.Info(LogUtils.TAG, "load buffer from image : " + image.FullName);
}
else
{
Log.Info(LogUtils.TAG, "Failed to load buffer from image : " + image.FullName);
- return ret;
+ return 1;
}
}
Log.Info(LogUtils.TAG, "Total loaded iamges : " + sources.Count.ToString());
-
return 0;
}
- internal static void AddImagesToModel(FaceRecognitionModel model, string path, int label)
+ internal static async Task AddImagesToModel(FaceRecognitionModel model, string path, int label)
{
- MediaVisionSource source = null;
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] images = di.GetFiles("*.jpg");
foreach (var image in images)
{
- source = GetMediaSourceFromImage(image.FullName);
+ var source = await GetMediaSourceFromImage(image.FullName);
Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height));
model.Add(source, label, roi);
}