Skip to content

Commit 67a7333

Browse files
authored
Merge pull request #133 from killkimno/1.300v
1.308v
2 parents 32a3efb + 9cb433a commit 67a7333

File tree

14 files changed

+664
-596
lines changed

14 files changed

+664
-596
lines changed

MORT/Form1.Designer.cs

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MORT/Form1.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ public void MakeAndStartSnapShop()
16731673
{
16741674
Action callback = delegate
16751675
{
1676-
if(!MySettingManager.isUseAttachedCapture && MySettingManager.NowIsActiveWindow)
1676+
if(!MySettingManager.IsUseAttachedCapture && MySettingManager.NowIsActiveWindow)
16771677
{
16781678
int waitCount = 0;
16791679

@@ -1858,12 +1858,6 @@ public void StartTrnas(OcrMethodType ocrMethodType)
18581858
isError = true;
18591859
errorMsg = LocalizeString("Overlay Error OCR");
18601860
}
1861-
else if(!MySettingManager.isUseAttachedCapture && !MySettingManager.NowIsActiveWindow)
1862-
{
1863-
isError = true;
1864-
errorMsg = LocalizeString("Overlay Error Window", true);
1865-
}
1866-
18671861

18681862
if(isError)
18691863
{

MORT/MORT.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@
4343
<PackageReference Include="Google.GenAI" Version="0.3.0" />
4444
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2045.28" />
4545
<PackageReference Include="Python.Included" Version="3.11.6" />
46+
<PackageReference Include="R3" Version="1.3.0" />
4647
<PackageReference Include="RestSharp" Version="106.12.0" />
4748
<PackageReference Include="SharpClipboard" Version="3.5.2" />
4849
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
50+
<PackageReference Include="System.Net.Http" Version="4.3.4" />
51+
<PackageReference Include="System.Net.Security" Version="4.3.1" />
4952
<PackageReference Include="System.Runtime.InteropServices.WindowsRuntime" Version="4.3.0" />
53+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
5054
<PackageReference Include="System.Windows.Extensions" Version="7.0.0" />
5155
</ItemGroup>
5256

MORT/Manager/FormManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ public void ShowScreenCapture()
203203
//test
204204
Action callback = delegate
205205
{
206-
MyMainForm.MySettingManager.isUseAttachedCapture = true;
206+
MyMainForm.MySettingManager.IsUseAttachedCapture = true;
207207
Console.WriteLine("뭔가가 선택 됨");
208208
};
209209

210210
Action stopCallback = delegate
211211
{
212212
if (this != null && MyMainForm != null && MyMainForm.MySettingManager != null)
213213
{
214-
MyMainForm.MySettingManager.isUseAttachedCapture = false;
214+
MyMainForm.MySettingManager.IsUseAttachedCapture = false;
215215
}
216216
};
217217

@@ -220,7 +220,7 @@ public void ShowScreenCapture()
220220
{
221221
if(this != null && MyMainForm != null && MyMainForm.MySettingManager != null)
222222
{
223-
MyMainForm.MySettingManager.isUseAttachedCapture = false;
223+
MyMainForm.MySettingManager.IsUseAttachedCapture = false;
224224
screenCaptureUI = null;
225225
}
226226

MORT/Manager/OCRDataManager.cs

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,17 @@ public bool GetIsEndLine()
276276

277277
public class ResultData
278278
{
279-
public int index;
279+
public int Index;
280280
//TODO : 미리 다 해놓아야 한다.
281281
public bool SnapShot;
282-
public List<LineData> lineDataList = new List<LineData>();
283-
public List<TransData> transDataList = new List<TransData>();
284-
public Rectangle resultRect;
282+
public List<LineData> LineDataList = new List<LineData>();
283+
public List<TransData> TransDataList = new List<TransData>();
284+
public Rectangle ResultRect;
285285
public bool UseAutoColor { get; private set; }
286286
public List<(Color Font, Color BackGround)> AutoColor { get; private set; } = new();
287287

288288
//public string ocrString = "";
289-
public string transString = "";
289+
public string TransString = "";
290290

291291
public void AddAutoColor(Color fontColor, Color backGroundColor)
292292
{
@@ -311,11 +311,11 @@ public string GetOCR()
311311
{
312312
string ocr = "";
313313

314-
for(int i = 0; i < lineDataList.Count; i++)
314+
for(int i = 0; i < LineDataList.Count; i++)
315315
{
316-
for(int j = 0; j < lineDataList[i].wordList.Count; j++)
316+
for(int j = 0; j < LineDataList[i].wordList.Count; j++)
317317
{
318-
ocr += lineDataList[i].wordList[j] + " ";
318+
ocr += LineDataList[i].wordList[j] + " ";
319319
}
320320
}
321321

@@ -325,9 +325,9 @@ public string GetOCR()
325325
public string GetTrans()
326326
{
327327
string ocr = "";
328-
for(int i = 0; i < transDataList.Count; i++)
328+
for(int i = 0; i < TransDataList.Count; i++)
329329
{
330-
ocr += transDataList[i].trans + " ";
330+
ocr += TransDataList[i].trans + " ";
331331
}
332332

333333
return GetOCR();
@@ -336,13 +336,13 @@ public string GetTrans()
336336
public List<string> GetOcrText()
337337
{
338338
List<string> list = new List<string>();
339-
for(int i = 0; i < transDataList.Count; i++)
339+
for(int i = 0; i < TransDataList.Count; i++)
340340
{
341341
string text = "";
342-
for(int j = 0; j < transDataList[i].lineDataList.Count; j++)
342+
for(int j = 0; j < TransDataList[i].lineDataList.Count; j++)
343343
{
344344

345-
text += transDataList[i].lineDataList[j].lineString;
345+
text += TransDataList[i].lineDataList[j].lineString;
346346
}
347347

348348
list.Add(text);
@@ -373,9 +373,9 @@ private static bool IsTitleData(LineData lineData, bool removeSpaceMode)
373373
public void InitLine(bool mergeLine, bool removeSpaceMode)
374374
{
375375
TransData transData = null;
376-
for(int i = 0; i < lineDataList.Count; i++)
376+
for(int i = 0; i < LineDataList.Count; i++)
377377
{
378-
var lineData = lineDataList[i];
378+
var lineData = LineDataList[i];
379379
if(lineData.angleType == WordAngleType.Horizontal)
380380
{
381381
var rect = RecognizeRect(lineData.lineString, lineData.lineRect);
@@ -392,14 +392,14 @@ public void InitLine(bool mergeLine, bool removeSpaceMode)
392392
if(isNew)
393393
{
394394
transData = new TransData();
395-
transData.lineDataList.Add(lineDataList[i]);
395+
transData.lineDataList.Add(LineDataList[i]);
396396
transData.isInsert = true;
397-
transData.angleType = lineDataList[i].angleType;
398-
this.transDataList.Add(transData);
397+
transData.angleType = LineDataList[i].angleType;
398+
this.TransDataList.Add(transData);
399399

400400
//첫 시작이 특정 수 미만이면 바로 다음으로 넘어간다
401401
//TODO : 인접한 문구가 있는지는 검사해야한다
402-
if(IsTitleData(lineDataList[i], removeSpaceMode))
402+
if(IsTitleData(LineDataList[i], removeSpaceMode))
403403
{
404404
transData.TitleData = true;
405405
transData = null;
@@ -408,12 +408,12 @@ public void InitLine(bool mergeLine, bool removeSpaceMode)
408408
else
409409
{
410410

411-
if(!Form1.IsDebugTransOneLine && transData != null && transData.CheckIsSameLine(lineDataList[i], mergeLine))
411+
if(!Form1.IsDebugTransOneLine && transData != null && transData.CheckIsSameLine(LineDataList[i], mergeLine))
412412
{
413413
//같은 라인이다.
414414

415-
bool isEnd = lineDataList[i].GetIsEndLine();
416-
transData.lineDataList.Add(lineDataList[i]);
415+
bool isEnd = LineDataList[i].GetIsEndLine();
416+
transData.lineDataList.Add(LineDataList[i]);
417417

418418
if(isEnd)
419419
{
@@ -424,14 +424,14 @@ public void InitLine(bool mergeLine, bool removeSpaceMode)
424424
{
425425
//같은 라인이 아니다.
426426
transData = new TransData();
427-
transData.lineDataList.Add(lineDataList[i]);
427+
transData.lineDataList.Add(LineDataList[i]);
428428
transData.isInsert = true;
429-
transData.angleType = lineDataList[i].angleType;
429+
transData.angleType = LineDataList[i].angleType;
430430

431-
this.transDataList.Add(transData);
431+
this.TransDataList.Add(transData);
432432

433433
//첫 시작이 특정 수 미만이면 바로 다음으로 넘어간다
434-
if(IsTitleData(lineDataList[i], removeSpaceMode))
434+
if(IsTitleData(LineDataList[i], removeSpaceMode))
435435
{
436436
transData.TitleData = true;
437437
transData = null;
@@ -440,19 +440,19 @@ public void InitLine(bool mergeLine, bool removeSpaceMode)
440440
}
441441
}
442442

443-
for(int i = 0; i < transDataList.Count; i++)
443+
for(int i = 0; i < TransDataList.Count; i++)
444444
{
445-
transDataList[i].lineRect = new Rectangle();
445+
TransDataList[i].lineRect = new Rectangle();
446446

447-
if(transDataList[i].lineDataList.Count > 0)
447+
if(TransDataList[i].lineDataList.Count > 0)
448448
{
449-
var rect = transDataList[i].lineDataList[0].lineRect;
450-
for(int j = 1; j < transDataList[i].lineDataList.Count; j++)
449+
var rect = TransDataList[i].lineDataList[0].lineRect;
450+
for(int j = 1; j < TransDataList[i].lineDataList.Count; j++)
451451
{
452-
rect = Rectangle.Union(rect, transDataList[i].lineDataList[j].lineRect);
452+
rect = Rectangle.Union(rect, TransDataList[i].lineDataList[j].lineRect);
453453
}
454454

455-
transDataList[i].lineRect = rect;
455+
TransDataList[i].lineRect = rect;
456456
}
457457
}
458458
}
@@ -463,13 +463,13 @@ public void InitLine(bool mergeLine, bool removeSpaceMode)
463463
/// <param name="transString"></param>
464464
public void ApplyTransResult(string transString, SettingManager.TransType transType)
465465
{
466-
this.transString = transString;
466+
this.TransString = transString;
467467

468-
string[] words = Util.GetSpliteByToken(this.transString, transType);
468+
string[] words = Util.GetSpliteByToken(this.TransString, transType);
469469

470-
for(int i = 0; i < transDataList.Count && i < words.Length; i++)
470+
for(int i = 0; i < TransDataList.Count && i < words.Length; i++)
471471
{
472-
transDataList[i].trans = words[i];
472+
TransDataList[i].trans = words[i];
473473
}
474474
}
475475

@@ -507,7 +507,7 @@ public ResultData GetData(int index)
507507

508508
for(int i = 0; i < dataList.Count; i++)
509509
{
510-
if(dataList[i].index == index)
510+
if(dataList[i].Index == index)
511511
{
512512
data = dataList[i];
513513
}
@@ -619,10 +619,16 @@ public static bool GetIsIntersectsWith(LineData beforeData, LineData data, bool
619619
{
620620
return false;
621621
}
622-
else
622+
623+
// x 축 검사 - 두 라인의 시작점 차이가 폰트 사이즈의 4배 이상이면 합치지 않음
624+
float xGap = Math.Abs(beforeData.lineRect.X - data.lineRect.X);
625+
float xThre = fontSize * 4f;
626+
if (xGap >= xThre)
623627
{
624-
return true;
628+
return false;
625629
}
630+
631+
return true;
626632
}
627633
else
628634
{
@@ -660,7 +666,7 @@ public void ClearData()
660666
public ResultData AddData(OcrResult data, int index, bool snapShot, bool removeSpace)
661667
{
662668
ResultData resultData = new ResultData();
663-
resultData.index = index;
669+
resultData.Index = index;
664670
resultData.SnapShot = snapShot;
665671

666672
//Util.ShowLog("line = " + point.lineCount);
@@ -699,7 +705,7 @@ public ResultData AddData(OcrResult data, int index, bool snapShot, bool removeS
699705
}
700706

701707
lineData.lineString = lineString;
702-
resultData.lineDataList.Add(lineData);
708+
resultData.LineDataList.Add(lineData);
703709

704710
if(lineRect.Height > lineRect.Width * 1.5f)
705711
{
@@ -712,16 +718,16 @@ public ResultData AddData(OcrResult data, int index, bool snapShot, bool removeS
712718
}
713719

714720
//전체 영역 처리.
715-
if(resultData.lineDataList.Count == 1)
721+
if(resultData.LineDataList.Count == 1)
716722
{
717-
resultData.resultRect = resultData.lineDataList[0].lineRect;
723+
resultData.ResultRect = resultData.LineDataList[0].lineRect;
718724
}
719-
else if(resultData.lineDataList.Count > 1)
725+
else if(resultData.LineDataList.Count > 1)
720726
{
721-
resultData.resultRect = resultData.lineDataList[0].lineRect;
722-
for(int i = 1; i < resultData.lineDataList.Count; i++)
727+
resultData.ResultRect = resultData.LineDataList[0].lineRect;
728+
for(int i = 1; i < resultData.LineDataList.Count; i++)
723729
{
724-
resultData.resultRect = Rectangle.Union(resultData.resultRect, resultData.lineDataList[i].lineRect);
730+
resultData.ResultRect = Rectangle.Union(resultData.ResultRect, resultData.LineDataList[i].lineRect);
725731
}
726732
}
727733

0 commit comments

Comments
 (0)