public ModelToken(IModelApplication application, string filePathImage, string filePathJson) { _application = application; _filePathImage = filePathImage; _filePathJson = filePathJson; _bitmapSource = new Bitmap(filePathImage); if ((_bitmapSource.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed) || (_bitmapSource.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb)) { _bitmapSource = ToolsConvolution.ConvertTo24(_bitmapSource); } Bitmap bitmapTemp = new Grayscale(1, 0, 0).Apply(_bitmapSource); bitmapTemp = new Erosion().Apply(bitmapTemp); bitmapTemp = new Threshold(160).Apply(bitmapTemp); bitmapTemp = new Invert().Apply(bitmapTemp); _kernel = ToolsConvolution.BitMapToDoubleArray(bitmapTemp, 0.5); _threshold = new ModelValueDouble(application.EventTokenChanged, 0); _weigth = new ModelValueDouble(application.EventTokenChanged, 0); ModelRendererBitmapSource renderer = new ModelRendererBitmapSource(_bitmapSource); renderer.Render(); Image = renderer.RenderedImage; ModelRendererBitmapSource rendererProcessed = new ModelRendererBitmapSource(bitmapTemp); rendererProcessed.Render(); ImageProcessed = rendererProcessed.RenderedImage; if (File.Exists(filePathJson)) { Load(); } else { this._threshold = new ModelValueDouble(_application.EventTokenChanged, 0.8); this._weigth = new ModelValueDouble(_application.EventTokenChanged, 1.0); this._label = filePathImage.Split('_')[1]; Save(); } }
public ModelPageLayout(IModelApplication application, string filePath, ModelPageLayout other) { _application = application; _filePath = filePath; this._rotation = new ModelValueDouble(application.EventLayoutChanged, 0); this._threshold = new ModelValueInt(application.EventLayoutChanged, 0); this._lineSize = new ModelValueDouble(application.EventLayoutChanged, 0); this._lineOffset = new ModelValueDouble(application.EventLayoutChanged, 0); this._lineCount = new ModelValueInt(application.EventLayoutChanged, 0); this._colSize = new ModelValueDouble(application.EventLayoutChanged, 0); this._colOffset = new ModelValueDouble(application.EventLayoutChanged, 0); this._colCount = new ModelValueInt(application.EventLayoutChanged, 0); this._margin = new ModelValueInt(application.EventLayoutChanged, 0); this._overlap = new ModelValueDouble(application.EventLayoutChanged, 0); if (File.Exists(_filePath)) { Load(); } else { if (other == null) { this._rotation.Value = 180; this._threshold.Value = 100; this._lineSize.Value = 20; this._lineOffset.Value = 100; this._lineCount.Value = 0; this._colSize.Value = 20; this._colOffset.Value = 100; this._colCount.Value = 0; this._margin.Value = 0; this._overlap.Value = 0; } else { SetValue(other.GetValue()); } Save(); } }
private void SetValue(PageLayoutV001 layout) { this._rotation = new ModelValueDouble(_application.EventLayoutChanged, layout.Rotation); this._threshold = new ModelValueInt(_application.EventLayoutChanged, layout.Threshold); this._lineSize = new ModelValueDouble(_application.EventLayoutChanged, layout.LineSize); this._lineOffset = new ModelValueDouble(_application.EventLayoutChanged, layout.LineOffset); this._lineCount = new ModelValueInt(_application.EventLayoutChanged, layout.LineCount); this._colSize = new ModelValueDouble(_application.EventLayoutChanged, layout.ColSize); this._colOffset = new ModelValueDouble(_application.EventLayoutChanged, layout.ColOffset); this._colCount = new ModelValueInt(_application.EventLayoutChanged, layout.ColCount); this._margin = new ModelValueInt(_application.EventLayoutChanged, layout.Margin); this._overlap = new ModelValueDouble(_application.EventLayoutChanged, layout.Overlap); }
private void SetValue(TokenV001 token) { this._threshold = new ModelValueDouble(_application.EventTokenChanged, token.Threshold); this._weigth = new ModelValueDouble(_application.EventTokenChanged, token.Weigth); this._label = token.Label; }