public void PointTransformProjectiveCreate1() { var matrix = new Matrix <double>(3, 3); var transform = new PointTransformProjective(matrix); this.DisposeAndCheckDisposedState(matrix); this.DisposeAndCheckDisposedState(transform); }
public void PointTransformProjectiveM() { var matrix = new Matrix <double>(3, 3); var transform = new PointTransformProjective(matrix); var m = transform.M; Assert.Equal(m.MatrixElementType, MatrixElementTypes.Double); Assert.Equal(m.Rows, 3); Assert.Equal(m.Columns, 3); this.DisposeAndCheckDisposedState(m); this.DisposeAndCheckDisposedState(matrix); this.DisposeAndCheckDisposedState(transform); }
public void PointTransformProjectiveOperator() { for (var x = -10d; x <= 10d; x += 0.5) { for (var y = -10d; y <= 10d; y += 0.5) { var matrix = new Matrix <double>(3, 3); var transform = new PointTransformProjective(matrix); var vector = new DPoint(x, y); var ret = transform.Operator(vector); this.DisposeAndCheckDisposedState(transform); this.DisposeAndCheckDisposedState(matrix); } } }
public void PointTransformProjectiveCreateException() { PointTransformProjective transform = null; Matrix <double> matrix = null; try { transform = new PointTransformProjective(null); Assert.True(false, "PointTransformProjective should not accept null object for 1st argument"); } catch { Console.WriteLine("OK"); } finally { if (transform != null) { this.DisposeAndCheckDisposedState(transform); } } try { matrix = new Matrix <double>(); transform = new PointTransformProjective(matrix); Assert.True(false, "PointTransformProjective should not accept not 3x3 matrix"); } catch { Console.WriteLine("OK"); } finally { if (matrix != null) { this.DisposeAndCheckDisposedState(matrix); } if (transform != null) { this.DisposeAndCheckDisposedState(transform); } } }
public void TransformImagePointTransformProjective() { const string testName = "TransformImagePointTransformProjective"; var path = this.GetDataFile($"{LoadTarget}.bmp"); var tests = new[] { new { Type = ImageTypes.HsiPixel, ExpectResult = false }, new { Type = ImageTypes.RgbAlphaPixel, ExpectResult = false }, new { Type = ImageTypes.RgbPixel, ExpectResult = true }, new { Type = ImageTypes.UInt8, ExpectResult = true }, new { Type = ImageTypes.UInt16, ExpectResult = true }, new { Type = ImageTypes.Float, ExpectResult = true }, new { Type = ImageTypes.Double, ExpectResult = true } }; var angleCases = new[] { //45d, -45d, 90d, 180d 0d }; var xCases = new[] { //10, -10, 50,5, -50,5 0d }; var yCases = new[] { //10, -10, 50,5, -50,5 0d }; var type = this.GetType().Name; foreach (var angle in angleCases) { foreach (var x in xCases) { foreach (var y in yCases) { foreach (var input in tests) { foreach (var output in tests) { var expectResult = input.ExpectResult && output.ExpectResult; var imageObj = DlibTest.LoadImage(input.Type, path); var outputObj = Array2DTest.CreateArray2D(output.Type, imageObj.Rows, imageObj.Columns); var matrix = new Matrix <double>(3, 3); var transform = new PointTransformProjective(matrix); var outputImageAction = new Func <bool, Array2DBase>(expect => { Dlib.TransformImage(imageObj, outputObj, transform); return(outputObj); }); var successAction = new Action <Array2DBase>(image => { Dlib.SaveJpeg(image, $"{Path.Combine(this.GetOutDir(type, testName), $"{LoadTarget}_{input.Type}_{output.Type}_{angle}_{x}_{y}.jpg")}"); }); var failAction = new Action(() => { Assert.Fail($"{testName} should throw excption for InputType: {input.Type}, OutputType: {output.Type}, Angle,: {angle}, X: {x}, Y: {y}."); }); var finallyAction = new Action(() => { this.DisposeAndCheckDisposedState(matrix); this.DisposeAndCheckDisposedState(transform); this.DisposeAndCheckDisposedState(imageObj); if (outputObj != null) { this.DisposeAndCheckDisposedState(outputObj); } }); var exceptionAction = new Action(() => { Console.WriteLine($"Failed to execute {testName} to InputType: {input.Type}, OutputType: {output.Type}, Angle,: {angle}, X: {x}, Y: {y}."); }); DoTest(outputImageAction, expectResult, successAction, finallyAction, failAction, exceptionAction); } } } } } }
public void PointTransformProjectiveCreate() { var transform = new PointTransformProjective(); this.DisposeAndCheckDisposedState(transform); }