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); }
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(); // 프로그램 강제 종료 } }