Use backward search in the screen time

This commit is contained in:
Namhyeon Go 2024-08-25 17:57:22 +09:00
parent 82ac8e5d02
commit 18e81f71ba
2 changed files with 14 additions and 5 deletions

View File

@ -296,15 +296,24 @@ public class ScreenMatch
Point bestMatch = Point.Empty;
maxCorrelation = 0;
for (int x = 0; x <= mainWidth - templateWidth; x++)
bool searchFromEnd = _params.Contains("backward");
int startX = searchFromEnd ? mainWidth - templateWidth : 0;
int endX = searchFromEnd ? -1 : mainWidth - templateWidth + 1;
int stepX = searchFromEnd ? -1 : 1;
int startY = searchFromEnd ? mainHeight - templateHeight : 0;
int endY = searchFromEnd ? -1 : mainHeight - templateHeight + 1;
int stepY = searchFromEnd ? -1 : 1;
for (int x = startX; x != endX; x += stepX)
{
for (int y = 0; y <= mainHeight - templateHeight; y++)
for (int y = startY; y != endY; y += stepY)
{
if (IsTemplateMatch(mainImage, templateImage, x, y, threshold))
{
bestMatch = new Point(x, y);
maxCorrelation = 1.0;
return bestMatch;
}
}

View File

@ -11,9 +11,9 @@ NONFREE_STRICT=false
DISABLE_SCREEN_TIME=false
DISABLE_FILE_MONITOR=false
; screen or window
SCREEN_TIME_MODE=screen
SCREEN_TIME_MODE=screen
;filename.exe
SCREEN_TIME_PARAMS=
SCREEN_TIME_PARAMS=backward
GRPC_HOST=http://localhost:50051
ES_HOST=http://localhost:9200
ES_USER=elastic