Exemplo n.º 1
0
        public static string getTargetText(Bitmap source, string targetText)
        {
            ///////////// ini 객체 생성 시작 /////////////////////////////////////////////////////
            //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
            FileInfo exefileinfo = new FileInfo(@"C:\Program Files\PLOCR\PLOCR.exe");
            string   pathini     = exefileinfo.Directory.FullName.ToString(); //프로그램 실행되고 있는데 path 가져오기
            string   fileName    = @"\PLOCRconfig.ini";                       // 환경설정 파일명
            string   filePath    = pathini + fileName;                        //ini 파일 경로

            PLOCR.IniUtil ini = new PLOCR.IniUtil(filePath);                  // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

            decimal x3old  = decimal.Parse(ini.GetIniValue(targetText, "X"));
            decimal y3old  = decimal.Parse(ini.GetIniValue(targetText, "Y"));
            decimal x1new  = (decimal)Global.coordNo1X;
            decimal x2new  = (decimal)Global.coordNo2X;
            int     x3new  = NewPointX(x3old, x1new, x2new);
            decimal y1new  = (decimal)Global.coordNo1Y;
            decimal y2new  = (decimal)Global.coordNo2Y;
            int     y3new  = NewPointY(y3old, y1new, y2new);
            int     width  = int.Parse(ini.GetIniValue(targetText, "가로"));
            int     height = int.Parse(ini.GetIniValue(targetText, "세로"));

            string returnText = OcrEngine.ocrDigit(source, x3new, y3new, width, height);

            return(returnText);
        }
Exemplo n.º 2
0
        public static string getDrugCodeDrugNameArea(Bitmap source)
        {
            ///////////// ini 객체 생성 시작 /////////////////////////////////////////////////////
            //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
            FileInfo exefileinfo = new FileInfo(@"C:\Program Files\PLOCR\PLOCR.exe");
            string   pathini     = exefileinfo.Directory.FullName.ToString(); //프로그램 실행되고 있는데 path 가져오기
            string   fileName    = @"\PLOCRconfig.ini";                       // 환경설정 파일명
            string   filePath    = pathini + fileName;                        //ini 파일 경로

            PLOCR.IniUtil ini = new PLOCR.IniUtil(filePath);                  // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

            int x      = int.Parse(ini.GetIniValue("약품영역지정", "X"));
            int y      = int.Parse(ini.GetIniValue("약품영역지정", "Y"));
            int width  = int.Parse(ini.GetIniValue("약품영역지정", "가로"));
            int height = int.Parse(ini.GetIniValue("약품영역지정", "세로"));

            string tDrugCodeDrugName = OcrEngine.hocrRect(source, x, y, width, height);

            return(tDrugCodeDrugName);
        }
Exemplo n.º 3
0
        public static void divSearch1(Bitmap source)
        {
            ///////////// ini 객체 생성 시작 /////////////////////////////////////////////////////
            //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
            FileInfo exefileinfo = new FileInfo(@"C:\Program Files\PLOCR\PLOCR.exe");
            string   pathini     = exefileinfo.Directory.FullName.ToString(); //프로그램 실행되고 있는데 path 가져오기
            string   fileName    = @".\PLOCRconfig.ini";                      // 환경설정 파일명
            string   filePath    = pathini + fileName;                        //ini 파일 경로

            PLOCR.IniUtil ini = new PLOCR.IniUtil(filePath);                  // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

            string coordAreaNo1 = ini.GetIniValue("지정한 사분면", "좌표1번사분면");
            string standardNo1  = ini.GetIniValue("좌표텍스트", "좌표1번");

            if (standardNo1 != "")
            {
                if (coordAreaNo1 == "1사분면")
                {
                    int x = (int)calculator.quadrantX(1);
                    int y = 0;

                    //string path = @"C:\Program Files\PLOCR\prescription.png";
                    //Bitmap source = (Bitmap)Bitmap.FromFile(path);
                    string htext = OcrEngine.hocrRect(source, x, y, (int)(source.Width / 2), (int)(source.Height / 2));

                    int standardX, standardY, standardWidth, standardHeight;
                    startXYRect(htext, standardNo1, out standardX, out standardY, out standardWidth, out standardHeight);

                    Global.coordNo1X = standardX;
                    Global.coordNo1Y = standardY;
                }
                else if (coordAreaNo1 == "2사분면")
                {
                    int x = 0;
                    int y = 0;

                    //string path = @"C:\Program Files\PLOCR\prescription.png";
                    //Bitmap source = (Bitmap)Bitmap.FromFile(path);
                    string htext = OcrEngine.hocrRect(source, x, y, (int)(source.Width / 2), (int)(source.Height / 2));

                    int standardX, standardY, standardWidth, standardHeight;
                    startXYRect(htext, standardNo1, out standardX, out standardY, out standardWidth, out standardHeight);

                    Global.coordNo1X = standardX;
                    Global.coordNo1Y = standardY;
                }
                else if (coordAreaNo1 == "3사분면")
                {
                    int x = 0;
                    int y = (int)calculator.quadrantY(3);

                    //string path = @"C:\Program Files\PLOCR\prescription.png";
                    //Bitmap source = (Bitmap)Bitmap.FromFile(path);
                    string htext = OcrEngine.hocrRect(source, x, y, (int)(source.Width / 2), (int)(source.Height / 2));

                    int standardX, standardY, standardWidth, standardHeight;
                    startXYRect(htext, standardNo1, out standardX, out standardY, out standardWidth, out standardHeight);

                    Global.coordNo1X = standardX;
                    Global.coordNo1Y = standardY;
                }
                else if (coordAreaNo1 == "4사분면")
                {
                    int x = (int)calculator.quadrantX(4);
                    int y = (int)calculator.quadrantX(4);

                    //string path = @"C:\Program Files\PLOCR\prescription.png";
                    //Bitmap source = (Bitmap)Bitmap.FromFile(path);
                    string htext = OcrEngine.hocrRect(source, x, y, (int)(source.Width / 2), (int)(source.Height / 2));

                    int standardX, standardY, standardWidth, standardHeight;
                    startXYRect(htext, standardNo1, out standardX, out standardY, out standardWidth, out standardHeight);

                    Global.coordNo1X = standardX;
                    Global.coordNo1Y = standardY;
                }
                else if (coordAreaNo1 == "특정영역1")
                {
                    int x      = int.Parse(ini.GetIniValue("특정좌표영역1", "X"));
                    int y      = int.Parse(ini.GetIniValue("특정좌표영역1", "Y"));
                    int width  = int.Parse(ini.GetIniValue("특정좌표영역1", "가로"));
                    int height = int.Parse(ini.GetIniValue("특정좌표영역1", "세로"));

                    //string path = @"C:\Program Files\PLOCR\prescription.png";
                    //Bitmap source = (Bitmap)Bitmap.FromFile(path);
                    string htext = OcrEngine.hocrRect(source, x, y, width, height);

                    int standardX, standardY, standardWidth, standardHeight;
                    startXYRect(htext, standardNo1, out standardX, out standardY, out standardWidth, out standardHeight);

                    Global.coordNo1X = standardX;
                    Global.coordNo1Y = standardY;
                }
                else if (coordAreaNo1 == "특정영역2")
                {
                    int x      = int.Parse(ini.GetIniValue("특정좌표영역2", "X"));
                    int y      = int.Parse(ini.GetIniValue("특정좌표영역2", "Y"));
                    int width  = int.Parse(ini.GetIniValue("특정좌표영역2", "가로"));
                    int height = int.Parse(ini.GetIniValue("특정좌표영역2", "세로"));

                    //string path = @"C:\Program Files\PLOCR\prescription.png";
                    //Bitmap source = (Bitmap)Bitmap.FromFile(path);
                    string htext = OcrEngine.hocrRect(source, x, y, width, height);

                    int standardX, standardY, standardWidth, standardHeight;
                    startXYRect(htext, standardNo1, out standardX, out standardY, out standardWidth, out standardHeight);

                    Global.coordNo1X = standardX;
                    Global.coordNo1Y = standardY;
                }
                else if (coordAreaNo1 == "전체영역")
                {
                    //string path = @"C:\Program Files\PLOCR\prescription.png";
                    //Bitmap source = (Bitmap)Bitmap.FromFile(path);
                    string htext = OcrEngine.hocrRect(source, 0, 0, source.Width, source.Height);

                    int standardX, standardY, standardWidth, standardHeight;
                    startXYRect(htext, standardNo1, out standardX, out standardY, out standardWidth, out standardHeight);

                    Global.coordNo1X = standardX;
                    Global.coordNo1Y = standardY;
                }
            }
            else
            {
                MessageBox.Show("환경설정에서 좌표 1번을 등록해주세요.");              // 기준좌표 1번이 등록되지 않은 경우의 처리
                System.Diagnostics.Process.GetCurrentProcess().Kill(); // 프로그램 강제 종료
            }
        }
Exemplo n.º 4
0
        public static string[] getDrugDay(Bitmap source)
        {
            ///////////// ini 객체 생성 시작 /////////////////////////////////////////////////////
            //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
            FileInfo exefileinfo = new FileInfo(@"C:\Program Files\PLOCR\PLOCR.exe");
            string   pathini     = exefileinfo.Directory.FullName.ToString(); //프로그램 실행되고 있는데 path 가져오기
            string   fileName    = @"\PLOCRconfig.ini";                       // 환경설정 파일명
            string   filePath    = pathini + fileName;                        //ini 파일 경로

            PLOCR.IniUtil ini = new PLOCR.IniUtil(filePath);                  // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

            int ct = 0;

            String[] tText = new String[13];  // 약품코드, 투약량, 횟수, 일수의 세로 13칸을 텍스트 배열로 넣기위해

            decimal[] x3old  = new decimal[13];
            decimal[] y3old  = new decimal[13];
            int[]     x3new  = new int[13];
            int[]     y3new  = new int[13];
            int[]     width  = new int[13];
            int[]     height = new int[13];

            do
            {
                string checkDayX = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "총투약일수", "X");
                if (checkDayX != "")
                {
                    x3old[ct] = decimal.Parse(checkDayX);
                }
                string checkDayY = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "총투약일수", "Y");
                if (checkDayY != "")
                {
                    y3old[ct] = decimal.Parse(checkDayY);
                }
                decimal x1new = (decimal)Global.coordNo1X;
                decimal x2new = (decimal)Global.coordNo2X;
                x3new[ct] = NewPointX(x3old[ct], x1new, x2new);
                decimal y1new = (decimal)Global.coordNo1Y;
                decimal y2new = (decimal)Global.coordNo2Y;
                y3new[ct] = NewPointY(y3old[ct], y1new, y2new);
                string checkDayWidth = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "총투약일수", "가로");
                if (checkDayWidth != "")
                {
                    width[ct] = int.Parse(checkDayWidth);
                }
                string checkDayHeith = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "총투약일수", "세로");
                if (checkDayHeith != "")
                {
                    height[ct] = int.Parse(checkDayHeith);
                }

                //    MessageBox.Show("총투약일수 좌표는 : " + x3new[ct] + " " + y3new[ct]);

                tText[ct] = OcrEngine.ocrDigitLine(source, x3new[ct], y3new[ct], width[ct], height[ct]);

                //      MessageBox.Show("총투약일수는 = " + tText[ct]);

                if (string.IsNullOrEmpty(tText[ct]) == true)
                {
                    break;
                }

                ++ct;
            }while (ct < 13);
            {
                Global.Endct[4] = ct - 1;
                //         MessageBox.Show("Endcd[4]=" + Global.Endct[4]);
                return(tText);   // tText 배열로 텍스트 반환
            }
        }
Exemplo n.º 5
0
        public static string[] getDrugName(Bitmap source)
        {
            ///////////// ini 객체 생성 시작 /////////////////////////////////////////////////////
            //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
            FileInfo exefileinfo = new FileInfo(@"C:\Program Files\PLOCR\PLOCR.exe");
            string   pathini     = exefileinfo.Directory.FullName.ToString(); //프로그램 실행되고 있는데 path 가져오기
            string   fileName    = @"\PLOCRconfig.ini";                       // 환경설정 파일명
            string   filePath    = pathini + fileName;                        //ini 파일 경로

            PLOCR.IniUtil ini = new PLOCR.IniUtil(filePath);                  // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

            int ct = 0;

            String[] tText = new String[13];  // 약품코드, 투약량, 횟수, 일수의 세로 13칸을 텍스트 배열로 넣기위해

            decimal[] x3old  = new decimal[13];
            decimal[] y3old  = new decimal[13];
            int[]     x3new  = new int[13];
            int[]     y3new  = new int[13];
            int[]     width  = new int[13];
            int[]     height = new int[13];

            do
            {
                string checkDrugNameX = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품명", "X");
                if (checkDrugNameX != "")
                {
                    x3old[ct] = decimal.Parse(checkDrugNameX);
                }
                else
                {
                    MessageBox.Show("환경설정에서 약품명 X 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                string checkDrugNameY = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품명", "Y");
                if (checkDrugNameY != "")
                {
                    y3old[ct] = decimal.Parse(checkDrugNameY);
                }
                else
                {
                    MessageBox.Show("환경설정에서 약품명 Y 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                decimal x1new = (decimal)Global.coordNo1X;
                decimal x2new = (decimal)Global.coordNo2X;
                x3new[ct] = NewPointX(x3old[ct], x1new, x2new);
                decimal y1new = (decimal)Global.coordNo1Y;
                decimal y2new = (decimal)Global.coordNo2Y;
                y3new[ct] = NewPointY(y3old[ct], y1new, y2new);
                string checkDrugNameWidth = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품명", "가로");
                if (checkDrugNameWidth != "")
                {
                    width[ct] = int.Parse(checkDrugNameWidth);
                }
                else
                {
                    MessageBox.Show("환경설정에서 약품명 가로 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                string checkDrugNameHeight = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품명", "세로");
                if (checkDrugNameHeight != "")
                {
                    height[ct] = int.Parse(checkDrugNameHeight);
                }
                else
                {
                    MessageBox.Show("환경설정에서 약품명 세로 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }

                //       MessageBox.Show("약품명 좌표는 : " + x3new[ct] + " " + y3new[ct]);

                tText[ct] = OcrEngine.ocrTextLine(source, x3new[ct], y3new[ct], width[ct], height[ct]);

                //        MessageBox.Show("약품명은 = " + tText[ct]);

                if (string.IsNullOrEmpty(tText[ct]) == true)
                {
                    break;
                }

                ++ct;
            }while (ct < 13);
            {
                Global.Endct[1] = ct - 1;
                return(tText);   // tText 배열로 텍스트 반환
            }
        }