示例#1
0
        public static Bitmap originalcheck(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 exeNo1 = ini.GetIniValue("실행 순서", "1단계");
            string exeNo2 = ini.GetIniValue("실행 순서", "2단계");
            string exeNo3 = ini.GetIniValue("실행 순서", "3단계");
            string exeNo4 = ini.GetIniValue("실행 순서", "4단계");
            string exeNo5 = ini.GetIniValue("실행 순서", "5단계");
            string exeNo6 = ini.GetIniValue("실행 순서", "6단계");
            string exeNo7 = ini.GetIniValue("실행 순서", "7단계");

            if (exeNo1 == "원본" ||
                exeNo2 == "원본" ||
                exeNo3 == "원본" ||
                exeNo4 == "원본" ||
                exeNo5 == "원본" ||
                exeNo6 == "원본" ||
                exeNo7 == "원본")
            {
                string path = @"C:\Program Files\PLOCR\prescription.png";
                source = (Bitmap)Bitmap.FromFile(path);
            }
            return(source);
        }
示例#2
0
        public static Bitmap thick(Bitmap source)        // 선 굵게, 24비트로 넣어줘야함
        {
            ///////////// 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 order = int.Parse(ini.GetIniValue("선굵기값", "굵게횟수"));

            for (int i = 0; i < order; i++)
            {
                Bitmap tmp = (Bitmap)source;        // 중요! 한번 이미지 처리가 끝난 비트맵 source 는 clone 함수로 보내기 전에 다시 한번 (Bitmap) 처리 해줘야함, 이유는 잘 모르겠음
                // convert to 24 bits per pixel
                source = ImageProcess.Clone(tmp, PixelFormat.Format24bppRgb);
                // delete old image
                tmp.Dispose();

                Erosion filter = new Erosion();
                filter.ApplyInPlace(source);;
            }

            return(source);
        }
示例#3
0
        public static Bitmap RGBfilter(Bitmap source)     // rgb 필터
        {
            ///////////// 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 redMin   = int.Parse(ini.GetIniValue("색상필터값", "RedMin"));
            int redMax   = int.Parse(ini.GetIniValue("색상필터값", "RedMax"));
            int greenMin = int.Parse(ini.GetIniValue("색상필터값", "GreenMin"));
            int greenMax = int.Parse(ini.GetIniValue("색상필터값", "GreenMax"));
            int blueMin  = int.Parse(ini.GetIniValue("색상필터값", "BlueMin"));
            int blueMax  = int.Parse(ini.GetIniValue("색상필터값", "BlueMax"));

            // create filter
            ColorFiltering filter = new ColorFiltering();

            // set color ranges to keep
            filter.Red   = new IntRange(redMin, redMax);
            filter.Green = new IntRange(greenMin, greenMax);
            filter.Blue  = new IntRange(blueMin, blueMax);
            Bitmap processedImage = filter.Apply(source);

            return(processedImage);
        }
示例#4
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);
        }
示例#5
0
        public static int NewPointX(decimal x3old, decimal x1new, decimal x2new)  // old 는 기준처방전 new 는 실제처방전, 1 과 2는 기준좌표 두점을 말하고, 모르는 제3의 new 를 찾는 함수
        {
            ///////////// 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 x1old = decimal.Parse(ini.GetIniValue("스캔으로 찾은 좌표1번", "X"));
            decimal x2old = decimal.Parse(ini.GetIniValue("스캔으로 찾은 좌표2번", "X"));

            //MessageBox.Show("x1old = " + x1old);
            //MessageBox.Show("x2old = " + x2old);
            //MessageBox.Show("x3old = " + x3old);

            //MessageBox.Show("x1new = " + x1new);
            //MessageBox.Show("x2new = " + x2new);

            decimal x3new = 0;
            //    decimal factor = ((Math.Abs(x2new - x1new)) / (Math.Abs(x2old - x1old)));      // factor 과 NewPoint 함수에 들어가는 인자들은 소수점까지 계산해야 하므로 반드시 "decimal" 로 해야 한다.
            decimal factor = 1;         // 위 방법으로는 오차가 너무 많이 생겨서 처리 불가능, 나중에 해결책을 찾아보기로 하고 모든 처방전이 동일한 크기라 보고 단순 거리 비교만 하기로 함

            //MessageBox.Show("x2new-x1new = " + (x2new - x1new).ToString());
            //MessageBox.Show("x2old-x1old = " + (x2old - x1old).ToString());
            //MessageBox.Show("Math.Abs(x2new - x1new) = " + (Math.Abs(x2new - x1new)).ToString());
            //MessageBox.Show("Math.Abs(x2old - x1old) = " + (Math.Abs(x2old - x1old)).ToString());
            //MessageBox.Show("factor x = " + factor.ToString());

            if ((x3old - x1old) < 0)
            {
                x3new = x1new - (Math.Abs(x3old - x1old) * factor);  // x1old 는 기준처방의 1번좌표, x2old 는 기준처방의 2번좌표, x3old 는 사용자가 지정한 기준처방의 좌표
            }                                                        // x1new 는 실제처방의 1번좌표, x2new 는 실제처방의 2번좌표, x3new 는 찾으려고 하는 좌표
            else if ((x3old - x1old) > 0)
            {
                x3new = (Math.Abs(x3old - x1old) * factor) + x1new;
            }
            else if (x3old == x1old)
            {
                MessageBox.Show("환경설정에서 좌표1번 과 좌표2번을 다시 설정해주세요.");
                System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
            }

            //  MessageBox.Show("x3new = " + x3new);

            return((int)x3new);  // 실제처방전의 원하는 좌표 x 값
        }
示例#6
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);
        }
示例#7
0
        // 밝게
        public static Bitmap bright(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 order = int.Parse(ini.GetIniValue("밝기값", "밝게횟수"));

            for (int i = 0; i < order; i++)
            {
                // create filter
                BrightnessCorrection filter = new BrightnessCorrection(+10);
                // apply the filter
                filter.ApplyInPlace(source);
            }

            return source;
        }
示例#8
0
        //   public static void zeroSearch(string HtmlText,
        //       out int zeroWidth,
        //       out int zeroHeight,
        //       out int ScaleX,
        //       out int ScaleY,
        //       out int distancePatientX, out int distancePatientY, out int sizePatientHor, out int sizePatientVer,
        //       out int distanceDoctorX, out int distanceDoctorY, out int sizeDoctorHor, out int sizeDoctorVer,
        //       out int distancePreNumX, out int distancePreNumY, out int sizePreNumHor, out int sizePreNumVer,
        //       out int distanceDrugCodeX, out int distanceDrugCodeY, out int sizeDrugCodeHor, out int sizeDrugCodeVer,
        //       out int distanceDoseX, out int distanceDoseY, out int sizeDoseHor, out int sizeDoseVer,
        //       out int distanceTimeX, out int distanceTimeY, out int sizeTimeHor, out int sizeTimeVer,
        //       out int distanceDayX, out int distanceDayY, out int sizeDayHor, out int sizeDayVer,
        //       out int jumpY,
        //       out int factor)
        //   {
        //       ///////////// 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 CatchText1 = ini.GetIniValue("좌표영점", "1번좌표");
        //       int factor1 = int.Parse(ini.GetIniValue("좌표영점", "1번좌표factor"));
        //       MessageBox.Show(CatchText1.ToString(), factor1.ToString());
        //       String CatchText2 = ini.GetIniValue("좌표영점", "2번좌표");
        //       int factor2 = int.Parse(ini.GetIniValue("좌표영점", "2번좌표factor"));
        //       MessageBox.Show(CatchText2.ToString(), factor2.ToString());
        //       String CatchText3 = ini.GetIniValue("좌표영점", "3번좌표");
        //       int factor3 = int.Parse(ini.GetIniValue("좌표영점", "3번좌표factor"));
        //       MessageBox.Show(CatchText3.ToString(), factor3.ToString());

        //       int XYzeroWidth = 0, XYzeroHeight = 0, XYScaleX = 0, XYScaleY = 0;

        //       int PdistancePatientX = 0, PdistancePatientY = 0, PsizePatientHor = 0, PsizePatientVer = 0;
        //       int PdistanceDoctorX=0, PdistanceDoctorY=0, PsizeDoctorHor=0, PsizeDoctorVer=0;
        //       int PdistancePreNumX=0, PdistancePreNumY=0, PsizePreNumHor=0, PsizePreNumVer=0;
        //       int PdistanceDrugCodeX = 0, PdistanceDrugCodeY = 0, PsizeDrugCodeHor = 0, PsizeDrugCodeVer = 0;
        //       int PdistanceDoseX=0, PdistanceDoseY=0, PsizeDoseHor=0, PsizeDoseVer=0;
        //       int PdistanceTimeX=0, PdistanceTimeY=0, PsizeTimeHor=0, PsizeTimeVer=0;
        //       int PdistanceDayX=0, PdistanceDayY=0, PsizeDayHor=0, PsizeDayVer=0;
        //       int PjumpY=0;
        //       int Pfactor=0;

        //       if (HtmlText.Contains(CatchText1))
        //       {
        //           ZeroXY(HtmlText, CatchText1, factor1, out XYzeroWidth, out XYzeroHeight, out XYScaleX, out XYScaleY);

        //           PdistancePatientX = int.Parse(ini.GetIniValue(CatchText1, "distancePatientX"));
        //           PdistancePatientY = int.Parse(ini.GetIniValue(CatchText1, "distancePatientY"));
        //           PsizePatientHor = int.Parse(ini.GetIniValue(CatchText1, "sizePatientHor"));
        //           PsizePatientVer = int.Parse(ini.GetIniValue(CatchText1, "sizePatientVer"));
        //           PdistanceDoctorX = int.Parse(ini.GetIniValue(CatchText1, "distanceDoctorX"));
        //           PdistanceDoctorY = int.Parse(ini.GetIniValue(CatchText1, "distanceDoctorY"));
        //           PsizeDoctorHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDoctorHor"));
        //           PsizeDoctorVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDoctorVer"));
        //           PdistancePreNumX = int.Parse(ini.GetIniValue(CatchText1, "distancePreNumX"));
        //           PdistancePreNumY = int.Parse(ini.GetIniValue(CatchText1, "distancePreNumY"));
        //           PsizePreNumHor = int.Parse(ini.GetIniValue(CatchText1, "sizePreNumHor"));
        //           PsizePreNumVer = int.Parse(ini.GetIniValue(CatchText1, "sizePreNumVer"));
        //           PdistanceDrugCodeX = int.Parse(ini.GetIniValue(CatchText1, "distanceDrugCodeX"));
        //           PdistanceDrugCodeY = int.Parse(ini.GetIniValue(CatchText1, "distanceDrugCodeY"));
        //           PsizeDrugCodeHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDrugCodeHor"));
        //           PsizeDrugCodeVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDrugCodeVer"));
        //           PdistanceDoseX = int.Parse(ini.GetIniValue(CatchText1, "distanceDoseX"));
        //           PdistanceDoseY = int.Parse(ini.GetIniValue(CatchText1, "distanceDoseY"));
        //           PsizeDoseHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDoseHor"));
        //           PsizeDoseVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDoseVer"));
        //           PdistanceTimeX = int.Parse(ini.GetIniValue(CatchText1, "distanceTimeX"));
        //           PdistanceTimeY = int.Parse(ini.GetIniValue(CatchText1, "distanceTimeY"));
        //           PsizeTimeHor = int.Parse(ini.GetIniValue(CatchText1, "sizeTimeHor"));
        //           PsizeTimeVer = int.Parse(ini.GetIniValue(CatchText1, "sizeTimeVer"));
        //           PdistanceDayX = int.Parse(ini.GetIniValue(CatchText1, "distanceDayX"));
        //           PdistanceDayY = int.Parse(ini.GetIniValue(CatchText1, "distanceDayY"));
        //           PsizeDayHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDayHor"));
        //           PsizeDayVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDayVer"));
        //           PjumpY = int.Parse(ini.GetIniValue(CatchText1, "jumpY"));
        //           Pfactor = int.Parse(ini.GetIniValue(CatchText1, "factor"));

        //    //       Console.WriteLine("1번좌표로 영점을 잡았습니다. \n");
        //       }
        //       else if (HtmlText.Contains(CatchText2))
        //       {
        //           ZeroXY(HtmlText, CatchText2, factor2, out XYzeroWidth, out XYzeroHeight, out XYScaleX, out XYScaleY);

        //           PdistancePatientX = int.Parse(ini.GetIniValue(CatchText2, "distancePatientX"));
        //           PdistancePatientY = int.Parse(ini.GetIniValue(CatchText2, "distancePatientY"));
        //           PsizePatientHor = int.Parse(ini.GetIniValue(CatchText2, "sizePatientHor"));
        //           PsizePatientVer = int.Parse(ini.GetIniValue(CatchText2, "sizePatientVer"));
        //           PdistanceDoctorX = int.Parse(ini.GetIniValue(CatchText2, "distanceDoctorX"));
        //           PdistanceDoctorY = int.Parse(ini.GetIniValue(CatchText2, "distanceDoctorY"));
        //           PsizeDoctorHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDoctorHor"));
        //           PsizeDoctorVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDoctorVer"));
        //           PdistancePreNumX = int.Parse(ini.GetIniValue(CatchText2, "distancePreNumX"));
        //           PdistancePreNumY = int.Parse(ini.GetIniValue(CatchText2, "distancePreNumY"));
        //           PsizePreNumHor = int.Parse(ini.GetIniValue(CatchText2, "sizePreNumHor"));
        //           PsizePreNumVer = int.Parse(ini.GetIniValue(CatchText2, "sizePreNumVer"));
        //           PdistanceDrugCodeX = int.Parse(ini.GetIniValue(CatchText2, "distanceDrugCodeX"));
        //           PdistanceDrugCodeY = int.Parse(ini.GetIniValue(CatchText2, "distanceDrugCodeY"));
        //           PsizeDrugCodeHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDrugCodeHor"));
        //           PsizeDrugCodeVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDrugCodeVer"));
        //           PdistanceDoseX = int.Parse(ini.GetIniValue(CatchText2, "distanceDoseX"));
        //           PdistanceDoseY = int.Parse(ini.GetIniValue(CatchText2, "distanceDoseY"));
        //           PsizeDoseHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDoseHor"));
        //           PsizeDoseVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDoseVer"));
        //           PdistanceTimeX = int.Parse(ini.GetIniValue(CatchText2, "distanceTimeX"));
        //           PdistanceTimeY = int.Parse(ini.GetIniValue(CatchText2, "distanceTimeY"));
        //           PsizeTimeHor = int.Parse(ini.GetIniValue(CatchText2, "sizeTimeHor"));
        //           PsizeTimeVer = int.Parse(ini.GetIniValue(CatchText2, "sizeTimeVer"));
        //           PdistanceDayX = int.Parse(ini.GetIniValue(CatchText2, "distanceDayX"));
        //           PdistanceDayY = int.Parse(ini.GetIniValue(CatchText2, "distanceDayY"));
        //           PsizeDayHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDayHor"));
        //           PsizeDayVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDayVer"));
        //           PjumpY = int.Parse(ini.GetIniValue(CatchText2, "jumpY"));
        //           Pfactor = int.Parse(ini.GetIniValue(CatchText2, "factor"));

        //    //       Console.WriteLine("2번좌표로 영점을 잡았습니다. \n");
        //       }
        //       else if(HtmlText.Contains(CatchText3))
        //       {
        //           ZeroXY(HtmlText, CatchText3, factor3, out XYzeroWidth, out XYzeroHeight, out XYScaleX, out XYScaleY);

        //           PdistancePatientX = int.Parse(ini.GetIniValue(CatchText3, "distancePatientX"));
        //           PdistancePatientY = int.Parse(ini.GetIniValue(CatchText3, "distancePatientY"));
        //           PsizePatientHor = int.Parse(ini.GetIniValue(CatchText3, "sizePatientHor"));
        //           PsizePatientVer = int.Parse(ini.GetIniValue(CatchText3, "sizePatientVer"));
        //           PdistanceDoctorX = int.Parse(ini.GetIniValue(CatchText3, "distanceDoctorX"));
        //           PdistanceDoctorY = int.Parse(ini.GetIniValue(CatchText3, "distanceDoctorY"));
        //           PsizeDoctorHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDoctorHor"));
        //           PsizeDoctorVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDoctorVer"));
        //           PdistancePreNumX = int.Parse(ini.GetIniValue(CatchText3, "distancePreNumX"));
        //           PdistancePreNumY = int.Parse(ini.GetIniValue(CatchText3, "distancePreNumY"));
        //           PsizePreNumHor = int.Parse(ini.GetIniValue(CatchText3, "sizePreNumHor"));
        //           PsizePreNumVer = int.Parse(ini.GetIniValue(CatchText3, "sizePreNumVer"));
        //           PdistanceDrugCodeX = int.Parse(ini.GetIniValue(CatchText3, "distanceDrugCodeX"));
        //           PdistanceDrugCodeY = int.Parse(ini.GetIniValue(CatchText3, "distanceDrugCodeY"));
        //           PsizeDrugCodeHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDrugCodeHor"));
        //           PsizeDrugCodeVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDrugCodeVer"));
        //           PdistanceDoseX = int.Parse(ini.GetIniValue(CatchText3, "distanceDoseX"));
        //           PdistanceDoseY = int.Parse(ini.GetIniValue(CatchText3, "distanceDoseY"));
        //           PsizeDoseHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDoseHor"));
        //           PsizeDoseVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDoseVer"));
        //           PdistanceTimeX = int.Parse(ini.GetIniValue(CatchText3, "distanceTimeX"));
        //           PdistanceTimeY = int.Parse(ini.GetIniValue(CatchText3, "distanceTimeY"));
        //           PsizeTimeHor = int.Parse(ini.GetIniValue(CatchText3, "sizeTimeHor"));
        //           PsizeTimeVer = int.Parse(ini.GetIniValue(CatchText3, "sizeTimeVer"));
        //           PdistanceDayX = int.Parse(ini.GetIniValue(CatchText3, "distanceDayX"));
        //           PdistanceDayY = int.Parse(ini.GetIniValue(CatchText3, "distanceDayY"));
        //           PsizeDayHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDayHor"));
        //           PsizeDayVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDayVer"));
        //           PjumpY = int.Parse(ini.GetIniValue(CatchText3, "jumpY"));
        //           Pfactor = int.Parse(ini.GetIniValue(CatchText3, "factor"));

        //    //       Console.WriteLine("3번좌표로 영점을 잡았습니다. \n");
        //       }
        //       else
        //       {
        //           MessageBox.Show("좌표영점 인식에 실패했습니다.\n 좌표영점을 더 추가해서\n 인식률을 개선시켜 놓을께요.");
        ////           Console.WriteLine("ocr 좌표영점 인식에 실패했습니다.");
        //       }

        //       zeroWidth = XYzeroWidth; zeroHeight = XYzeroHeight; ScaleX = XYScaleX; ScaleY = XYScaleY;

        //       distancePatientX=PdistancePatientX; distancePatientY=PdistancePatientY; sizePatientHor=PsizePatientHor; sizePatientVer=PsizePatientVer;
        //       distanceDoctorX=PdistanceDoctorX; distanceDoctorY=PdistanceDoctorY; sizeDoctorHor=PsizeDoctorHor; sizeDoctorVer=PsizeDoctorVer;
        //       distancePreNumX = PdistancePreNumX; distancePreNumY = PdistancePreNumY; sizePreNumHor = PsizePreNumHor; sizePreNumVer = PsizePreNumVer;
        //       distanceDrugCodeX = PdistanceDrugCodeX; distanceDrugCodeY = PdistanceDrugCodeY; sizeDrugCodeHor = PsizeDrugCodeHor; sizeDrugCodeVer = PsizeDrugCodeVer;
        //       distanceDoseX = PdistanceDoseX; distanceDoseY = PdistanceDoseY; sizeDoseHor = PsizeDoseHor; sizeDoseVer = PsizeDoseVer;
        //       distanceTimeX=PdistanceTimeX; distanceTimeY=PdistanceTimeY; sizeTimeHor=PsizeTimeHor; sizeTimeVer=PsizeTimeVer;
        //       distanceDayX=PdistanceDayX; distanceDayY=PdistanceDayY; sizeDayHor=PsizeDayHor; sizeDayVer=PsizeDayVer;
        //       jumpY=PjumpY;
        //       factor=Pfactor;
        //   }



        //public static void ZeroXY(
        //    string HtmlText,
        //    string CatchText,
        //    int factor,
        //    out int XYzeroWidth,
        //    out int XYzeroHeight,
        //    out int XYScaleX,
        //    out int XYScaleY)   // 찾고자 하는 좌표영점의 문자를 주고, Html 텍스트 중에서 해당문자의 x,y 좌표를 반환한다.
        //{
        //    int x1 = 0, y1 = 0, x2 = 0, y2 = 0;

        //    int ZeroIndex = HtmlText.IndexOf(CatchText);  // 주어진 문자열로 기준이 되는 문자열 인덱스를 찾고,
        //    string ZeroRange = HtmlText.Substring(ZeroIndex - 30, 30); // 기준 문자열부터 앞쪽으로 30 인덱스 부분부터 기준까지의 문자열을 선택하고,

        //  //     Console.WriteLine(ZeroRange);

        //    char[] delimiterChars = { ' ' };
        //    string[] ZeroDiv = ZeroRange.Split(delimiterChars);  // 공백을 기준으로 문자열을 분리하고

        //    for (int ct = 0; ct < ZeroDiv.Length; ct++)
        //    {
        //        if (Regex.IsMatch(ZeroDiv[ct], @"^-?\d+$"))  // 숫자인지 아닌지 판단
        //        {
        //            x1 = int.Parse(Regex.Replace(ZeroDiv[ct], "[^0-9.-]", ""));      // 숫자만 추출하여, x좌표 문자형 숫자를 정수형으로 형변환
        //            y1 = int.Parse(Regex.Replace(ZeroDiv[ct + 1], "[^0-9.-]", ""));    // 숫자만 추출하여, y좌표 문자형 숫자를 정수형으로 형변환
        //            x2 = int.Parse(Regex.Replace(ZeroDiv[ct+2], "[^0-9.-]", ""));
        //            y2 = int.Parse(Regex.Replace(ZeroDiv[ct+3], "[^0-9.-]", ""));

        //      //      Console.WriteLine(x1);
        //      //      Console.WriteLine(y1);
        //      //      Console.WriteLine(x2);
        //      //      Console.WriteLine(y2);

        //            ct = ZeroDiv.Length;  // 숫자요소를 가진 배열을 찾으면 루프 탈출
        //        }
        //    }

        //    XYzeroWidth = x2 - x1;
        //    XYzeroHeight = y2 - y1;
        //    XYScaleX = x1 * (factor / 10000000) / XYzeroWidth;
        //    XYScaleY = y1 * (factor / 10000000) / XYzeroWidth;

        ////    Console.WriteLine(XYzeroWidth);
        //}


        public static void standardSearch(string HtmlText, int quad, out int x, out int y)
        {
            ///////////// 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 standardY1    = ini.GetIniValue("좌표1번", "Y");
            string standardX2    = ini.GetIniValue("좌표2번", "X");
            string standardY2    = ini.GetIniValue("좌표2번", "Y");
            string standardText1 = ini.GetIniValue("좌표텍스트", "좌표1번");
            string standardText2 = ini.GetIniValue("좌표텍스트", "좌표1번");

            int standardX, standardY, standardWidth, standardHeight;

            startXY(HtmlText, standardText1, out standardX, out standardY, out standardWidth, out standardHeight);

            x = standardX; y = standardY;
        }
示例#9
0
        public static Bitmap bright(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 order = int.Parse(ini.GetIniValue("밝기값", "밝게횟수"));

            for (int i = 0; i < order; i++)
            {
                // create filter
                BrightnessCorrection filter = new BrightnessCorrection(+10);
                // apply the filter
                filter.ApplyInPlace(source);
            }

            return(source);
        }
示例#10
0
文件: typing.cs 项目: linuxbank/PLOCR
        public static void segType(IntPtr hDrugCode, IntPtr hDose, IntPtr hTime, IntPtr hDay, IntPtr hTotalDose, IntPtr hInsureCombo, IntPtr hTakeCombo, IntPtr hAlterCombo, string[] tDrugCode, string[] tDose, string[] tTime, string[] tDay, int EndctMax)
        {
            ///////////// 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 TimeSleep = int.Parse(ini.GetIniValue("입력설정", "입력대기시간"));

            int ct = 0;

            do
            {
                //if (string.IsNullOrEmpty(tDrugCode[ct]) == true)
                //{
                //    tDrugCode[ct] = "641100270";
                //}
                //if (string.IsNullOrEmpty(tDose[ct]) == true)
                //{
                //    tDose[ct] = "1";
                //}
                //if (string.IsNullOrEmpty(tTime[ct]) == true)
                //{
                //    tTime[ct] = "1";
                //}
                //if (string.IsNullOrEmpty(tDay[ct]) == true)
                //{
                //    tDay[ct] = "1";
                //}

                //    if (string.IsNullOrEmpty(Global.tDrugCode[ct]) == false)
                //    {
                System.Threading.Thread.Sleep(TimeSleep);

                if (tDrugCode[ct] != "")
                {
                    SendMessage(hDrugCode, WM_SETTEXT, 0, tDrugCode[ct]);
                    PostMessage(hDrugCode, 0x0100, 0xD, 0x1C001);
                    PostMessage(hDrugCode, 0x0102, 0xD, 0xC01C001);
                }

                //        if (string.IsNullOrEmpty(tDose[ct]) == false && string.IsNullOrEmpty(tTime[ct]) == false && string.IsNullOrEmpty(tDay[ct]) == false)
                //        {
                System.Threading.Thread.Sleep(TimeSleep);

                if (tDose[ct] != "")
                {
                    SendMessage(hDose, WM_SETTEXT, 0, tDose[ct]);
                    PostMessage(hDose, 0x0100, 0xD, 0x1C001);
                    PostMessage(hDose, 0x0102, 0xD, 0xC01C001);
                }

                System.Threading.Thread.Sleep(TimeSleep);

                if (tTime[ct] != "")
                {
                    SendMessage(hTime, WM_SETTEXT, 0, tTime[ct]);
                    PostMessage(hTime, 0x0100, 0xD, 0x1C001);
                    PostMessage(hTime, 0x0102, 0xD, 0xC01C001);
                }

                System.Threading.Thread.Sleep(TimeSleep);

                if (tDay[ct] != "")
                {
                    SendMessage(hDay, WM_SETTEXT, 0, tDay[ct]);
                    PostMessage(hDay, 0x0100, 0xD, 0x1C001);
                    PostMessage(hDay, 0x0102, 0xD, 0xC01C001);
                }

                //           System.Threading.Thread.Sleep(TimeSleep);

                //          float Dose = Convert.ToSingle(tDose[ct]);   // null 값을 무시하기 위해 parse 대신 convert 사용, 소수점이 있는 경우가 있으므로 float 변수로
                //         float Time = Convert.ToSingle(tTime[ct]);
                //         float Day = Convert.ToSingle(tDay[ct]);
                //           string TotalDose = (Dose * Time * Day).ToString();    // 총투약량을 계산하기 위해서 바로 위에 float 로 했지만, 실제 입력 필요없으므로 일단 주석처리

                //          SendMessage(hTotalDose, WM_SETTEXT, 0, TotalDose);
                //           PostMessage(hTotalDose, 0x0100, 0xD, 0x1C001);
                //           PostMessage(hTotalDose, 0x0102, 0xD, 0xC01C001);

                System.Threading.Thread.Sleep(TimeSleep);

                PostMessage(hInsureCombo, 0x0100, 0xD, 0x1C001);
                PostMessage(hInsureCombo, 0x0102, 0xD, 0xC01C001);
                System.Threading.Thread.Sleep(TimeSleep);

                PostMessage(hTakeCombo, 0x0100, 0xD, 0x1C001);
                PostMessage(hTakeCombo, 0x0102, 0xD, 0xC01C001);

                System.Threading.Thread.Sleep(TimeSleep);

                PostMessage(hAlterCombo, 0x0100, 0xD, 0x1C001);

                PostMessage(hAlterCombo, 0x0102, 0xD, 0xC01C001);

                System.Threading.Thread.Sleep(TimeSleep);
                //      }
                //        }

                //    Console.WriteLine(ct);
                //     Console.WriteLine(Global.EndctMax);
                ++ct;
            }while (ct <= EndctMax);
            {
            }
        }
示例#11
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();      // 프로그램 강제 종료

            }
        }
示例#12
0
        // 이미지 처리 몇단계까지 해야하나 확인하고 처리
        public static Bitmap sequence(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 exeNo1 = ini.GetIniValue("실행 순서", "1단계");
            string exeNo2 = ini.GetIniValue("실행 순서", "2단계");
            string exeNo3 = ini.GetIniValue("실행 순서", "3단계");
            string exeNo4 = ini.GetIniValue("실행 순서", "4단계");
            string exeNo5 = ini.GetIniValue("실행 순서", "5단계");
            string exeNo6 = ini.GetIniValue("실행 순서", "6단계");
            string exeNo7 = ini.GetIniValue("실행 순서", "7단계");

            if(exeNo7 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
                source = imgProcess(source, exeNo4);
                source = imgProcess(source, exeNo5);
                source = imgProcess(source, exeNo6);
            }
            else if(exeNo6 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
                source = imgProcess(source, exeNo4);
                source = imgProcess(source, exeNo5);
            }
            else if(exeNo5 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
                source = imgProcess(source, exeNo4);
            }
            else if (exeNo4 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
            }
            else if (exeNo3 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
            }
            else if (exeNo2 == "끝")
            {
                source = imgProcess(source, exeNo1);
            }
            else if (exeNo1 == "끝")
            {
            }

            return source;
        }
示例#13
0
文件: typing.cs 项目: linuxbank/PLOCR
        public static void segType(IntPtr hDrugCode, IntPtr hDose, IntPtr hTime, IntPtr hDay, IntPtr hTotalDose, IntPtr hInsureCombo, IntPtr hTakeCombo, IntPtr hAlterCombo, string[] tDrugCode, string[] tDose, string[] tTime, string[] tDay, int EndctMax)
        {
            ///////////// 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 TimeSleep = int.Parse(ini.GetIniValue("입력설정", "입력대기시간"));

            int ct = 0;

            do
            {
                //if (string.IsNullOrEmpty(tDrugCode[ct]) == true)
                //{
                //    tDrugCode[ct] = "641100270";
                //}
                //if (string.IsNullOrEmpty(tDose[ct]) == true)
                //{
                //    tDose[ct] = "1";
                //}
                //if (string.IsNullOrEmpty(tTime[ct]) == true)
                //{
                //    tTime[ct] = "1";
                //}
                //if (string.IsNullOrEmpty(tDay[ct]) == true)
                //{
                //    tDay[ct] = "1";
                //}

            //    if (string.IsNullOrEmpty(Global.tDrugCode[ct]) == false)
            //    {
                    System.Threading.Thread.Sleep(TimeSleep);

                    if (tDrugCode[ct] != "")
                    {
                        SendMessage(hDrugCode, WM_SETTEXT, 0, tDrugCode[ct]);
                        PostMessage(hDrugCode, 0x0100, 0xD, 0x1C001);
                        PostMessage(hDrugCode, 0x0102, 0xD, 0xC01C001);
                    }

            //        if (string.IsNullOrEmpty(tDose[ct]) == false && string.IsNullOrEmpty(tTime[ct]) == false && string.IsNullOrEmpty(tDay[ct]) == false)
            //        {
                        System.Threading.Thread.Sleep(TimeSleep);

                        if (tDose[ct] != "")
                        {
                            SendMessage(hDose, WM_SETTEXT, 0, tDose[ct]);
                            PostMessage(hDose, 0x0100, 0xD, 0x1C001);
                            PostMessage(hDose, 0x0102, 0xD, 0xC01C001);
                        }

                        System.Threading.Thread.Sleep(TimeSleep);

                        if (tTime[ct] != "")
                        {
                            SendMessage(hTime, WM_SETTEXT, 0, tTime[ct]);
                            PostMessage(hTime, 0x0100, 0xD, 0x1C001);
                            PostMessage(hTime, 0x0102, 0xD, 0xC01C001);
                        }

                        System.Threading.Thread.Sleep(TimeSleep);

                        if (tDay[ct] != "")
                        {
                            SendMessage(hDay, WM_SETTEXT, 0, tDay[ct]);
                            PostMessage(hDay, 0x0100, 0xD, 0x1C001);
                            PostMessage(hDay, 0x0102, 0xD, 0xC01C001);
                        }

             //           System.Threading.Thread.Sleep(TimeSleep);

              //          float Dose = Convert.ToSingle(tDose[ct]);   // null 값을 무시하기 위해 parse 대신 convert 사용, 소수점이 있는 경우가 있으므로 float 변수로
               //         float Time = Convert.ToSingle(tTime[ct]);
               //         float Day = Convert.ToSingle(tDay[ct]);
             //           string TotalDose = (Dose * Time * Day).ToString();    // 총투약량을 계산하기 위해서 바로 위에 float 로 했지만, 실제 입력 필요없으므로 일단 주석처리

              //          SendMessage(hTotalDose, WM_SETTEXT, 0, TotalDose);
             //           PostMessage(hTotalDose, 0x0100, 0xD, 0x1C001);
             //           PostMessage(hTotalDose, 0x0102, 0xD, 0xC01C001);

                        System.Threading.Thread.Sleep(TimeSleep);

                        PostMessage(hInsureCombo, 0x0100, 0xD, 0x1C001);
                        PostMessage(hInsureCombo, 0x0102, 0xD, 0xC01C001);
                        System.Threading.Thread.Sleep(TimeSleep);

                        PostMessage(hTakeCombo, 0x0100, 0xD, 0x1C001);
                        PostMessage(hTakeCombo, 0x0102, 0xD, 0xC01C001);

                        System.Threading.Thread.Sleep(TimeSleep);

                        PostMessage(hAlterCombo, 0x0100, 0xD, 0x1C001);

                        PostMessage(hAlterCombo, 0x0102, 0xD, 0xC01C001);

                        System.Threading.Thread.Sleep(TimeSleep);
              //      }
            //        }

            //    Console.WriteLine(ct);
               //     Console.WriteLine(Global.EndctMax);
                ++ct;
            }

            while (ct <= EndctMax);
            {
            }
        }
示例#14
0
        public static string[] getDrugCode(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 checkDrugCodeX = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품코드", "X");
                if (checkDrugCodeX != "")
                {
                    x3old[ct] = decimal.Parse(checkDrugCodeX);
                }
                else
                {
                    MessageBox.Show("환경설정에서 약품코드 X 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                string checkDrugCodeY = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품코드", "Y");
                if (checkDrugCodeY != "")
                {
                    y3old[ct] = decimal.Parse(checkDrugCodeY);
                }
                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 checkDrugCodeWidth = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품코드", "가로");
                if (checkDrugCodeWidth != "")
                {
                    width[ct] = int.Parse(checkDrugCodeWidth);
                }
                else
                {
                    MessageBox.Show("환경설정에서 약품코드 가로 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                string checkDrugCodeHeight = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "약품코드", "세로");
                if (checkDrugCodeHeight != "")
                {
                    height[ct] = int.Parse(checkDrugCodeHeight);
                }
                else
                {
                    MessageBox.Show("환경설정에서 약품코드 세로 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }

             //       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[0] = ct - 1;
                return tText;   // tText 배열로 텍스트 반환
            }
        }
示例#15
0
        public static Bitmap originalcheck(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 exeNo1 = ini.GetIniValue("실행 순서", "1단계");
            string exeNo2 = ini.GetIniValue("실행 순서", "2단계");
            string exeNo3 = ini.GetIniValue("실행 순서", "3단계");
            string exeNo4 = ini.GetIniValue("실행 순서", "4단계");
            string exeNo5 = ini.GetIniValue("실행 순서", "5단계");
            string exeNo6 = ini.GetIniValue("실행 순서", "6단계");
            string exeNo7 = ini.GetIniValue("실행 순서", "7단계");

            if(exeNo1 == "원본" ||
               exeNo2 == "원본" ||
               exeNo3 == "원본" ||
               exeNo4 == "원본" ||
               exeNo5 == "원본" ||
               exeNo6 == "원본" ||
               exeNo7 == "원본")
            {
                string path = @"C:\Program Files\PLOCR\prescription.png";
                source = (Bitmap)Bitmap.FromFile(path);
            }
            return source;
        }
示例#16
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;
        }
示例#17
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 배열로 텍스트 반환
            }
        }
示例#18
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(); // 프로그램 강제 종료
            }
        }
示例#19
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;
        }
示例#20
0
        //   public static void zeroSearch(string HtmlText,
        //       out int zeroWidth,
        //       out int zeroHeight,
        //       out int ScaleX,
        //       out int ScaleY,
        //       out int distancePatientX, out int distancePatientY, out int sizePatientHor, out int sizePatientVer,
        //       out int distanceDoctorX, out int distanceDoctorY, out int sizeDoctorHor, out int sizeDoctorVer,
        //       out int distancePreNumX, out int distancePreNumY, out int sizePreNumHor, out int sizePreNumVer,
        //       out int distanceDrugCodeX, out int distanceDrugCodeY, out int sizeDrugCodeHor, out int sizeDrugCodeVer,
        //       out int distanceDoseX, out int distanceDoseY, out int sizeDoseHor, out int sizeDoseVer,
        //       out int distanceTimeX, out int distanceTimeY, out int sizeTimeHor, out int sizeTimeVer,
        //       out int distanceDayX, out int distanceDayY, out int sizeDayHor, out int sizeDayVer,
        //       out int jumpY,
        //       out int factor)
        //   {
        //       ///////////// 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 CatchText1 = ini.GetIniValue("좌표영점", "1번좌표");
        //       int factor1 = int.Parse(ini.GetIniValue("좌표영점", "1번좌표factor"));
        //       MessageBox.Show(CatchText1.ToString(), factor1.ToString());
        //       String CatchText2 = ini.GetIniValue("좌표영점", "2번좌표");
        //       int factor2 = int.Parse(ini.GetIniValue("좌표영점", "2번좌표factor"));
        //       MessageBox.Show(CatchText2.ToString(), factor2.ToString());
        //       String CatchText3 = ini.GetIniValue("좌표영점", "3번좌표");
        //       int factor3 = int.Parse(ini.GetIniValue("좌표영점", "3번좌표factor"));
        //       MessageBox.Show(CatchText3.ToString(), factor3.ToString());
        //       int XYzeroWidth = 0, XYzeroHeight = 0, XYScaleX = 0, XYScaleY = 0;
        //       int PdistancePatientX = 0, PdistancePatientY = 0, PsizePatientHor = 0, PsizePatientVer = 0;
        //       int PdistanceDoctorX=0, PdistanceDoctorY=0, PsizeDoctorHor=0, PsizeDoctorVer=0;
        //       int PdistancePreNumX=0, PdistancePreNumY=0, PsizePreNumHor=0, PsizePreNumVer=0;
        //       int PdistanceDrugCodeX = 0, PdistanceDrugCodeY = 0, PsizeDrugCodeHor = 0, PsizeDrugCodeVer = 0;
        //       int PdistanceDoseX=0, PdistanceDoseY=0, PsizeDoseHor=0, PsizeDoseVer=0;
        //       int PdistanceTimeX=0, PdistanceTimeY=0, PsizeTimeHor=0, PsizeTimeVer=0;
        //       int PdistanceDayX=0, PdistanceDayY=0, PsizeDayHor=0, PsizeDayVer=0;
        //       int PjumpY=0;
        //       int Pfactor=0;
        //       if (HtmlText.Contains(CatchText1))
        //       {
        //           ZeroXY(HtmlText, CatchText1, factor1, out XYzeroWidth, out XYzeroHeight, out XYScaleX, out XYScaleY);
        //           PdistancePatientX = int.Parse(ini.GetIniValue(CatchText1, "distancePatientX"));
        //           PdistancePatientY = int.Parse(ini.GetIniValue(CatchText1, "distancePatientY"));
        //           PsizePatientHor = int.Parse(ini.GetIniValue(CatchText1, "sizePatientHor"));
        //           PsizePatientVer = int.Parse(ini.GetIniValue(CatchText1, "sizePatientVer"));
        //           PdistanceDoctorX = int.Parse(ini.GetIniValue(CatchText1, "distanceDoctorX"));
        //           PdistanceDoctorY = int.Parse(ini.GetIniValue(CatchText1, "distanceDoctorY"));
        //           PsizeDoctorHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDoctorHor"));
        //           PsizeDoctorVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDoctorVer"));
        //           PdistancePreNumX = int.Parse(ini.GetIniValue(CatchText1, "distancePreNumX"));
        //           PdistancePreNumY = int.Parse(ini.GetIniValue(CatchText1, "distancePreNumY"));
        //           PsizePreNumHor = int.Parse(ini.GetIniValue(CatchText1, "sizePreNumHor"));
        //           PsizePreNumVer = int.Parse(ini.GetIniValue(CatchText1, "sizePreNumVer"));
        //           PdistanceDrugCodeX = int.Parse(ini.GetIniValue(CatchText1, "distanceDrugCodeX"));
        //           PdistanceDrugCodeY = int.Parse(ini.GetIniValue(CatchText1, "distanceDrugCodeY"));
        //           PsizeDrugCodeHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDrugCodeHor"));
        //           PsizeDrugCodeVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDrugCodeVer"));
        //           PdistanceDoseX = int.Parse(ini.GetIniValue(CatchText1, "distanceDoseX"));
        //           PdistanceDoseY = int.Parse(ini.GetIniValue(CatchText1, "distanceDoseY"));
        //           PsizeDoseHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDoseHor"));
        //           PsizeDoseVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDoseVer"));
        //           PdistanceTimeX = int.Parse(ini.GetIniValue(CatchText1, "distanceTimeX"));
        //           PdistanceTimeY = int.Parse(ini.GetIniValue(CatchText1, "distanceTimeY"));
        //           PsizeTimeHor = int.Parse(ini.GetIniValue(CatchText1, "sizeTimeHor"));
        //           PsizeTimeVer = int.Parse(ini.GetIniValue(CatchText1, "sizeTimeVer"));
        //           PdistanceDayX = int.Parse(ini.GetIniValue(CatchText1, "distanceDayX"));
        //           PdistanceDayY = int.Parse(ini.GetIniValue(CatchText1, "distanceDayY"));
        //           PsizeDayHor = int.Parse(ini.GetIniValue(CatchText1, "sizeDayHor"));
        //           PsizeDayVer = int.Parse(ini.GetIniValue(CatchText1, "sizeDayVer"));
        //           PjumpY = int.Parse(ini.GetIniValue(CatchText1, "jumpY"));
        //           Pfactor = int.Parse(ini.GetIniValue(CatchText1, "factor"));
        //    //       Console.WriteLine("1번좌표로 영점을 잡았습니다. \n");
        //       }
        //       else if (HtmlText.Contains(CatchText2))
        //       {
        //           ZeroXY(HtmlText, CatchText2, factor2, out XYzeroWidth, out XYzeroHeight, out XYScaleX, out XYScaleY);
        //           PdistancePatientX = int.Parse(ini.GetIniValue(CatchText2, "distancePatientX"));
        //           PdistancePatientY = int.Parse(ini.GetIniValue(CatchText2, "distancePatientY"));
        //           PsizePatientHor = int.Parse(ini.GetIniValue(CatchText2, "sizePatientHor"));
        //           PsizePatientVer = int.Parse(ini.GetIniValue(CatchText2, "sizePatientVer"));
        //           PdistanceDoctorX = int.Parse(ini.GetIniValue(CatchText2, "distanceDoctorX"));
        //           PdistanceDoctorY = int.Parse(ini.GetIniValue(CatchText2, "distanceDoctorY"));
        //           PsizeDoctorHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDoctorHor"));
        //           PsizeDoctorVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDoctorVer"));
        //           PdistancePreNumX = int.Parse(ini.GetIniValue(CatchText2, "distancePreNumX"));
        //           PdistancePreNumY = int.Parse(ini.GetIniValue(CatchText2, "distancePreNumY"));
        //           PsizePreNumHor = int.Parse(ini.GetIniValue(CatchText2, "sizePreNumHor"));
        //           PsizePreNumVer = int.Parse(ini.GetIniValue(CatchText2, "sizePreNumVer"));
        //           PdistanceDrugCodeX = int.Parse(ini.GetIniValue(CatchText2, "distanceDrugCodeX"));
        //           PdistanceDrugCodeY = int.Parse(ini.GetIniValue(CatchText2, "distanceDrugCodeY"));
        //           PsizeDrugCodeHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDrugCodeHor"));
        //           PsizeDrugCodeVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDrugCodeVer"));
        //           PdistanceDoseX = int.Parse(ini.GetIniValue(CatchText2, "distanceDoseX"));
        //           PdistanceDoseY = int.Parse(ini.GetIniValue(CatchText2, "distanceDoseY"));
        //           PsizeDoseHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDoseHor"));
        //           PsizeDoseVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDoseVer"));
        //           PdistanceTimeX = int.Parse(ini.GetIniValue(CatchText2, "distanceTimeX"));
        //           PdistanceTimeY = int.Parse(ini.GetIniValue(CatchText2, "distanceTimeY"));
        //           PsizeTimeHor = int.Parse(ini.GetIniValue(CatchText2, "sizeTimeHor"));
        //           PsizeTimeVer = int.Parse(ini.GetIniValue(CatchText2, "sizeTimeVer"));
        //           PdistanceDayX = int.Parse(ini.GetIniValue(CatchText2, "distanceDayX"));
        //           PdistanceDayY = int.Parse(ini.GetIniValue(CatchText2, "distanceDayY"));
        //           PsizeDayHor = int.Parse(ini.GetIniValue(CatchText2, "sizeDayHor"));
        //           PsizeDayVer = int.Parse(ini.GetIniValue(CatchText2, "sizeDayVer"));
        //           PjumpY = int.Parse(ini.GetIniValue(CatchText2, "jumpY"));
        //           Pfactor = int.Parse(ini.GetIniValue(CatchText2, "factor"));
        //    //       Console.WriteLine("2번좌표로 영점을 잡았습니다. \n");
        //       }
        //       else if(HtmlText.Contains(CatchText3))
        //       {
        //           ZeroXY(HtmlText, CatchText3, factor3, out XYzeroWidth, out XYzeroHeight, out XYScaleX, out XYScaleY);
        //           PdistancePatientX = int.Parse(ini.GetIniValue(CatchText3, "distancePatientX"));
        //           PdistancePatientY = int.Parse(ini.GetIniValue(CatchText3, "distancePatientY"));
        //           PsizePatientHor = int.Parse(ini.GetIniValue(CatchText3, "sizePatientHor"));
        //           PsizePatientVer = int.Parse(ini.GetIniValue(CatchText3, "sizePatientVer"));
        //           PdistanceDoctorX = int.Parse(ini.GetIniValue(CatchText3, "distanceDoctorX"));
        //           PdistanceDoctorY = int.Parse(ini.GetIniValue(CatchText3, "distanceDoctorY"));
        //           PsizeDoctorHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDoctorHor"));
        //           PsizeDoctorVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDoctorVer"));
        //           PdistancePreNumX = int.Parse(ini.GetIniValue(CatchText3, "distancePreNumX"));
        //           PdistancePreNumY = int.Parse(ini.GetIniValue(CatchText3, "distancePreNumY"));
        //           PsizePreNumHor = int.Parse(ini.GetIniValue(CatchText3, "sizePreNumHor"));
        //           PsizePreNumVer = int.Parse(ini.GetIniValue(CatchText3, "sizePreNumVer"));
        //           PdistanceDrugCodeX = int.Parse(ini.GetIniValue(CatchText3, "distanceDrugCodeX"));
        //           PdistanceDrugCodeY = int.Parse(ini.GetIniValue(CatchText3, "distanceDrugCodeY"));
        //           PsizeDrugCodeHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDrugCodeHor"));
        //           PsizeDrugCodeVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDrugCodeVer"));
        //           PdistanceDoseX = int.Parse(ini.GetIniValue(CatchText3, "distanceDoseX"));
        //           PdistanceDoseY = int.Parse(ini.GetIniValue(CatchText3, "distanceDoseY"));
        //           PsizeDoseHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDoseHor"));
        //           PsizeDoseVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDoseVer"));
        //           PdistanceTimeX = int.Parse(ini.GetIniValue(CatchText3, "distanceTimeX"));
        //           PdistanceTimeY = int.Parse(ini.GetIniValue(CatchText3, "distanceTimeY"));
        //           PsizeTimeHor = int.Parse(ini.GetIniValue(CatchText3, "sizeTimeHor"));
        //           PsizeTimeVer = int.Parse(ini.GetIniValue(CatchText3, "sizeTimeVer"));
        //           PdistanceDayX = int.Parse(ini.GetIniValue(CatchText3, "distanceDayX"));
        //           PdistanceDayY = int.Parse(ini.GetIniValue(CatchText3, "distanceDayY"));
        //           PsizeDayHor = int.Parse(ini.GetIniValue(CatchText3, "sizeDayHor"));
        //           PsizeDayVer = int.Parse(ini.GetIniValue(CatchText3, "sizeDayVer"));
        //           PjumpY = int.Parse(ini.GetIniValue(CatchText3, "jumpY"));
        //           Pfactor = int.Parse(ini.GetIniValue(CatchText3, "factor"));
        //    //       Console.WriteLine("3번좌표로 영점을 잡았습니다. \n");
        //       }
        //       else
        //       {
        //           MessageBox.Show("좌표영점 인식에 실패했습니다.\n 좌표영점을 더 추가해서\n 인식률을 개선시켜 놓을께요.");
        ////           Console.WriteLine("ocr 좌표영점 인식에 실패했습니다.");
        //       }
        //       zeroWidth = XYzeroWidth; zeroHeight = XYzeroHeight; ScaleX = XYScaleX; ScaleY = XYScaleY;
        //       distancePatientX=PdistancePatientX; distancePatientY=PdistancePatientY; sizePatientHor=PsizePatientHor; sizePatientVer=PsizePatientVer;
        //       distanceDoctorX=PdistanceDoctorX; distanceDoctorY=PdistanceDoctorY; sizeDoctorHor=PsizeDoctorHor; sizeDoctorVer=PsizeDoctorVer;
        //       distancePreNumX = PdistancePreNumX; distancePreNumY = PdistancePreNumY; sizePreNumHor = PsizePreNumHor; sizePreNumVer = PsizePreNumVer;
        //       distanceDrugCodeX = PdistanceDrugCodeX; distanceDrugCodeY = PdistanceDrugCodeY; sizeDrugCodeHor = PsizeDrugCodeHor; sizeDrugCodeVer = PsizeDrugCodeVer;
        //       distanceDoseX = PdistanceDoseX; distanceDoseY = PdistanceDoseY; sizeDoseHor = PsizeDoseHor; sizeDoseVer = PsizeDoseVer;
        //       distanceTimeX=PdistanceTimeX; distanceTimeY=PdistanceTimeY; sizeTimeHor=PsizeTimeHor; sizeTimeVer=PsizeTimeVer;
        //       distanceDayX=PdistanceDayX; distanceDayY=PdistanceDayY; sizeDayHor=PsizeDayHor; sizeDayVer=PsizeDayVer;
        //       jumpY=PjumpY;
        //       factor=Pfactor;
        //   }
        //public static void ZeroXY(
        //    string HtmlText,
        //    string CatchText,
        //    int factor,
        //    out int XYzeroWidth,
        //    out int XYzeroHeight,
        //    out int XYScaleX,
        //    out int XYScaleY)   // 찾고자 하는 좌표영점의 문자를 주고, Html 텍스트 중에서 해당문자의 x,y 좌표를 반환한다.
        //{
        //    int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        //    int ZeroIndex = HtmlText.IndexOf(CatchText);  // 주어진 문자열로 기준이 되는 문자열 인덱스를 찾고,
        //    string ZeroRange = HtmlText.Substring(ZeroIndex - 30, 30); // 기준 문자열부터 앞쪽으로 30 인덱스 부분부터 기준까지의 문자열을 선택하고,
        //  //     Console.WriteLine(ZeroRange);
        //    char[] delimiterChars = { ' ' };
        //    string[] ZeroDiv = ZeroRange.Split(delimiterChars);  // 공백을 기준으로 문자열을 분리하고
        //    for (int ct = 0; ct < ZeroDiv.Length; ct++)
        //    {
        //        if (Regex.IsMatch(ZeroDiv[ct], @"^-?\d+$"))  // 숫자인지 아닌지 판단
        //        {
        //            x1 = int.Parse(Regex.Replace(ZeroDiv[ct], "[^0-9.-]", ""));      // 숫자만 추출하여, x좌표 문자형 숫자를 정수형으로 형변환
        //            y1 = int.Parse(Regex.Replace(ZeroDiv[ct + 1], "[^0-9.-]", ""));    // 숫자만 추출하여, y좌표 문자형 숫자를 정수형으로 형변환
        //            x2 = int.Parse(Regex.Replace(ZeroDiv[ct+2], "[^0-9.-]", ""));
        //            y2 = int.Parse(Regex.Replace(ZeroDiv[ct+3], "[^0-9.-]", ""));
        //      //      Console.WriteLine(x1);
        //      //      Console.WriteLine(y1);
        //      //      Console.WriteLine(x2);
        //      //      Console.WriteLine(y2);
        //            ct = ZeroDiv.Length;  // 숫자요소를 가진 배열을 찾으면 루프 탈출
        //        }
        //    }
        //    XYzeroWidth = x2 - x1;
        //    XYzeroHeight = y2 - y1;
        //    XYScaleX = x1 * (factor / 10000000) / XYzeroWidth;
        //    XYScaleY = y1 * (factor / 10000000) / XYzeroWidth;
        ////    Console.WriteLine(XYzeroWidth);
        //}
        public static void standardSearch(string HtmlText, int quad, out int x, out int y)
        {
            ///////////// 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 standardY1 = ini.GetIniValue("좌표1번", "Y");
            string standardX2 = ini.GetIniValue("좌표2번", "X");
            string standardY2 = ini.GetIniValue("좌표2번", "Y");
            string standardText1 = ini.GetIniValue("좌표텍스트", "좌표1번");
            string standardText2 = ini.GetIniValue("좌표텍스트", "좌표1번");

            int standardX, standardY, standardWidth, standardHeight;

            startXY(HtmlText, standardText1, out standardX, out standardY, out standardWidth, out standardHeight);

            x = standardX; y = standardY;
        }
示例#21
0
        public static void insideProcess()
        {
            ///////////// 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 inihDose = ini.GetIniValue("PLOCR_handle", "hDose");
            //Global.hDose = Handle.FindSortWindow(Global.hTPanelDoseTimeDay, 15, "TwEdit", -1, 3);

            //if (inihDose != Global.hDose.ToString())  // 찾아온 핸들값과 .ini 에서 읽어온 핸들값이 다르면 새로 핸들값 가져온다.
            //{
            //   Console.WriteLine(Global.hPatientName);
            //   Console.WriteLine(inihDose);

            //    Console.WriteLine("핸들값이 없어서 새로 읽어왔어요.");

            /////////////////////// 핸들 찾기 시작 ////////////////////////////
             //   if (Global.hTFrmPrescriptionEdit == null)       // 찾아놓은 핸들이 없을 때만 탐색하도록 하기 위해
            //    {
                Global.hTFrmPrescriptionEdit = Handle.FindWindow("TFrmPrescriptionEdit", "처방조제"); // 처방조제 최상위 윈도우 핸들찾기
                Global.hTPanelTop = Handle.Findchildchildwindow(Global.hTFrmPrescriptionEdit, 10, "TPanel", "TwMaskEdit"); // 처방조제 최상위 바로 아래 TPanel 이 8개 있으므로 10번 정도 돌려보고 찾은 TPanel 중에 하위에 TwMaskEdit 이 있는 TPanel 의 핸들값을 찾는다.
                Global.hTPanelDrugName = Handle.FindSizeWindow(Global.hTPanelTop, 50, "TPanel", 460, 86); // 처방조제 최상위 아래의 TPanel 중 가로 세로 460 86인 TPanel 을 찾는다. 이 TPanel 아래에 TwEdit (명칭) 이 들어있다.
                Global.hDrugCode = Handle.FindSizeWindow(Global.hTPanelDrugName, 10, "TwEdit", 263, 20); // 명칭 상위의 TPanel 을 넣어, 하위에 "명칭" 가로 세로 263 20 을 찾는다.
                Global.hTPanelDoseTimeDay = Handle.FindSizeWindow(Global.hTPanelTop, 10, "TPanel", 461, 174); // 투약량,횟수,일수 의 상위 TPanel 을 가로 세로 461 74로 찾는다.
                Global.hDose = Handle.FindSortWindow(Global.hTPanelDoseTimeDay, 15, "TwEdit", -1, 3);  // 투약량,횟수,일수 를 찾기 위해 OrderY, OrderX(배열이므로 0부터 시작) 순위를 넣어주어 윈도우 핸들을 찾는다. Y축으로 찾을 때는 OrderX = -1, X축으로 찾을 때는 OrderY = -1 을 넣는다.
                Global.hTime = Handle.FindSortWindow(Global.hTPanelDoseTimeDay, 15, "TwEdit", -1, 2);  // 투약량,횟수,일수 를 찾기 위해 OrderY, OrderX(배열이므로 0부터 시작) 순위를 넣어주어 윈도우 핸들을 찾는다. Y축으로 찾을 때는 OrderX = -1, X축으로 찾을 때는 OrderY = -1 을 넣는다.
                Global.hDay = Handle.FindSortWindow(Global.hTPanelDoseTimeDay, 15, "TwEdit", 2, -1);  // 투약량,횟수,일수 를 찾기 위해 OrderY, OrderX(배열이므로 0부터 시작) 순위를 넣어주어 윈도우 핸들을 찾는다. Y축으로 찾을 때는 OrderX = -1, X축으로 찾을 때는 OrderY = -1 을 넣는다.
                Global.hTotalDose = Handle.FindSizeWindow(Global.hTPanelDoseTimeDay, 15, "TwEdit", 77, 20); // 총투약, 가로 세로 77 20   , 입력하지 않아도 엔터치며 이동해야 하기 때문에 핸들 탐색해둬야함
                //     Global.hCopayDay = Handle.FindSizeWindow(hTPanelDoseTimeDay, 15, "TwEdit", 55, 20); // 본인부담일수, 가로 세로 55 20
                Global.hPatientName = Handle.FindSizeWindow(Global.hTPanelTop, 50, "TwEdit", 78, 20); // hTPanelTop 를 부모 윈도우로 하여, 아래에 TwEdit 이 있는 텍스트박스를 찾고 박스의 Width 와 Height 를 비교하여 "환자이름" 의TwEdit 을 찾는다. 환자이름 입력창의 가로 = 78, 세로 = 20 이다.
                Global.hPrescriptionNumber = Handle.FindSizeWindow(Global.hTPanelTop, 50, "TwEdit", 138, 20); // 교부번호의 가로 세로는 138 20 이다.
                Global.hDoctorLicenseNumber = Handle.FindSizeWindow(Global.hTPanelTop, 50, "TwEdit", 64, 20); // 의사면허의 가로 세로는 64 20 이다.
                //    Global.hHospitalCode = Handle.FindSizeWindow(hTPanelTop, 50, "TwEdit", 110, 20); // 발행기관의 가로 세로는 110 20 이다.
                //     Global.hPrescriptionDay = Handle.FindSortWindow(hTPanelTop, 50, "TDateTimePicker", -1, 1);
                //    Global.hFillPrescriptionDay = Handle.FindSortWindow(hTPanelTop, 50, "TDateTimePicker", -1, 0);
                //   Global.hTimeOutCombo = Handle.FindSizeWindow(hTPanelTop, 50, "TComboBox", 117, 22); // 시간외 콤보박스 가로 세로 117 22
                //    Global.hAdditionCombo = Handle.FindSizeWindow(hTPanelTop, 50, "TComboBox", 76, 22); // 비가산/소아가산/65세 콤보박스 가로 세로 76 22
                //    Global.hTimeOutEdit = Handle.FindSizeWindow(hTPanelTop, 50, "TwMaskEdit", 77, 20);  // FindWindowEx 또는 만든 함수 FindChildWindow 를 사용하는 것이 좋은데 작동을 안해서 FindSizeWindow 사용해서 찾았음
                Global.hAlterCombo = Handle.FindSizeWindow(Global.hTPanelDoseTimeDay, 15, "TComboBox", 107, 22); // 형태(대체 등..) 가로 세로 107 22     , 입력하지 않아도 엔터치며 이동해야 하기 때문에 핸들 탐색해둬야함
                Global.hInsureCombo = Handle.FindSizeWindow(Global.hTPanelDoseTimeDay, 15, "TComboBox", 84, 22); // 급여(100/100 등..) 가로 세로 107 22  , 입력하지 않아도 엔터치며 이동해야 하기 때문에 핸들 탐색해둬야함
                Global.hTakeCombo = Handle.FindSizeWindow(Global.hTPanelDoseTimeDay, 15, "TComboBox", 84, 20);  // 용법 가로 세로 84 20   , 입력하지 않아도 엔터치며 이동해야 하기 때문에 핸들 탐색해둬야함
              //  }

            //   IntPtr hDrugSelectCode = Handle.FindWindow("TFrmSelectCode", "코드조회"); // 약품입력 팝업창

            //if (Global.hTFrmPrescriptionEdit == IntPtr.Zero)
            //{
            //    Console.WriteLine("처방조제 입력화면을 먼저 열어주세요.");
            //}
            /////////////////////// 핸들 찾기 끝////////////////////////////

               // Console.WriteLine("핸들을 찾았습니다.\n");

            //////////////////////// ini 값 입력 시작 /////////////////////////////
            //ini.SetIniValue("PLOCR_handle", "hTFrmPrescriptionEdit", Global.hTFrmPrescriptionEdit.ToString());  // ini 파일에 핸들값을 string으로 형변환 하여 텍스트로 저장한다. string 값이지만 int32 로 다시 변환하면 핸들값이 된다.
            //ini.SetIniValue("PLOCR_handle", "hTPanelTop", Global.hTPanelTop.ToString());
            //ini.SetIniValue("PLOCR_handle", "hTPanelDrugName", Global.hTPanelDrugName.ToString());
            //ini.SetIniValue("PLOCR_handle", "hDrugCode", Global.hDrugCode.ToString());
            //ini.SetIniValue("PLOCR_handle", "hTPanelDoseTimeDay", Global.hTPanelDoseTimeDay.ToString());
            //ini.SetIniValue("PLOCR_handle", "hDose", Global.hDose.ToString());
            //ini.SetIniValue("PLOCR_handle", "hTime", Global.hTime.ToString());
            //ini.SetIniValue("PLOCR_handle", "hDay", Global.hDay.ToString());
            //ini.SetIniValue("PLOCR_handle", "hTotalDose", Global.hTotalDose.ToString());
            //ini.SetIniValue("PLOCR_handle", "hPatientName", Global.hPatientName.ToString());
            //ini.SetIniValue("PLOCR_handle", "hPrescriptionNumber", Global.hPrescriptionNumber.ToString());
            //ini.SetIniValue("PLOCR_handle", "hDoctorLicenseNumber", Global.hDoctorLicenseNumber.ToString());
            //ini.SetIniValue("PLOCR_handle", "hAlterCombo", Global.hAlterCombo.ToString());
            //ini.SetIniValue("PLOCR_handle", "hInsureCombo", Global.hInsureCombo.ToString());
            //ini.SetIniValue("PLOCR_handle", "hTakeCombo", Global.hTakeCombo.ToString());
            ////   ini.SetIniValue("PLOCR_handle", "hDrugSelectCode", hDrugSelectCode.ToString());
            //////////////////////// ini 값 입력 끝 ///////////////////////////////
            //}
            //else  // 핸들값이 .ini 에 있으면 값을 가져온다.
            //{
            //ini.GetIniValue("PLOCR_handle", "hTFrmPrescriptionEdit");  // ini 파일에서 핸들값을 가져옴, 형변환 해야함
            //ini.GetIniValue("PLOCR_handle", "hTPanelTop");
            //ini.GetIniValue("PLOCR_handle", "hTPanelDrugCode");
            //ini.GetIniValue("PLOCR_handle", "hDrugCode");
            //ini.GetIniValue("PLOCR_handle", "hTPanelDoseTimeDay");
            //ini.GetIniValue("PLOCR_handle", "hDose");
            //ini.GetIniValue("PLOCR_handle", "hTime");
            //ini.GetIniValue("PLOCR_handle", "hDay");
            //ini.GetIniValue("PLOCR_handle", "hTotalDose");
            //ini.GetIniValue("PLOCR_handle", "hPatientName");
            //ini.GetIniValue("PLOCR_handle", "hPrescriptionNumber");
            //ini.GetIniValue("PLOCR_handle", "hDoctorLicenseNumber");
            //ini.GetIniValue("PLOCR_handle", "hAlterCombo");
            //ini.GetIniValue("PLOCR_handle", "hInsureCombo");
            //ini.GetIniValue("PLOCR_handle", "hTakeCombo");
            //}

            ///////////////// 처방전 스캔 시작 ///////////////////////////
              //  splashPres fmPres = new splashPres();
            //    fmPres.Owner = DataEdit.ActiveForm;  // child form 을 알리고
             //   fmPres.Show();       // 스캔중 화면을 띄우고

            Bitmap source = scan.scanImage();
            if (source != null)
            {
                Global.source = source;
            }
            else
            {
                MessageBox.Show("스캐너 연결상태 또는 처방전 급지상태를 확인하고 재실행 해주세요.");
                System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
            }

               //     fmPres.Close(); // 스캔중 화면 닫고
            /////////////////// 처방전 스캔 끝 ///////////////////////////

            /////////////// 처방전 스캔 프로그램 시작 ///////////////////////////
            //splashPres fmPres = new splashPres();
            //fmPres.Owner = DataEdit.ActiveForm;  // child form 을 알리고
            //fmPres.Show();       // 스캔중 화면을 띄우고

            //System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo();
            //start.FileName = @"C:\Program Files\PLOCR\PLOCRscan.exe";         // 스캔 프로그램 시작
            //start.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;   // 윈도우 속성을  windows hidden  으로 지정
            //start.CreateNoWindow = true;  // hidden 을 시키기 위해서 이 속성도 true 로 체크해야 함

            //Process process = Process.Start(start);
            //process.WaitForExit(); // 외부 프로세스가 끝날 때까지 프로그램의 진행을 멈춘다.

            //fmPres.Close(); // 스캔중 화면 닫고
            ///////////////// 처방전 스캔 프로그램 끝 ///////////////////////////

            splashImageProcess fmImageProcess = new splashImageProcess();
            fmImageProcess.Owner = DataEdit.ActiveForm;  // child form 을 알리고
            fmImageProcess.Show();       // 이미지 처리중 화면을 띄우고

            //    string path = @"C:\Program Files\PLOCR\prescription.png";
            //    Bitmap source = (Bitmap)Bitmap.FromFile(path);
            if (source != null)
            {
                source = calculator.sequence(source); // 이미지 전처리
            }
            else
            {
                MessageBox.Show("스캐너 연결상태를 확인하고 재실행 해주세요.");
                System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
            }

               //     source.Save(@"C:\Program Files\PLOCR\processedprescription.png");

              //  source = ImageProcess.Scaling(source, 500);                 // % 로 확대한다.
            if (source != null)
            {
                FindZeroXY.divSearch1(source);  // 좌표1번 찾고
                FindZeroXY.divSearch2(source);  // 좌표2번 찾고
            }
            else
            {
             //   MessageBox.Show("다시 스캔해주세요.");
            }

            fmImageProcess.Close();

            //MessageBox.Show("찾아낸 좌표1번은 : " + Global.coordNo1X + " " + Global.coordNo1Y);
            //MessageBox.Show("찾아낸 좌표2번은 : " + Global.coordNo2X + " " + Global.coordNo2Y);

            //MessageBox.Show("기준좌표1번 x 는" + Global.coordNo1X.ToString());
            //MessageBox.Show("기준좌표1번 y 는" + Global.coordNo1Y.ToString());
            //MessageBox.Show("기준좌표2번 x 는" + Global.coordNo2X.ToString());
            //MessageBox.Show("기준좌표2번 y 는" + Global.coordNo2Y.ToString());

            //string path = @"C:\Program Files\PLOCR\prescription.png";
            //Bitmap source = (Bitmap)Bitmap.FromFile(path);

            splashOcr fmOcr = new splashOcr();  // ocr 인식 알림
            fmOcr.Owner = DataEdit.ActiveForm;  // child form 을 알리고
            fmOcr.Show();       // OCR 인식중 화면을 띄우고

            if (source != null)
            {
                source = calculator.originalcheck(source);      // 처리순서 끝에 원본이 필요한가 확인한다. 처방전이 흐린 경우 이미지처리후 좌표잡고 실제 읽을 때는 원본으로 하는 경우가 된다.

                Global.tPatientNumber = calculator.getTargetText(source, "주민번호");   // 환자 주민번호 txt 저장

                //    MessageBox.Show("읽어낸 주민번호는 = " + Global.tPatientNumber);

                Global.tPatientName = calculator.getTargetText(source, "환자이름");

                //      MessageBox.Show("읽어낸 환자이름은 = " + Global.tPatientName);

                Global.tDoctorLicenseNumber = calculator.getTargetText(source, "의사면허");  // 의사 면허번호 txt 저장

                //      MessageBox.Show("읽어낸 면허번호는 = " + Global.tDoctorLicenseNumber);

                Global.tPrescriptionNumber = calculator.getTargetText(source, "교부번호");

                //      MessageBox.Show("읽어낸 교부번호는 = " + Global.tPrescriptionNumber);

                fmOcr.Close();  // 인식창 닫고

                splashData fmData = new splashData();  // 데이터 처리 알림
                fmData.Owner = DataEdit.ActiveForm;  // child form 을 알리고
                fmData.Show();       // 데이터 처리중 화면을 띄우고

                string DrugAreaCheck = ini.GetIniValue("약품영역사용", "사용여부");   // 약품영역으로 할 것인지, 약품코드와 약품명을 각각 읽어낼 것인지 결정한다. 1이면 약품영역좌표 전체로, 0 이면 각각 코드와 약품명 좌표로 읽어낸다.

                if (DrugAreaCheck == "1")
                {
                    Global.tDose = calculator.getDrugDose(source);           // 투약량 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
                    Global.tTime = calculator.getDrugTime(source);           // 투여횟수 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
                    Global.tDay = calculator.getDrugDay(source);             // 총투약일수 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.

                    Global.EndctMax = Global.Endct.Max();
                    //           MessageBox.Show("세가지로만 잡은 EndctMax 는" + Global.EndctMax.ToString());

                    string tDrugCodeDrugNameArea = calculator.getDrugCodeDrugNameArea(source);     // 약품코드 약품명 영역을 읽어낸다.
                    Global.tDrugCode = TextProcess.DrugCodeSplit(tDrugCodeDrugNameArea);   // 읽어낸 약품코드를 문자열 후처리를 통해 글로벌 변수에 저장한다.
                    Global.tDrugName = TextProcess.DrugNameSplit(tDrugCodeDrugNameArea);   // 읽어낸 약품명을 문자열 후처리를 통해 글로벌 변수에 저장한다.
                }
                else if (DrugAreaCheck == "0")
                {
                    Global.tDrugCode = calculator.getDrugCode(source);    // 약품코드 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
                    Global.tDrugName = calculator.getDrugName(source);
                    Global.tDose = calculator.getDrugDose(source);           // 투약량 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
                    Global.tTime = calculator.getDrugTime(source);           // 투여횟수 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
                    Global.tDay = calculator.getDrugDay(source);             // 총투약일수 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.

                    Global.EndctMax = Global.Endct.Max();   // 투약량,횟수,일수 중에서 가장 많이 인식한 숫자만큼 입력을 하기 위해 카운팅 값을 구한다.
                    // 입력 모듈 반복수를 구하기 위해 스캔하면서 정해둔다. 이 값이 4라면 0부터 시작하므로 5행까지 입력하게 된다.
                }

                Array.Resize<String>(ref Global.tDrugCode, Global.EndctMax + 1);     // 배열 인덱스 오류를 방지하기 위해 전체 배열의 크기를 EndcdMax 로 재조정한다.
                Array.Resize<String>(ref Global.tDrugName, Global.EndctMax + 1);    // 프로그램 완료후 다시 스캔할 때, 앞선 처방전의 배열크기가 크면 다음
                Array.Resize<String>(ref Global.tDose, Global.EndctMax + 1);        // 다음 처방전에서 줄수가 적으면 배열 인덱스 범위를 벗어나기 때문에 오류가 생긴다.
                Array.Resize<String>(ref Global.tTime, Global.EndctMax + 1);        // 그래서 여기서 배열의 크기를 바꿔준다.
                Array.Resize<String>(ref Global.tDay, Global.EndctMax + 1);         // 중요한 오류임, 주의할 것.

                fmData.Close();     // 데이터 처리 알림창 닫고
            }

              //      ini.SetIniValue("스캔후자동실행", "자동실행여부", "0");  // 스캔후 자동실행 여부를 미실행으로 다시 지정해둠

               // MessageBox.Show("EndctMax = " + Global.EndctMax);

               //     ////////////////////// 이미지 전처리 시작 //////////////////////
               //     string path = @"C:\Program Files\PLOCR\prescription.png";    // twain 이용하여 스캐너로부터 가져와야 하는 이미지, twain 연결 부분
               //     Bitmap source = (Bitmap)Bitmap.FromFile(path);
               //     Bitmap ProcessedImage = ImageProcess.ImgProcess(source);
               //                ProcessedImage.Save(@".\ProcessedImage.png");
               //     ////////////////////  이미지 전처리 끝 /////////////////////////

               //  //   Console.WriteLine("이미지 전처리를 끝냈습니다.\n");
               //       MessageBox.Show("이미지 전처리를 끝냈습니다.\n");

               //     ////////////////////  좌표영점 찾아 좌표설정 시작 //////////////////////
               //     string ZeroHtml = OcrEngine.hocr(ProcessedImage);  // 좌표 영점을 찾기 위해 hocr 실행

               //     int zeroWidth, zeroHeight, ScaleX, ScaleY;

               //     int distancePatientX, distancePatientY, sizePatientHor, sizePatientVer;
               //     int distanceDoctorX, distanceDoctorY, sizeDoctorHor, sizeDoctorVer;
               //     int distancePreNumX, distancePreNumY, sizePreNumHor, sizePreNumVer;
               //     int distanceDrugCodeX, distanceDrugCodeY, sizeDrugCodeHor, sizeDrugCodeVer;
               //     int distanceDoseX, distanceDoseY, sizeDoseHor, sizeDoseVer;
               //     int distanceTimeX, distanceTimeY, sizeTimeHor, sizeTimeVer;
               //     int distanceDayX, distanceDayY, sizeDayHor, sizeDayVer;
               //     int jumpY;
               //     int factor;

               //     FindZeroXY.zeroSearch(ZeroHtml,
               //         out zeroWidth, out zeroHeight, out ScaleX, out ScaleY,
               //         out distancePatientX, out distancePatientY, out sizePatientHor, out sizePatientVer,
               //         out distanceDoctorX, out distanceDoctorY, out sizeDoctorHor, out sizeDoctorVer,
               //         out distancePreNumX, out distancePreNumY, out sizePreNumHor, out sizePreNumVer,
               //         out distanceDrugCodeX, out distanceDrugCodeY, out sizeDrugCodeHor, out sizeDrugCodeVer,
               //         out distanceDoseX, out distanceDoseY, out sizeDoseHor, out sizeDoseVer,
               //         out distanceTimeX, out distanceTimeY, out sizeTimeHor, out sizeTimeVer,
               //         out distanceDayX, out distanceDayY, out sizeDayHor, out sizeDayVer,
               //         out jumpY,
               //         out factor);  // 좌표영점의 가로세로와 표준화된 좌표영점을 반환받는다.

               //   //    Console.WriteLine(zeroWidth);
               //   //     Console.WriteLine(ScaleX);

               //         MessageBox.Show(zeroWidth.ToString());
               //         MessageBox.Show(ScaleX.ToString());

               //     ////////////////////  좌표영점 찾아 좌표설정 끝 ///////////////////////

               // //          Console.WriteLine("좌표영점을 찾았습니다.\n");
               //        MessageBox.Show("좌표영점을 찾았습니다.\n");

               //     ///////////////////   이미지 사이즈 표준화 시작 ///////////////////
               //     if (zeroWidth == 0)
               //     {
               //         MessageBox.Show("좌표영점 인식에 실패했습니다.\n 다른 처방전으로 시험해보세요.\n 인식률을 더 개선시켜 놓을께요.");
               //     }

               //     Bitmap ScaledImage = ImageProcess.ScaleByPercent(ProcessedImage, factor / zeroWidth);
               //               ScaledImage.Save(@".\ScaledImage.png");
               //     //////////////////    이미지 사이즈 표준화 끝 ///////////////////

               ////     Console.WriteLine("이미지 사이즈 표준화를 끝냈습니다.\n");

               //     ///////////////////  이미지 잘라내기 시작 /////////////////////
               //     Bitmap cPatientName = Crop.cloneAforge(ScaledImage, ScaleX - distancePatientX, ScaleY + distancePatientY, sizePatientHor, sizePatientVer);   // 환자 주민번호 위치 잘라내기
               //                cPatientName.Save(@".\cPatientName.png");
               //     Bitmap cDoctorLicenseNumber = Crop.cloneAforge(ScaledImage, ScaleX - distanceDoctorX, ScaleY + distanceDoctorY, sizeDoctorHor, sizeDoctorVer);   // 의사면허 위치 잘라내기
               //                cDoctorLicenseNumber.Save(@".\cDoctorLicenseNumber.png");
               //     Bitmap cPrescriptionNumber = Crop.cloneAforge(ScaledImage, ScaleX - distancePreNumX, ScaleY + distancePreNumY, sizePreNumHor, sizePreNumVer);  // 교부번호 위치 잘라내기
               //                cPrescriptionNumber.Save(@".\cPrescriptionNumber.png");
               //     Bitmap[] cDrugCode = Crop.segCrop(ScaledImage, ScaleX - distanceDrugCodeX, ScaleY + distanceDrugCodeY, sizeDrugCodeHor, sizeDrugCodeVer, jumpY);  // 약품코드 위치를 잘라내어 배열에 저장
               //     Bitmap[] cDose = Crop.segCrop(ScaledImage, ScaleX - distanceDoseX, ScaleY + distanceDoseY, sizeDoseHor, sizeDoseVer, jumpY);     // 투약량 위치를 잘라내어 배열에 저장
               //     Bitmap[] cTime = Crop.segCrop(ScaledImage, ScaleX - distanceTimeX, ScaleY + distanceTimeY, sizeTimeHor, sizeTimeVer, jumpY);     // 투여횟수 위치를 잘라내어 배열에 저장
               //     Bitmap[] cDay = Crop.segCrop(ScaledImage, ScaleX - distanceDayX, ScaleY + distanceDayY, sizeDayHor, sizeDayVer, jumpY);      // 투약일수 위치를 잘라내어 배열에 저장
               //     ///////////////////  이미지 잘라내기 끝 //////////////////////

               //     /////////////////////  이미지 잘라내기 시작 /////////////////////
               //     //Bitmap cPatientName = Crop.cloneAforge(ScaledImage, ScaleX - distancePatientX, ScaleY + distancePatientY, sizePatientHor, sizePatientVer);   // 환자 주민번호 위치 잘라내기
               //     //cPatientName.Save(@".\cPatientName.png");
               //     //Bitmap cDoctorLicenseNumber = Crop.cloneAforge(ScaledImage, ScaleX - distanceDoctorX, ScaleY + distanceDoctorY, sizeDoctorHor, sizeDoctorVer);   // 의사면허 위치 잘라내기
               //     //cDoctorLicenseNumber.Save(@".\cDoctorLicenseNumber.png");
               //     //Bitmap cPrescriptionNumber = Crop.cloneAforge(ScaledImage, ScaleX - distancePreNumX, ScaleY + distancePreNumY, sizePreNumHor, sizePreNumVer);  // 교부번호 위치 잘라내기
               //     //cPrescriptionNumber.Save(@".\cPrescriptionNumber.png");
               //     //Bitmap[] cDrugCode = Crop.segCrop(ScaledImage, ScaleX - distanceDrugCodeX, ScaleY + distanceDrugCodeY, sizeDrugCodeHor, sizeDrugCodeVer, jumpY);  // 약품코드 위치를 잘라내어 배열에 저장
               //     //Bitmap[] cDose = Crop.segCrop(ScaledImage, ScaleX - distanceDoseX, ScaleY + distanceDoseY, sizeDoseHor, sizeDoseVer, jumpY);     // 투약량 위치를 잘라내어 배열에 저장
               //     //Bitmap[] cTime = Crop.segCrop(ScaledImage, ScaleX - distanceTimeX, ScaleY + distanceTimeY, sizeTimeHor, sizeTimeVer, jumpY);     // 투여횟수 위치를 잘라내어 배열에 저장
               //     //Bitmap[] cDay = Crop.segCrop(ScaledImage, ScaleX - distanceDayX, ScaleY + distanceDayY, sizeDayHor, sizeDayVer, jumpY);      // 투약일수 위치를 잘라내어 배열에 저장
               //     /////////////////////  이미지 잘라내기 끝 //////////////////////

               // //    Console.WriteLine("이미지를 좌표대로 분할했습니다.\n");
               //     MessageBox.Show("이미지를 좌표대로 분할했습니다.\n");

            ///////////////////// ocr 인식 시작 ////////////////////////
            //Global.tPatientName = OcrEngine.ocr(cPatientName);   // 환자 주민번호 txt 저장
            //Console.WriteLine("환자 주민번호:{0:x}", Global.tPatientName);
            //Global.tDoctorLicenseNumber = OcrEngine.ocr(cDoctorLicenseNumber);   // 의사면허 txt 저장
            //Console.WriteLine("의사 면허번호:{0:x}", Global.tDoctorLicenseNumber);
            //Global.tPrescriptionNumber = OcrEngine.ocr(cPrescriptionNumber);    // 교부번호 txt 저장
            //Console.WriteLine("교부번호:{0:x}", Global.tPrescriptionNumber);

            //Global.Endct = new int[4];
            //Global.tDrugCode = OcrEngine.segOcr(cDrugCode, out Global.Endct[0]);    // 약품코드 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
            //Global.tDose = OcrEngine.segOcr(cDose, out Global.Endct[1]);           // 투약량 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
            //Global.tTime = OcrEngine.segOcr(cTime, out Global.Endct[2]);           // 투여횟수 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
            //Global.tDay = OcrEngine.segOcr(cDay, out Global.Endct[3]);             // 투약일수 이미지 배열을 인자로 전달하여 ocr 실행후 텍스트 배열을 받는다.
            //Global.EndctMax = Global.Endct.Max();   // 투약량,횟수,일수 중에서 가장 많이 인식한 숫자만큼 입력을 하기 위해 카운팅 값을 구한다.

            //     Console.WriteLine("EndctMax : {0:x}", Global.EndctMax);

            //   Console.WriteLine("End CT:{0:x}", Endct);

            // Console.Read();  // 핸들에 데이터 입력까지 볼 때는 이 부분을 주석처리 해야 진행됨, 콘솔창에서 테스트 할때 대기하려고.
            /////////////////// ocr 인식 끝 //////////////////////////

            //    fmOcr.Close();  // OCR 인식중 창 닫고

            //     Application.OpenForms["ocrRecogTime"].Close();  // ocr 인식 알림창 닫기

            //    Console.WriteLine("ocr 인식을 끝냈습니다.\n");
            //MessageBox.Show("ocr 인식을 끝냈습니다.\n");

            ////////////////// 핸들로 전달 시작 ////////////////////// --> 윈도우폼에서 처리하기로 함
            //typing.typePatientName(Global.hPatientName, Global.tPatientName);        // 환자 주민번호 입력 후 엔터
            //typing.typePrescriptionNumber(Global.hPrescriptionNumber, Global.tPrescriptionNumber);  // 교부번호 입력 후 엔터
            //typing.typeDoctorLicenseNumber(Global.hDoctorLicenseNumber, Global.tDoctorLicenseNumber); // 의사면허 입력 후 엔터

            //typing.segType(Global.hDrugCode, Global.hDose, Global.hTime, Global.hDay, Global.hTotalDose, Global.hInsureCombo, Global.hTakeCombo, Global.hAlterCombo, Global.tDrugCode, Global.tDose, Global.tTime, Global.tDay, Global.EndctMax);   // 루프를 돌면서 약품코드, 투약량, 횟수, 투약일수를 입력한다.
            ///////////////////  핸들로 전달 끝 ///////////////////////

               //     Console.WriteLine("핸들로 문자를 전달했습니다.\n");

            //   Console.Read();

            //    //반복 실행시 변수에 쓰레기값이 들어가서 종료시 초기화 해본다.
            //    Global.tPatientNumber = null;
            //    Global.tPatientName = null;
            //    Global.tDoctorLicenseNumber = null;
            //    Global.tPrescriptionNumber = null;
            //    Global.tDrugCode = null;
            //    Global.tDrugName = null;
            //    Global.tDose = null;
            //    Global.tTime = null;
            //    Global.tDay = null;

            //    Global.Endct = null;
            //  //  Global.EndctMax = null;

            // //   Global.coordNo1X = null;
            // //   Global.coordNo1Y = null;
            ////    Global.coordNo2X = null;
            ////    Global.coordNo2Y = null;

            //    Global.source = null;
        }
示例#22
0
        public static Bitmap sequence(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 exeNo1 = ini.GetIniValue("실행 순서", "1단계");
            string exeNo2 = ini.GetIniValue("실행 순서", "2단계");
            string exeNo3 = ini.GetIniValue("실행 순서", "3단계");
            string exeNo4 = ini.GetIniValue("실행 순서", "4단계");
            string exeNo5 = ini.GetIniValue("실행 순서", "5단계");
            string exeNo6 = ini.GetIniValue("실행 순서", "6단계");
            string exeNo7 = ini.GetIniValue("실행 순서", "7단계");

            if (exeNo7 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
                source = imgProcess(source, exeNo4);
                source = imgProcess(source, exeNo5);
                source = imgProcess(source, exeNo6);
            }
            else if (exeNo6 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
                source = imgProcess(source, exeNo4);
                source = imgProcess(source, exeNo5);
            }
            else if (exeNo5 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
                source = imgProcess(source, exeNo4);
            }
            else if (exeNo4 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
                source = imgProcess(source, exeNo3);
            }
            else if (exeNo3 == "끝")
            {
                source = imgProcess(source, exeNo1);
                source = imgProcess(source, exeNo2);
            }
            else if (exeNo2 == "끝")
            {
                source = imgProcess(source, exeNo1);
            }
            else if (exeNo1 == "끝")
            {
            }

            return(source);
        }
示例#23
0
        // rgb 필터
        public static Bitmap RGBfilter(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 redMin = int.Parse(ini.GetIniValue("색상필터값", "RedMin"));
            int redMax = int.Parse(ini.GetIniValue("색상필터값", "RedMax"));
            int greenMin = int.Parse(ini.GetIniValue("색상필터값", "GreenMin"));
            int greenMax = int.Parse(ini.GetIniValue("색상필터값", "GreenMax"));
            int blueMin = int.Parse(ini.GetIniValue("색상필터값", "BlueMin"));
            int blueMax = int.Parse(ini.GetIniValue("색상필터값", "BlueMax"));

            // create filter
            ColorFiltering filter = new ColorFiltering();
            // set color ranges to keep
            filter.Red = new IntRange(redMin, redMax);
            filter.Green = new IntRange(greenMin, greenMax);
            filter.Blue = new IntRange(blueMin, blueMax);
            Bitmap processedImage = filter.Apply(source);

            return processedImage;
        }
示例#24
0
        // old 는 기준처방전 new 는 실제처방전, 1 과 2는 기준좌표 두점을 말하고, 모르는 제3의 new 를 찾는 함수
        public static int NewPointY(decimal y3old, decimal y1new, decimal y2new)
        {
            ///////////// 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 y1old = decimal.Parse(ini.GetIniValue("스캔으로 찾은 좌표1번", "Y"));
            decimal y2old = decimal.Parse(ini.GetIniValue("스캔으로 찾은 좌표2번", "Y"));

            //MessageBox.Show("y1old = " + y1old);
            //MessageBox.Show("y2old = " + y2old);
            //MessageBox.Show("y3old = " + y3old);

            //MessageBox.Show("y1new = " + y1new);
            //MessageBox.Show("y2new = " + y2new);

            decimal y3new = 0;
               // decimal factor = ((Math.Abs(y2new - y1new)) / (Math.Abs(y2old - y1old)));  // factor 과 NewPoint 함수에 들어가는 인자들은 소수점까지 계산해야 하므로 반드시 "decimal" 로 해야 한다.
            decimal factor = 1;         // 위 방법으로는 오차가 너무 많이 생겨서 처리 불가능, 나중에 해결책을 찾아보기로 하고 모든 처방전이 동일한 크기라 보고 단순 거리 비교만 하기로 함

              //      MessageBox.Show("factor y = " + factor.ToString());

            if ((y3old - y1old) < 0)
            {
                y3new = y1new - (Math.Abs(y3old - y1old) * factor);  // y1old 는 기준처방의 1번좌표, y2old 는 기준처방의 2번좌표, y3old 는 사용자가 지정한 기준처방의 좌표
            }                                                                                                      // y1new 는 실제처방의 1번좌표, y2new 는 실제처방의 2번좌표, y3new 는 찾으려고 하는 좌표
            else if ((y3old - y1old) > 0)
            {
                y3new = (Math.Abs(y3old - y1old) * factor) + y1new;
            }
            else if (y3old == y1old)
            {
                MessageBox.Show("환경설정에서 좌표1번 과 좌표2번을 다시 설정해주세요.");
                System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
            }
             //   MessageBox.Show("y3new = " + y3new);
            return (int)y3new;
        }
示例#25
0
        // 선 가늘게
        public static Bitmap thin(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 order = int.Parse(ini.GetIniValue("선굵기값", "가늘게횟수"));

            for (int i = 0; i < order; i++)
            {
                Bitmap tmp = (Bitmap)source;        // 중요! 한번 이미지 처리가 끝난 비트맵 source 는 clone 함수로 보내기 전에 다시 한번 (Bitmap) 처리 해줘야함, 이유는 잘 모르겠음
                // convert to 24 bits per pixel
                source = ImageProcess.Clone(tmp, PixelFormat.Format24bppRgb);
                // delete old image
                tmp.Dispose();

                Dilatation filter = new Dilatation();
                filter.ApplyInPlace(source);
            }

            return source;
        }
示例#26
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 배열로 텍스트 반환
            }
        }