mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-04 11:15:18 +08:00
refactor: rename enum name
This commit is contained in:
18
BetterGenshinImpact/Core/Recognition/OcrEngineTypes.cs
Normal file
18
BetterGenshinImpact/Core/Recognition/OcrEngineTypes.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition
|
||||
{
|
||||
public enum OcrEngineTypes
|
||||
{
|
||||
// 通用
|
||||
MediaOcr,
|
||||
|
||||
// 特定模型
|
||||
YasModel,
|
||||
YapModel
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace BetterGenshinImpact.Core.Recognition;
|
||||
[Serializable]
|
||||
public class RecognitionObject
|
||||
{
|
||||
public RecognitionType RecognitionType { get; set; }
|
||||
public RecognitionTypes RecognitionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 感兴趣的区域
|
||||
@@ -115,7 +115,7 @@ public class RecognitionObject
|
||||
/// <summary>
|
||||
/// OCR 引擎。可选,默认 Media.Ocr。
|
||||
/// </summary>
|
||||
public string? OcrEngine { get; set; }
|
||||
public OcrEngineTypes OcrEngine { get; set; } = OcrEngineTypes.MediaOcr;
|
||||
|
||||
/// <summary>
|
||||
/// 部分文字识别结果不准确,进行替换。可选。
|
||||
@@ -136,21 +136,4 @@ public class RecognitionObject
|
||||
public List<string> RegexMatchText { get; set; } = new();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 模型OCR识别
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用模型文字识别
|
||||
/// </summary>
|
||||
public bool UseModelTextRecognition { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 圣遗物 Yas
|
||||
/// 拾取 Yap
|
||||
/// TODO 换成枚举
|
||||
/// </summary>
|
||||
public string? ModelTextRecognitionType { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition;
|
||||
|
||||
public enum RecognitionType
|
||||
public enum RecognitionTypes
|
||||
{
|
||||
None,
|
||||
TemplateMatch,
|
||||
@@ -22,7 +22,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing.Assets
|
||||
SpaceButtonRo = new RecognitionObject
|
||||
{
|
||||
Name = "SpaceButton",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoFishing", "space.png"),
|
||||
RegionOfInterest = new Rect(info.CaptureAreaRect.Width - info.CaptureAreaRect.Width / 3,
|
||||
info.CaptureAreaRect.Height - info.CaptureAreaRect.Height / 5,
|
||||
@@ -34,7 +34,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing.Assets
|
||||
BaitButtonRo = new RecognitionObject
|
||||
{
|
||||
Name = "BaitButton",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoFishing", "bait.png"),
|
||||
RegionOfInterest = new Rect(info.CaptureAreaRect.Width - info.CaptureAreaRect.Width / 2,
|
||||
info.CaptureAreaRect.Height - info.CaptureAreaRect.Height / 4,
|
||||
@@ -46,7 +46,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing.Assets
|
||||
WaitBiteButtonRo = new RecognitionObject
|
||||
{
|
||||
Name = "WaitBiteButton",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoFishing", "wait_bite.png"),
|
||||
RegionOfInterest = new Rect(info.CaptureAreaRect.Width - info.CaptureAreaRect.Width / 2,
|
||||
info.CaptureAreaRect.Height - info.CaptureAreaRect.Height / 4,
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
var ro = new RecognitionObject()
|
||||
{
|
||||
Name = "StartFishingText",
|
||||
RecognitionType = RecognitionType.Ocr,
|
||||
RecognitionType = RecognitionTypes.Ocr,
|
||||
RegionOfInterest = new Rect(srcMat.Width / 2, srcMat.Height / 2, srcMat.Width - srcMat.Width / 2,
|
||||
srcMat.Height - srcMat.Height / 2),
|
||||
ContainMatchText = new List<string>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace BetterGenshinImpact.GameTask.AutoPick.Assets
|
||||
FRo = new RecognitionObject
|
||||
{
|
||||
Name = "F",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoPick", "F.png"),
|
||||
RegionOfInterest = new Rect(info.CaptureAreaRect.Width / 2,
|
||||
info.CaptureAreaRect.Height / 3,
|
||||
|
||||
@@ -15,7 +15,7 @@ public class AutoSkipAssets
|
||||
StopAutoButtonRo = new RecognitionObject
|
||||
{
|
||||
Name = "StopAutoButton",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoSkip", "stop_auto.png"),
|
||||
RegionOfInterest = new Rect(0, 0, info.CaptureAreaRect.Width / 5, info.CaptureAreaRect.Height / 5),
|
||||
DrawOnWindow = true
|
||||
@@ -24,7 +24,7 @@ public class AutoSkipAssets
|
||||
OptionButtonRo = new RecognitionObject
|
||||
{
|
||||
Name = "OptionButton",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoSkip", "option.png"),
|
||||
RegionOfInterest = new Rect(info.CaptureAreaRect.Width / 2, 0, info.CaptureAreaRect.Width - info.CaptureAreaRect.Width / 2, info.CaptureAreaRect.Height),
|
||||
DrawOnWindow = false
|
||||
@@ -33,7 +33,7 @@ public class AutoSkipAssets
|
||||
MenuRo = new RecognitionObject
|
||||
{
|
||||
Name = "Menu",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoSkip", "menu.png"),
|
||||
RegionOfInterest = new Rect(0, 0, info.CaptureAreaRect.Width / 4, info.CaptureAreaRect.Height / 4),
|
||||
DrawOnWindow = false
|
||||
|
||||
@@ -228,7 +228,7 @@ public class RectArea
|
||||
throw new Exception("识别对象不能为null");
|
||||
}
|
||||
|
||||
if (RecognitionType.TemplateMatch.Equals(ro.RecognitionType))
|
||||
if (RecognitionTypes.TemplateMatch.Equals(ro.RecognitionType))
|
||||
{
|
||||
if (ro.TemplateImageGreyMat == null)
|
||||
{
|
||||
@@ -265,7 +265,7 @@ public class RectArea
|
||||
return new RectArea();
|
||||
}
|
||||
}
|
||||
else if (RecognitionType.Ocr.Equals(ro.RecognitionType))
|
||||
else if (RecognitionTypes.Ocr.Equals(ro.RecognitionType))
|
||||
{
|
||||
if (ro.ContainMatchText.Count == 0 && ro.RegexMatchText.Count == 0)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BetterGenshinImpact.GameTask.RecognitionTest
|
||||
_optionButtonRo = new RecognitionObject
|
||||
{
|
||||
Name = "OptionButton",
|
||||
RecognitionType = RecognitionType.TemplateMatch,
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssertImage("AutoSkip", "option.png"),
|
||||
DrawOnWindow = true
|
||||
}.InitTemplate();
|
||||
|
||||
Reference in New Issue
Block a user