public void DisposeAndCheckDisposedState(DlibObject obj) { obj.Dispose(); Assert.True(obj.IsDisposed); Assert.True(obj.NativePtr == IntPtr.Zero); }
public void Jet2() { var path = this.GetDataFile($"{LoadTarget}.bmp"); var tests = new[] { new { Type = ImageTypes.RgbPixel, ExpectResult = false, Max = 255, Min = 0 }, new { Type = ImageTypes.RgbAlphaPixel, ExpectResult = false, Max = 255, Min = 0 }, new { Type = ImageTypes.UInt8, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.UInt16, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.UInt32, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.Int8, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.Int16, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.Int32, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.HsiPixel, ExpectResult = false, Max = 255, Min = 0 }, new { Type = ImageTypes.Float, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.Double, ExpectResult = true, Max = 255, Min = 0 }, new { Type = ImageTypes.RgbPixel, ExpectResult = false, Max = 75, Min = 50 }, new { Type = ImageTypes.RgbAlphaPixel, ExpectResult = false, Max = 75, Min = 50 }, new { Type = ImageTypes.UInt8, ExpectResult = true, Max = 75, Min = 50 }, new { Type = ImageTypes.UInt16, ExpectResult = true, Max = 75, Min = 50 }, new { Type = ImageTypes.UInt32, ExpectResult = true, Max = 75, Min = 50 }, new { Type = ImageTypes.Int8, ExpectResult = true, Max = 75, Min = 50 }, new { Type = ImageTypes.Int16, ExpectResult = true, Max = 75, Min = 50 }, new { Type = ImageTypes.Int32, ExpectResult = true, Max = 75, Min = 50 }, new { Type = ImageTypes.HsiPixel, ExpectResult = false, Max = 75, Min = 50 }, new { Type = ImageTypes.Float, ExpectResult = true, Max = 75, Min = 50 }, new { Type = ImageTypes.Double, ExpectResult = true, Max = 75, Min = 50 } }; var type = this.GetType().Name; foreach (var test in tests) { Array2DBase imageObj = null; Array2DBase horzObj = null; Array2DBase vertObj = null; Array2DBase outputImageObj = null; MatrixOp matrix = null; DlibObject windowObj = null; try { const ImageTypes inputType = ImageTypes.Float; var image = DlibTest.LoadImage(test.Type, path); imageObj = image; var horz = Array2DTest.CreateArray2D(inputType); horzObj = horz; var vert = Array2DTest.CreateArray2D(inputType); vertObj = vert; var outputImage = Array2DTest.CreateArray2D(test.Type); outputImageObj = outputImage; Dlib.SobelEdgeDetector(image, horz, vert); Dlib.SuppressNonMaximumEdges(horz, vert, outputImage); try { matrix = Jet(test.Type, outputImage, test.Max, test.Min); if (test.ExpectResult) { if (this.CanGuiDebug) { var window = new ImageWindow(matrix, $"{test.Type} - Max: {test.Max}, Min : {test.Min}"); windowObj = window; } Dlib.SaveBmp(image, $"{Path.Combine(this.GetOutDir(type, "Jet2"), $"{LoadTarget}_{test.Type}_{test.Max}_{test.Min}.bmp")}"); } else { Assert.Fail($"Failed to execute Jet2 to Type: {test.Type}"); } } catch (Exception) { if (!test.ExpectResult) { Console.WriteLine("OK"); } else { throw; } } } catch (Exception e) { Console.WriteLine(e.StackTrace); Console.WriteLine($"Failed to execute Jet2 to Type: {test.Type}"); throw; } finally { if (outputImageObj != null) { this.DisposeAndCheckDisposedState(outputImageObj); } if (vertObj != null) { this.DisposeAndCheckDisposedState(vertObj); } if (horzObj != null) { this.DisposeAndCheckDisposedState(horzObj); } if (windowObj != null) { this.DisposeAndCheckDisposedState(windowObj); } if (matrix != null) { this.DisposeAndCheckDisposedState(matrix); } if (imageObj != null) { this.DisposeAndCheckDisposedState(imageObj); } } } }
public override string ToString() { return(DlibObject.ToString()); }
protected PartCollectionBridge(DlibObject parent) { this._Parent = parent; }