示例#1
0
        public void InitData(WinOCRResultData data)
        {
            //일단은 ocr 영역 1개로 처리한다는 가정하에 만든다.
            dataList = new List <ResultData>();

            ResultData resultData = new ResultData();

            resultData.index = 1;

            //Util.ShowLog("line = " + point.lineCount);
            int count = 0;

            for (int i = 0; i < data.lineCount; i++)
            {
                LineData lineData   = new LineData();
                string   lineString = "";
                //Util.ShowLog("----line start----");

                for (int j2 = 0; j2 < data.wordCounts[i]; j2++)
                {
                    lineString += data.words[count] + " ";

                    Rectangle rect = new Rectangle((int)data.x[count], (int)data.y[count], (int)data.sizeX[count], (int)data.sizeY[count]);
                    lineData.wordList.Add(data.words[count]);
                    lineData.wordRectList.Add(rect);
                    // Util.ShowLog("words : " + data.words[count] + " rect : " + rect.ToString());

                    count++;
                }
                Rectangle lineRect = new Rectangle();
                //줄 처리.
                if (lineData.wordRectList.Count > 1)
                {
                    lineRect = lineData.wordRectList[0];
                    for (int j = 1; j < lineData.wordRectList.Count; j++)
                    {
                        lineRect = Rectangle.Union(lineRect, lineData.wordRectList[j]);
                    }
                    lineData.lineRect = lineRect;
                }
                else if (lineData.wordRectList.Count == 1)
                {
                    lineRect          = lineData.wordRectList[0];
                    lineData.lineRect = lineRect;
                }
                //Util.ShowLog("Line string : " + lineString + " Rect : " + lineRect.ToString()  );

                lineData.lineString = lineString;

                resultData.lineDataList.Add(lineData);
            }

            //전체 영역 처리.
            if (resultData.lineDataList.Count == 1)
            {
                resultData.resultRect = resultData.lineDataList[0].lineRect;
            }
            else if (resultData.lineDataList.Count > 1)
            {
                resultData.resultRect = resultData.lineDataList[0].lineRect;
                for (int i = 1; i < resultData.lineDataList.Count; i++)
                {
                    resultData.resultRect = Rectangle.Union(resultData.resultRect, resultData.lineDataList[i].lineRect);
                }
            }

            CalculateLines(resultData);
            dataList.Add(resultData);
        }
示例#2
0
        public ResultData AddData(WinOCRResultData data, int index)
        {
            ResultData resultData = new ResultData();

            resultData.index = index;

            //Util.ShowLog("line = " + point.lineCount);
            int count = 0;

            for (int i = 0; i < data.lineCount; i++)
            {
                LineData lineData   = new LineData();
                string   lineString = "";
                //Util.ShowLog("----line start----");

                for (int j2 = 0; j2 < data.wordCounts[i]; j2++)
                {
                    lineString += data.words[count] + " ";

                    Rectangle rect = new Rectangle((int)data.x[count], (int)data.y[count], (int)data.sizeX[count], (int)data.sizeY[count]);
                    lineData.wordList.Add(data.words[count]);
                    lineData.wordRectList.Add(rect);

                    count++;
                }
                Rectangle lineRect = new Rectangle();
                //줄 처리.
                if (lineData.wordRectList.Count > 1)
                {
                    lineRect = lineData.wordRectList[0];
                    for (int j = 1; j < lineData.wordRectList.Count; j++)
                    {
                        lineRect = Rectangle.Union(lineRect, lineData.wordRectList[j]);
                    }
                    lineData.lineRect = lineRect;
                }
                else if (lineData.wordRectList.Count == 1)
                {
                    lineRect          = lineData.wordRectList[0];
                    lineData.lineRect = lineRect;
                }

                lineData.lineString = lineString;
                resultData.lineDataList.Add(lineData);

                if (lineRect.Height > lineRect.Width * 1.5f)
                {
                    lineData.angleType = WordAngleType.Vertical;
                }
                else
                {
                    lineData.angleType = WordAngleType.Horizontal;
                }
            }

            //전체 영역 처리.
            if (resultData.lineDataList.Count == 1)
            {
                resultData.resultRect = resultData.lineDataList[0].lineRect;
            }
            else if (resultData.lineDataList.Count > 1)
            {
                resultData.resultRect = resultData.lineDataList[0].lineRect;
                for (int i = 1; i < resultData.lineDataList.Count; i++)
                {
                    resultData.resultRect = Rectangle.Union(resultData.resultRect, resultData.lineDataList[i].lineRect);
                }
            }
            resultData.InitLine();
            dataList.Add(resultData);



            return(resultData);
        }