def get_act_pos_by_icon(self, cv_screen, icon, crop=False):
    (vh, vw) = (self.vh, self.vw)
    raw_screen = cv_screen.copy()
    if (self.scale != 1):
        cv_screen = cv2.resize(cv_screen, (int((self.helper.viewport[0] / self.scale)), 720))
    roi = crop_cv_by_rect(cv_screen, (0, 0, (10.0 * vh), (100.0 * vh)))
    roi = cv2.cvtColor(roi, cv2.COLOR_RGB2GRAY)
    result = cv2.matchTemplate(roi, icon, cv2.TM_CCOEFF_NORMED)
    loc = np.where((result >= 0.8))
    tag_set = set()
    tag_set2 = set()
    res = {}
    dbg_screen = raw_screen.copy()
    available_activity = get_available_activity()
    for pt in zip(*loc[::(- 1)]):
        pos_key = ((pt[0] // 100), (pt[1] // 100))
        pos_key2 = (int(((pt[0] / 100) + 0.5)), int(((pt[1] / 100) + 0.5)))
        if ((pos_key in tag_set) or (pos_key2 in tag_set2)):
            continue
        tag_set.add(pos_key)
        tag_set2.add(pos_key2)
        if (icon1 is icon):
            (x, y) = ((int(pt[0]) + 35), (int(pt[1]) - 6))
            (tw, th) = map(self.apply_scale, (180, 40))
        else:
            (x, y) = ((int(pt[0]) + 35), (int(pt[1]) - 3))
            (tw, th) = map(self.apply_scale, (150, 30))
        (l, t) = map(self.apply_scale, (x, y))
        tag_img = raw_screen[t:(t + th), l:(l + tw)]
        if crop:
            gray_tag = cv2.cvtColor(tag_img, cv2.COLOR_RGB2GRAY)
            tag_img = crop_image_only_outside(gray_tag, tag_img, 160)
        factor = (2.5 - self.scale)
        if (factor > 1):
            tag_img = cv2.resize(tag_img, (0, 0), fx=factor, fy=factor, interpolation=cv2.INTER_LINEAR)
        name = ocr_and_correct(tag_img, available_activity, model_name='densenet-lite-fc', log_level=logging.INFO)
        if name:
            res[name] = (int((l + (85 * self.scale))), int((t + (20 * self.scale))))
        cv2.rectangle(dbg_screen, (l, t), ((l + tw), (t + th)), (255, 255, 0), 2)
    return res
def get_act_pos_by_icon(self, cv_screen, icon, crop=False):
    (vh, vw) = (self.vh, self.vw)
    raw_screen = cv_screen.copy()
    if (self.scale != 1):
        cv_screen = cv2.resize(cv_screen, (int((self.helper.viewport[0] / self.scale)), 720))
    roi = crop_cv_by_rect(cv_screen, (0, 0, (10.0 * vh), (100.0 * vh)))
    roi = cv2.cvtColor(roi, cv2.COLOR_RGB2GRAY)
    result = cv2.matchTemplate(roi, icon, cv2.TM_CCOEFF_NORMED)
    loc = np.where((result >= 0.8))
    tag_set = set()
    tag_set2 = set()
    res = {}
    dbg_screen = raw_screen.copy()
    available_activity = get_available_activity()
    for pt in zip(*loc[::(- 1)]):
        pos_key = ((pt[0] // 100), (pt[1] // 100))
        pos_key2 = (int(((pt[0] / 100) + 0.5)), int(((pt[1] / 100) + 0.5)))
        if ((pos_key in tag_set) or (pos_key2 in tag_set2)):
            continue
        tag_set.add(pos_key)
        tag_set2.add(pos_key2)
        if (icon1 is icon):
            (x, y) = ((int(pt[0]) + 35), (int(pt[1]) - 6))
            (tw, th) = map(self.apply_scale, (180, 40))
        else:
            (x, y) = ((int(pt[0]) + 35), (int(pt[1]) - 3))
            (tw, th) = map(self.apply_scale, (150, 30))
        (l, t) = map(self.apply_scale, (x, y))
        tag_img = raw_screen[t:(t + th), l:(l + tw)]
        if crop:
            gray_tag = cv2.cvtColor(tag_img, cv2.COLOR_RGB2GRAY)
            tag_img = crop_image_only_outside(gray_tag, tag_img, 160)
        factor = (2.5 - self.scale)
        if (factor > 1):
            tag_img = cv2.resize(tag_img, (0, 0), fx=factor, fy=factor, interpolation=cv2.INTER_LINEAR)
        name = ocr_and_correct(tag_img, available_activity, model_name='densenet-lite-fc', log_level=logging.INFO)
        if name:
            res[name] = (int((l + (85 * self.scale))), int((t + (20 * self.scale))))
        cv2.rectangle(dbg_screen, (l, t), ((l + tw), (t + th)), (255, 255, 0), 2)
    return res