Skip to content

Commit

Permalink
Merge branch 'master' of ssh://git-qa.gz.netease.com:32200/maki/airtest
Browse files Browse the repository at this point in the history
  • Loading branch information
yimelia committed Aug 4, 2021
2 parents b1b5c17 + adc25a8 commit a7bd738
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions airtest/aircv/cal_confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def cal_rgb_confidence(img_src_rgb, img_sch_rgb):

# 计算BGR三通道的confidence,存入bgr_confidence:
bgr_confidence = [0, 0, 0]
# 加入取值范围干扰,防止算法过于放大微小差异
src_bgr[0][0,0] = sch_bgr[0][0,0] = 0
src_bgr[0][0,1] = sch_bgr[0][0,1] = 255
for i in range(3):
res_temp = cv2.matchTemplate(src_bgr[i], sch_bgr[i], cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res_temp)
Expand Down
5 changes: 4 additions & 1 deletion airtest/aircv/multiscale_template_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import time

from airtest.utils.logger import get_logger
from airtest.aircv.error import TemplateInputError
from airtest import aircv
from .utils import generate_result, check_source_larger_than_search, img_mat_rgb_2_gray, print_run_time
from .cal_confidence import cal_rgb_confidence, cal_ccoeff_confidence
Expand Down Expand Up @@ -158,11 +159,13 @@ def find_best_result(self):
if self.resolution!=():
# 第一步:校验图像输入
check_source_larger_than_search(self.im_source, self.im_search)

if self.resolution[0]<self.im_search.shape[1] or self.resolution[1]<self.im_search.shape[0]:
raise TemplateInputError("error: resolution is too small.")
# 第二步:计算模板匹配的结果矩阵res
if not self.record_pos is None:
area, self.resolution = self._get_area_scope(self.im_source, self.im_search, self.record_pos, self.resolution)
self.im_source = aircv.crop_image(self.im_source, area)
check_source_larger_than_search(self.im_source, self.im_search)
r_min, r_max = self._get_ratio_scope(
self.im_source, self.im_search, self.resolution)
s_gray, i_gray = img_mat_rgb_2_gray(self.im_search), img_mat_rgb_2_gray(self.im_source)
Expand Down

0 comments on commit a7bd738

Please sign in to comment.