Commit aeedd0c5 刘韬

修正1024x768下界面显示

1 个父辈 0405e96a
...@@ -29,41 +29,37 @@ namespace BLL ...@@ -29,41 +29,37 @@ namespace BLL
public static string StartTest(string imgPath) public static string StartTest(string imgPath)
{ {
string ocr = ""; string ocr = "";
for (int i = 0; i < 2; i++)
{
if (!AppIsRun()) if (!AppIsRun())
{ {
LogNet.log.Info("ocr程序未允许,启动");
try try
{ {
var paddle = "paddleOCR.exe"; var paddle = "paddleOCR.exe";
Process process = new Process(); Process process = new Process();
process.StartInfo = new ProcessStartInfo(); process.StartInfo = new ProcessStartInfo();
process.StartInfo.FileName = paddle; process.StartInfo.FileName = paddle;
process.StartInfo.WorkingDirectory =Application.StartupPath+"\\paddle"; process.StartInfo.WorkingDirectory = Application.StartupPath + "\\paddle";
process.Start(); process.Start();
} }
catch (Exception ex) catch (Exception ex)
{ {
LogNet.log.Error("打开paddleOCR失败", ex); LogNet.log.Error("打开paddleOCR失败", ex);
} }
Thread.Sleep(3000); Thread.Sleep(5000);
}
if(AppIsRun())
{
ocr = StartCplusOcr(imgPath);
} }
if (!AppIsRun()) if (AppIsRun())
{ {
try try
{ {
var paddle = "paddleOCR.exe"; ocr = StartCplusOcr(imgPath);
Process process = new Process(); break;
process.StartInfo = new ProcessStartInfo(); }
process.StartInfo.FileName = paddle; catch (Exception ex) {
process.StartInfo.WorkingDirectory = Application.StartupPath + "\\paddle"; LogNet.log.Error("OCR失败", ex);
process.Start(); AppKill();
} }
catch (Exception ex)
{
LogNet.log.Error("打开paddleOCR失败", ex);
} }
} }
return ocr; return ocr;
...@@ -100,6 +96,15 @@ namespace BLL ...@@ -100,6 +96,15 @@ namespace BLL
LogNet.log.Info("paddleOCR 未在运行,启动程序"); LogNet.log.Info("paddleOCR 未在运行,启动程序");
return false; return false;
} }
static void AppKill()
{
Process[] processes = Process.GetProcessesByName("paddleOCR");
foreach(var p in processes)
{
p.Kill();
}
LogNet.log.Info("paddleOCR AppKill");
}
public class Result public class Result
{ {
/// <summary> /// <summary>
......
...@@ -101,7 +101,7 @@ namespace SmartScan ...@@ -101,7 +101,7 @@ namespace SmartScan
pnl.Visible = false; pnl.Visible = false;
//Controls.Add(pnl); //Controls.Add(pnl);
this.tableLayoutPanel3.Controls.Add(pnl, 0, 1); this.tableLayoutPanel3.Controls.Add(pnl, 0, 1);
Maximize(); //Maximize();
clacWindowHeight(); clacWindowHeight();
} }
......
...@@ -167,6 +167,7 @@ namespace SmartScan ...@@ -167,6 +167,7 @@ namespace SmartScan
{ {
BLLCommon.mateEdit.CurrntBitmap?.Dispose(); BLLCommon.mateEdit.CurrntBitmap?.Dispose();
Bitmap bitmap = null; Bitmap bitmap = null;
MemoryStream stream = null;
try try
{ {
if (bitmapData == null) if (bitmapData == null)
...@@ -180,10 +181,9 @@ namespace SmartScan ...@@ -180,10 +181,9 @@ namespace SmartScan
byte[] imageData = Convert.FromBase64String(bitmapData.ImageData); byte[] imageData = Convert.FromBase64String(bitmapData.ImageData);
using (MemoryStream stream = new MemoryStream(imageData)) stream = new MemoryStream(imageData);
{
bitmap = new Bitmap(stream); bitmap = new Bitmap(stream);
}
if (bitmap == null) if (bitmap == null)
{ {
return new WebResultCode() { ErrorCode = -1, Msg = "图片解析完成为空;" }; return new WebResultCode() { ErrorCode = -1, Msg = "图片解析完成为空;" };
...@@ -263,6 +263,7 @@ namespace SmartScan ...@@ -263,6 +263,7 @@ namespace SmartScan
} }
finally { finally {
bitmap?.Dispose(); bitmap?.Dispose();
stream?.Dispose();
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!