Update ScreenMatching.cs, ServiceMain.cs

This commit is contained in:
Namhyeon Go 2024-08-12 16:53:31 +09:00
parent cf34039f5a
commit 15bd7d40db
2 changed files with 24 additions and 2 deletions

View File

@ -51,10 +51,11 @@ public class ScreenMatching
public int Bottom;
}
private ServiceMain parent;
private List<Bitmap> templateImages;
private string templateFolderPath;
private int currentTemplateIndex = 0;
private ServiceMain parent;
private string captureMode;
public ScreenMatching(ServiceBase parent, string workingDirectory)
{
@ -62,9 +63,15 @@ public class ScreenMatching
templateFolderPath = Path.Combine(workingDirectory, "app/assets/img/_templates");
templateImages = new List<Bitmap>();
SetCaptureMode("screen");
LoadTemplateImages();
}
public void SetCaptureMode(string captureMode)
{
this.captureMode = captureMode;
}
public void LoadTemplateImages()
{
string[] files;
@ -87,6 +94,21 @@ public class ScreenMatching
}
}
// 캡쳐 및 템플릿 매칭 진행
public List<ScreenMatchResult> CaptureAndMatch()
{
switch(captureMode)
{
case "screen": // 화면 기준
return CaptureAndMatchAllScreens();
case "windows": // 윈도우 핸들 기준
return CaptureAndMatchAllWindows();
}
return new List<ScreenMatchResult>();
}
// 화면을 기준으로 찾기
public List<ScreenMatchResult> CaptureAndMatchAllScreens()
{

View File

@ -263,7 +263,7 @@ namespace WelsonJS.Service
{
try
{
List<ScreenMatchResult> matchedResults = screenMatcher.CaptureAndMatchAllScreens();
List<ScreenMatchResult> matchedResults = screenMatcher.CaptureAndMatch();
matchedResults.ForEach(result =>
{
if (result.MaxCorrelation > 0.0) {