Skip to content

Commit 47fd842

Browse files
committed
md: support narrow screen
1 parent 0497d7b commit 47fd842

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Strategies/MadodoraStrategy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def cvPassHomeDialog(self, frame: cv.Mat, framePoint: FramePoint) -> bool:
126126
_, roiDialogBgBin = cv.threshold(roiDialogGray, 100, 255, cv.THRESH_BINARY)
127127
meanDialogTextBin: float = cv.mean(roiDialogTextBin)[0]
128128
meanDialogBgBin: float = cv.mean(roiDialogBgBin)[0]
129-
hasDialogBg: bool = meanDialogBgBin < 20 and meanDialogBgBin > 0.1
130-
hasDialogText: bool = meanDialogTextBin < 10 and meanDialogTextBin > 0.1
129+
hasDialogBg: bool = meanDialogBgBin < 25 and meanDialogBgBin > 0.1
130+
hasDialogText: bool = meanDialogTextBin < 20 and meanDialogTextBin > 0.1
131131

132132
roiUnderDialog = self.underHomeDialogRect.cutRoiToUmat(frame)
133133
roiUnderDialogGray = cv.cvtColor(roiUnderDialog, cv.COLOR_BGR2GRAY)
@@ -152,8 +152,8 @@ def cvPassDialog(self, frame: cv.Mat, framePoint: FramePoint) -> bool:
152152
_, roiDialogBgBin = cv.threshold(roiDialogGray, 100, 255, cv.THRESH_BINARY)
153153
meanDialogTextBin: float = cv.mean(roiDialogTextBin)[0]
154154
meanDialogBgBin: float = cv.mean(roiDialogBgBin)[0]
155-
hasDialogBg: bool = meanDialogBgBin < 20 and meanDialogBgBin > 0.1
156-
hasDialogText: bool = meanDialogTextBin < 10 and meanDialogTextBin > 0.1
155+
hasDialogBg: bool = meanDialogBgBin < 25 and meanDialogBgBin > 0.1
156+
hasDialogText: bool = meanDialogTextBin < 20 and meanDialogTextBin > 0.1
157157

158158
isValidDialog = hasDialogBg and hasDialogText
159159

@@ -166,7 +166,7 @@ def cvPassDialog(self, frame: cv.Mat, framePoint: FramePoint) -> bool:
166166
def cvPassWhitescreen(self, frame: cv.Mat, framePoint: FramePoint) -> bool:
167167
roiWhitescreen = self.whitescreenRect.cutRoiToUmat(frame)
168168
roiWhitescreenGray = cv.cvtColor(roiWhitescreen, cv.COLOR_BGR2GRAY)
169-
_, roiWhitescreenBgBin = cv.threshold(roiWhitescreenGray, 220, 255, cv.THRESH_BINARY_INV)
169+
_, roiWhitescreenBgBin = cv.threshold(roiWhitescreenGray, 170, 255, cv.THRESH_BINARY_INV)
170170
_, roiWhitescreenTextBin = cv.threshold(roiWhitescreenGray, 20, 255, cv.THRESH_BINARY_INV)
171171
meanWhitescreenBgBin: float = cv.mean(roiWhitescreenBgBin)[0]
172172
meanWhitescreenTextBin: float = cv.mean(roiWhitescreenTextBin)[0]
@@ -186,7 +186,7 @@ def cvPassBlackscreen(self, frame: cv.Mat, framePoint: FramePoint) -> bool:
186186
_, roiBlackscreenBlackBgBin = cv.threshold(roiBlackscreenGray, 10, 255, cv.THRESH_BINARY)
187187
_, roiBlackscreenDimBgBin = cv.threshold(roiBlackscreenGray, 100, 255, cv.THRESH_BINARY)
188188
_, roiBlackscreenTextBin = cv.threshold(roiBlackscreenGray, 240, 255, cv.THRESH_BINARY)
189-
roiBlackscreenTextBinDialate = cv.morphologyEx(roiBlackscreenTextBin, cv.MORPH_DILATE, kernel=cv.getStructuringElement(cv.MORPH_RECT, (5, 5)))
189+
roiBlackscreenTextBinDialate = cv.morphologyEx(roiBlackscreenTextBin, cv.MORPH_DILATE, kernel=cv.getStructuringElement(cv.MORPH_RECT, (9, 9)))
190190
roiBlackscreenDimBgBinExcludeText = cv.bitwise_and(roiBlackscreenDimBgBin, cv.bitwise_not(roiBlackscreenTextBinDialate))
191191

192192
meanBlackscreenBlackBgBin: float = cv.mean(roiBlackscreenBlackBgBin)[0]

config.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,16 @@ md:
123123
homeDialogRect: [0.25, 0.75, 0.74, 0.94]
124124
underHomeDialogRect: [0.25, 0.75, 0.94, 1.00]
125125
dialogRect: [0.25, 0.75, 0.80, 1.00]
126-
whitescreenRect: [0.17, 0.83, 0.20, 0.80]
127-
blackscreenRect: [0.17, 0.83, 0.20, 0.80]
126+
whitescreenRect: [0.17, 0.83, 0.30, 0.70]
127+
blackscreenRect: [0.17, 0.83, 0.30, 0.70]
128+
leftBubbleRect: [0.12, 0.45, 0.15, 0.25]
129+
rightBubbleRect: [0.55, 0.88, 0.15, 0.25]
130+
narrow:
131+
homeDialogRect: [0.25, 0.75, 0.74, 0.94]
132+
underHomeDialogRect: [0.25, 0.75, 0.94, 1.00]
133+
dialogRect: [0.25, 0.75, 0.80, 1.00]
134+
whitescreenRect: [0.09, 0.91, 0.30, 0.70]
135+
blackscreenRect: [0.17, 0.83, 0.30, 0.70]
128136
leftBubbleRect: [0.12, 0.45, 0.15, 0.25]
129137
rightBubbleRect: [0.55, 0.88, 0.15, 0.25]
130138

0 commit comments

Comments
 (0)