/// <summary> ///A Create PRD ///</summary> public TPage CreatePRD() { TPage page = new TPage(); TLine line1 = new TLine(); TLine line2 = new TLine(); TLine line3 = new TLine(); TWord word1 = new TWord(); TWord word2 = new TWord(); TWord word3 = new TWord(); TWord word4 = new TWord(); TWord word5 = new TWord(); word1.AddChar(new TChar('A', 100, new TOCRRect(10, 10, 20, 20))); word1.AddChar(new TChar('B', 100, new TOCRRect(40, 10, 20, 20))); word1.AddChar(new TChar('C', 100, new TOCRRect(70, 10, 20, 20))); word2.AddChar(new TChar('D', 100, new TOCRRect(100, 10, 20, 20))); word2.AddChar(new TChar('E', 100, new TOCRRect(140, 10, 20, 20))); word2.AddChar(new TChar('F', 100, new TOCRRect(170, 10, 20, 20))); word3.AddChar(new TChar('1', 100, new TOCRRect(10, 40, 20, 20))); word3.AddChar(new TChar('2', 100, new TOCRRect(40, 40, 20, 20))); word3.AddChar(new TChar('3', 100, new TOCRRect(70, 40, 20, 20))); word4.AddChar(new TChar('X', 100, new TOCRRect(10, 70, 20, 20))); word4.AddChar(new TChar('Y', 100, new TOCRRect(40, 70, 20, 20))); word4.AddChar(new TChar('Z', 100, new TOCRRect(70, 70, 20, 20))); word5.AddChar(new TChar('W', 100, new TOCRRect(110, 70, 20, 20))); word5.AddChar(new TChar('V', 100, new TOCRRect(140, 70, 20, 20))); word5.AddChar(new TChar('Q', 100, new TOCRRect(170, 70, 20, 20))); line1.AddWord(word1); line1.AddWord(word2); line2.AddWord(word3); line3.AddWord(word4); line3.AddWord(word5); page.AddLine(line1); page.AddLine(line2); page.AddLine(line3); return(page); }
public static TPage ToPRD(PageOcrData ocrData, String saveToPrdPath) #endif { try { if (ocrData != null) { TPage res = new TPage(); //-- iterate data lines --\\ foreach (LineOcrData lineOcr in ocrData.Lines) { TLine currentLine = new TLine(); //-- Itarate the line's words --\\ foreach (WordOcrData wordOcr in lineOcr.Words) { //-- Iterate the word's chars --\\ TWord wordPrd = new TWord(); foreach (CharOcrData charOcr in wordOcr.GetAsChars(true)) { wordPrd.AddChar(new TChar(charOcr.Value, (short)charOcr.Confidence, new TOCRRect(charOcr.Rect))); } currentLine.AddWord(wordPrd); } if (currentLine != null && currentLine.Words != null && currentLine.Words.Count > 0) { res.AddLine(currentLine); } } //-- Save the contents to a PRD file if 'saveToPrdPath' is specified --\\ if (!String.IsNullOrEmpty(saveToPrdPath)) { if (!Directory.Exists(Path.GetDirectoryName(saveToPrdPath))) { Directory.CreateDirectory(Path.GetDirectoryName(saveToPrdPath)); } TPage.SaveToPRD(res, saveToPrdPath); } return(res); } else { throw new Exception(String.Format("Invalid input PRD object in: [{0}]", MethodBase.GetCurrentMethod().Name)); } } catch (Exception ex) { ILog.LogError(ex); } return(null); }
/// <summary> /// Sets the next character. /// </summary> /// <param name="cCharData">The c character data.</param> /// <param name="iConfidence">The i confidence.</param> /// <param name="iLeft">The i left.</param> /// <param name="iTop">The i top.</param> /// <param name="iWidth">Width of the i.</param> /// <param name="iHeight">Height of the i.</param> /// <param name="iLine">The i line.</param> /// <param name="iWord">The i word.</param> public void SetNextChar(char cCharData, short iConfidence, int iLeft, int iTop, int iWidth, int iHeight, int iLine, int iWord) { if ((cCharData == ' ')) { m_oSetLine.AddWord(m_oSetWord); m_oSetWord = new TWord(); } else if (cCharData == '\n') { m_oPage.AddLine(m_oSetLine); m_oSetLine = new TLine(); } else { TChar oSetChar = new TChar(cCharData, iConfidence, new TOCRRect(iLeft, iTop, iWidth, iHeight)); m_oSetWord.AddChar(oSetChar); } }