private TableCellType CreateHeaderTableCell(string fieldName) { TableCellType headerTableCell = new TableCellType(); headerTableCell.Items = new object[] { CreateHeaderTableCellReportItems(fieldName) }; return(headerTableCell); }
private TableCellType CreateTableCell(string fieldName, bool isNumeric) { TableCellType tableCell = new TableCellType(); tableCell.Items = new object[] { CreateTableCellReportItems(fieldName, isNumeric) }; return(tableCell); }
public WTTableCell(string name, float horizontalPadding, float verticalPadding, float width, Color backgroundColor, TableCellType type) : base(name) { this.tableCellType = type; horizontalPadding_ = horizontalPadding; verticalPadding_ = verticalPadding; width_ = width; if (backgroundColor.a > 0) { backgroundSpriteComponent = new WTSpriteComponent("backgroundSpriteComponent", "Futile_White"); backgroundSpriteComponent.sprite.color = backgroundColor; backgroundSpriteComponent.sprite.width = width_; backgroundSpriteComponent.sprite.anchorX = 0; backgroundSpriteComponent.sprite.anchorY = 0; backgroundSpriteComponent.sprite.y = 1; AddComponent(backgroundSpriteComponent); } bottomLineSpriteComponent = new WTSpriteComponent("bottomLineSpriteComponent", "Futile_White"); bottomLineSpriteComponent.sprite.width = width; bottomLineSpriteComponent.sprite.height = 1f; bottomLineSpriteComponent.sprite.color = Color.black; bottomLineSpriteComponent.sprite.alpha = 0.2f; bottomLineSpriteComponent.sprite.anchorX = 0; //bottomLineSpriteComponent.sprite.y = 1f; AddComponent(bottomLineSpriteComponent); }
private TableCellType CreateHeaderTableCell(ReportColumn field) { var headerTableCell = new TableCellType(); headerTableCell.Items = new object[] { CreateHeaderTableCellReportItems(field) }; return(headerTableCell); }
public GameObject CreateItem(TableCellType type, Transform parent) { switch (type) { case TableCellType.Empty: { return(Object.Instantiate(Style.Empty, parent)); } case TableCellType.StaticText: case TableCellType.DynamicText: { return(Object.Instantiate(Style.Text, parent)); } case TableCellType.Row: { return(Object.Instantiate(Style.Row, parent)); } case TableCellType.Column: { return(Object.Instantiate(Style.Column, parent)); } default: { throw new ArgumentOutOfRangeException(); } } }
public ImTableCell(string name, float horizontalPadding, float verticalPadding, float width, Color backgroundColor, TableCellType type) : base(name) { this.tableCellType = type; horizontalPadding_ = horizontalPadding; verticalPadding_ = verticalPadding; width_ = width; if (backgroundColor.a > 0) { backgroundSpriteComponent = new ImSpriteComponent("backgroundSpriteComponent", "Futile_White"); backgroundSpriteComponent.sprite.color = backgroundColor; backgroundSpriteComponent.sprite.width = width_; backgroundSpriteComponent.sprite.anchorX = 0; backgroundSpriteComponent.sprite.anchorY = 0; backgroundSpriteComponent.sprite.y = 1; AddComponent(backgroundSpriteComponent); } bottomLineSpriteComponent = new ImSpriteComponent("bottomLineSpriteComponent", "Futile_White"); bottomLineSpriteComponent.sprite.width = width; bottomLineSpriteComponent.sprite.height = 1f; bottomLineSpriteComponent.sprite.color = Color.black; bottomLineSpriteComponent.sprite.alpha = 0.2f; bottomLineSpriteComponent.sprite.anchorX = 0; //bottomLineSpriteComponent.sprite.y = 1f; AddComponent(bottomLineSpriteComponent); }
private TableCellType CreateHeaderTableCell(string fieldName, int i, bool isNumeric) { TableCellType headerTableCell = new TableCellType(); headerTableCell.Items = new object[] { CreateHeaderTableCellReportItems(fieldName, i, isNumeric) }; return(headerTableCell); }
public TableCellViewModel(int order, object content, TableCellType type, bool editable, string relatedProperty) { this.Order = order; this.Type = type; this.content = content; this.Editable = editable; this.RelatedProperty = relatedProperty; }
public TableCell(int column, int row, TableCellType type, Bitmap image, string text, bool mask) { this.Column = column; this.Row = row; this.Type = type; this.Image = image; this.Text = text; this.Mask = mask; }
public void AddCell(string id, TableCellType type, ICollection <string> refs) { _body.Add(new TableCell() { Id = id, Type = type, Refs = refs }); }
public void AddTableCell(string centerLabelString, TableCellType type) { ImTableCell tableCell = new ImTableCell("tableCell", 8f, 3f, width_ - inset_, Color.white, type); tableCells.Add(tableCell); tableCell.x = inset_ / 2f - width_ / 2f; tableCell.AddCenterLabel("TwCen", centerLabelString, Color.black, 0.2f); AddChild(tableCell); RefreshHeight(); ArrangeCells(); }
public TableCellAttribute( int order, string name, TableCellType type, string textForTrueValue, string textForFalseValue) { this.Order = order; this.Name = name; this.Type = type; this.TextForFalseValue = textForFalseValue; this.TextForTrueValue = textForTrueValue; }
public void AddTableCell(string leftLabelString, string rightSpriteImageName, TableCellType type) { WTTableCell tableCell = new WTTableCell("tableCell", 8f, 3f, width_ - inset_, Color.white, type); tableCells.Add(tableCell); tableCell.x = inset_ / 2f - width_ / 2f; tableCell.AddLeftLabel("TwCen", leftLabelString, Color.black, 0.2f); tableCell.AddRightSprite(rightSpriteImageName, 1f); tableCell.rightSpriteComponent.sprite.color = Color.blue; AddChild(tableCell); RefreshHeight(); ArrangeCells(); }
public void AddCell( int order, object content, TableCellType type, bool editable, string relatedProperty, string textForTrueValue, string textForFalseValue) { TableCellViewModel tableCell = new TableCellViewModel(order, content, type, editable, relatedProperty, textForTrueValue, textForFalseValue); this.cells.Add(tableCell); }
public TableCellViewModel( int order, object content, TableCellType type, bool editable, string relatedProperty, string textForTrueValue, string textForFalseValue) { this.Order = order; this.Type = type; this.content = content; this.Editable = editable; this.RelatedProperty = relatedProperty; this.TextForFalseValue = textForFalseValue; this.TextForTrueValue = textForTrueValue; }
public GameObject CreateItem(TableCellType type, Transform parent) { return(Object.Instantiate(Prefab, parent)); }
protected void AddItemData(string id, TableCellType type, ICollection <string> refs) { _tableData.AddCell(id, type, refs); }
public TableCellViewModel(int order, object content, TableCellType type) { Order = order; Type = type; this.content = content; }
public void AddCell(int order, object content, TableCellType type, bool editable, string relatedProperty) { TableCellViewModel tableCell = new TableCellViewModel(order, content, type, editable, relatedProperty); this.cells.Add(tableCell); }
public TableCellAttribute(int order, string name, TableCellType type) { this.Order = order; this.Name = name; this.Type = type; }
public void AddCell(int order, object content, TableCellType type) { TableCellViewModel tableCell = new TableCellViewModel(order, content, type); this.cells.Add(tableCell); }
public void AddTableCell(string leftLabelString, string rightSpriteImageName, ImAbstractItem item, TableCellType type) { ImTableCell tableCell = new ImTableCell("tableCell", 8f, 3f, width_ - inset_, Color.white, type); tableCells.Add(tableCell); tableCell.x = inset_ / 2f - width_ / 2f; tableCell.AddLeftLabel("TwCen", leftLabelString, Color.black, 0.2f); tableCell.AddRightSprite(rightSpriteImageName, 1f); tableCell.rightSpriteComponent.sprite.color = Color.blue; tableCell.item = item; AddChild(tableCell); RefreshHeight(); ArrangeCells(); }
public TableCellAttribute(int order, string name, TableCellType type) { Order = order; Name = name; Type = type; }
public virtual void ProccessImage(BackgroundWorker worker) { this.worker = worker; UpdateProgress(3); //Brightness and sharpen filters BrightnessCorrection cfilter = new BrightnessCorrection(Settings.Brightness); GaussianSharpen filter = new GaussianSharpen(4, 11); //Apply filters cfilter.ApplyInPlace(sourceBitmap); UpdateProgress(15); filter.ApplyInPlace(sourceBitmap); UpdateProgress(30); //Convert to gray var tmpImage = ConvertToGrayScale(sourceBitmap); UpdateProgress(35); //Cut edges tmpImage = CutEdgesAndInvert(tmpImage); UpdateProgress(40); //Get angle for rotating image var rotateAngle = DetectRotation(tmpImage); UpdateProgress(45); if (rotateAngle != 0) { RotateBilinear rotate = new RotateBilinear(rotateAngle, true); tmpImage = rotate.Apply(tmpImage); } //Build horizontal hough lines OCRLessonReport.Imaging.HoughLineTransformation lineTransform = new OCRLessonReport.Imaging.HoughLineTransformation(); HoughLineRequestSettings settings = new HoughLineRequestSettings { HorizontalLines = true, VerticalLines = false, HorizontalDeviation = 2 }; lineTransform.ProcessImage(tmpImage, settings); //Get horizontal line HoughLine[] lines = lineTransform.GetLinesByRelativeIntensity(Settings.HorizontalSensitivity); //Get half width and height for future calculations int hWidth = tmpImage.Width / 2; int hHeight = tmpImage.Height / 2; //Get line coordinates (Y axis only - horizontal lines) var lineCoordinates = lines.Select(line => hHeight - line.Radius); //Grouping coords by delta var groupedCoordinates = ImagingHelper.GroupingCoordinates(lineCoordinates, Settings.LineGroupingDelta); if (groupedCoordinates.Count <= Settings.HeaderStartLine) { throw new Exception("Invalid source. Can't be recognized"); } int headerLineY0 = groupedCoordinates[Settings.HeaderStartLine]; int headerLineY1 = groupedCoordinates[Settings.HeaderStartLine + 1]; //Copy header to new image var headerImage = tmpImage.Copy(new Rectangle(0, headerLineY0, tmpImage.Width, headerLineY1 - headerLineY0)); //Parse header to get header lines HoughLineRequestSettings headerSettings = new HoughLineRequestSettings { HorizontalLines = false, VerticalLines = true, VerticalDeviation = 1 }; lineTransform.ProcessImage(headerImage, headerSettings); Func <HoughLine, int, int> getRadius = (l, w) => { if (l.Theta > 90 && l.Theta < 180) { return(w - l.Radius); } else { return(w + l.Radius); } }; HoughLine[] headerLines = lineTransform.GetLinesByRelativeIntensity(Settings.VerticalSensitivity); //Get header vertical lines var headerLineCoordinates = headerLines.Select(line => getRadius(line, hWidth)); //Grouped lines var groupedheaderLineCoordinates = ImagingHelper.GroupingCoordinates(headerLineCoordinates, Settings.LineGroupingDelta); //Build cell map List <TableCell> cellMap = new List <TableCell>(); UpdateProgress(50); //Use tess engine for ocr using (TesseractEngine engine = new TesseractEngine(Settings.TessdataPath, Settings.TessdataLanguage)) { //Parse top header var x0 = groupedheaderLineCoordinates.FirstOrDefault(); var x1 = groupedheaderLineCoordinates.LastOrDefault(); var y0 = groupedCoordinates[0]; var y1 = groupedCoordinates[1]; int fullProgress = (groupedheaderLineCoordinates.Count - 1) * (groupedCoordinates.Count - Settings.BottomStartLine - 1 - Settings.HeaderStartLine); int curProgress = 0; var hImage = tmpImage.Copy(new Rectangle(x0, y0, x1 - x0, y1 - y0)); hImage = ProcessCell(hImage); using (var page = engine.Process(hImage, PageSegMode.SingleBlock)) { cellMap.Add(new TableCell(0, 0, TableCellType.MainHeader, hImage, page.GetText(), false)); } //Parse table for (int i = 0; i < groupedheaderLineCoordinates.Count - 1; i++) { int subjectArea = (i < Settings.ColumnSubjectStart - 1) ? 0 : 1; for (int j = Settings.HeaderStartLine; j < groupedCoordinates.Count - Settings.BottomStartLine - 1; j++) { int headerArea = (j == Settings.HeaderStartLine) ? 2 : 0; TableCellType cellType = (TableCellType)(subjectArea + headerArea); var cellImg = tmpImage.Copy(new Rectangle(groupedheaderLineCoordinates[i], groupedCoordinates[j], groupedheaderLineCoordinates[i + 1] - groupedheaderLineCoordinates[i], groupedCoordinates[j + 1] - groupedCoordinates[j])); if (cellType == TableCellType.Text || cellType == TableCellType.Header || cellType == TableCellType.HeaderRotated) { cellImg = ProcessCell(cellImg, i == Settings.NameStartLine); string text = String.Empty; if (cellType == TableCellType.HeaderRotated) { cellImg.RotateFlip(RotateFlipType.Rotate90FlipNone); } using (var page = engine.Process(cellImg, PageSegMode.SingleBlock)) { text = page.GetText(); } cellMap.Add(new TableCell(i, j, cellType, cellImg, text, false)); } else { cellImg = ProcessCell(cellImg); BilateralSmoothing bfilter = new BilateralSmoothing(); bfilter.KernelSize = 7; bfilter.SpatialFactor = 10; bfilter.ColorFactor = 60; bfilter.ColorPower = 0.5; bfilter.ApplyInPlace(cellImg); cellImg = FilterColors(cellImg, Settings.FilteringColor, ByteColor.Black, ByteColor.White); BlobCounter bcounter = new BlobCounter(); bcounter.ProcessImage(cellImg); var blobs = bcounter.GetObjects(cellImg, false); if (blobs.Length < 1) { continue; } var biggestBlob = blobs.OrderBy(b => b.Area).LastOrDefault(); var biggestBlobsImage = biggestBlob.Image.ToManagedImage(); cellMap.Add(new TableCell(i, j, cellType, biggestBlobsImage, GetMask(biggestBlobsImage).ToString(), GetMask(biggestBlobsImage))); } curProgress++; double reportProgress = (double)curProgress / (double)fullProgress * 50 + 50; UpdateProgress((int)reportProgress); } } } this.Cells = cellMap; UpdateProgress(100); }