Exemplo n.º 1
0
def getCount(frame, team_color, control):
    ''' カウントを取得する '''
    # 記録リスト
    count_list = ['nodata', 'nodata']

    # アルファとブラボー
    for i in range(2):
        # 数字画像
        image_num = image_act if i == 0 else image_bct
        # 数字の色は通常はチームカラー、確保中は白
        color = team_color[i] if control != i + 1 else 'wht'
        # カウント表示位置
        TL = (L_cnt[i], T_cnt[1])
        BR = (R_cnt[i], B_cnt[1])
        # カウント数字取得
        count = iip.getNumber(frame,
                              TL,
                              BR,
                              image_num,
                              threshold=color,
                              color_type='HSV',
                              resize='on')
        # リストに記録
        count_list[i] = count

    return count_list
Exemplo n.º 2
0
def getCount(frame):
    ''' カウントを取得する '''
    # 記録リスト
    count_list = [100, 100]

    # アルファとブラボー
    for i in range(2):
        # 「のこり」部分の切り取り
        t = T_rmn
        b = B_rmn
        l = L_rmn[i]
        r = R_rmn[i]
        img_trm = frame[t:b, l:r]
        # 白で二値化
        bin_trm = cv2.inRange(img_trm, thd_rgb['wht'][0], thd_rgb['wht'][1])
        # 「のこり」画像
        bin_rmn = image_rmn[i]
        # 一致率と位置を算出
        jug = cv2.matchTemplate(bin_trm, bin_rmn, cv2.TM_CCOEFF_NORMED)
        minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(jug)

        # 表示が重なってカウントが見えない場合があるので閾値を設ける
        if maxVal > thd_rmn:
            # 「のこり」の位置から数字の左右位置を算出
            width_rmn = bin_rmn.shape[1]
            center = L_rmn[i] + maxLoc[0] + width_rmn / 2
            left = round(center - width_count / 2)
            right = round(center + width_count / 2)
            # カウント座標
            TL = (left, T_cnt)
            BR = (right, B_cnt)
            # 数字画像
            image_num = image_act if i == 0 else image_bct
            # カウント数字取得
            count = iip.getNumber(frame, TL, BR, image_num)
            # リストに記録
            count_list[i] = count

    return count_list
Exemplo n.º 3
0
def getPenaltyCount(frame, jug_pena):
    ''' ペナルティカウントを取得する '''
    # 記録リスト
    pcount_list = [0, 0]

    # アルファとブラボー
    for i in range(2):
        # ペナルティカウントがあれば
        if jug_pena[i]:
            # ペナルティカウント表示位置
            TL = TL_pct[i]
            BR = BR_pct[i]
            # カウント数字取得
            color = thd_rgb['wht']
            count = iip.getNumber(frame,
                                  TL,
                                  BR,
                                  image_pct,
                                  threshold=color,
                                  resize='on')
            # リストに記録
            pcount_list[i] = count

    return pcount_list
Exemplo n.º 4
0
def getJudge(frame, rule):
    ''' ジャッジ数字取得 '''
    # ナワバリバトル
    if rule == 'turf':
        # 単位「%」画像
        bin_per = cv2.imread('.\\pbm\\judge_percent.pbm', -1)
        # 単位「p」画像
        bin_pnt = cv2.imread('.\\pbm\\judge_point_p.pbm', -1)

        # 数字画像読み込み
        num_per = []
        num_pnt = []
        for num in range(10):
            # パーセント
            bin_num = cv2.imread('.\\pbm\\judge_count_' + str(num) + '.pbm',
                                 -1)
            num_per.append(bin_num)
            # ポイント
            bin_num = cv2.imread('.\\pbm\\judge_point_' + str(num) + '.pbm',
                                 -1)
            num_pnt.append(bin_num)

        # 出力リスト
        list_top = [
            'percent_alfa', 'percent_bravo', 'point_alfa', 'point_bravo'
        ]
        judge_list = [list_top, [0, 0, 0, 0]]

        # アルファとブラボー
        for i in range(2):
            # パーセントの取得
            TL = TL_cnt[i]
            BR = BR_cnt[i]
            percent = iip.getNumber(frame, TL, BR, num_per, image_unit=bin_per)
            # コンピュータの誤差対策に0.1をかけたら丸める
            percent = round(percent * 0.1, 1)

            # ポイントの取得
            TL = TL_pnt[i]
            BR = BR_pnt[i]
            point = iip.getNumber(frame, TL, BR, num_pnt, image_unit=bin_pnt)

            # リストに記録
            judge_list[1][i] = percent
            judge_list[1][i + 2] = point

    # ガチルール
    else:
        # 「ノックアウト」画像
        bin_ko = cv2.imread('.\\pbm\\judge_ko.pbm', -1)
        # 「カウント」画像
        bin_cnt = cv2.imread('.\\pbm\\judge_count.pbm', -1)

        # 数字画像読み込み
        num_cnt = []
        for num in range(10):
            bin_num = cv2.imread('.\\pbm\\judge_count_' + str(num) + '.pbm',
                                 -1)
            num_cnt.append(bin_num)

        # 出力リスト
        list_top = ['count_alfa', 'count_bravo', 'point_alfa', 'point_bravo']
        judge_list = [list_top, [0, 0, 0, 0]]

        # アルファとブラボー
        for i in range(2):
            # 「ノックアウト」との一致率を算出
            TL = TL_cnt[i]
            BR = BR_cnt[i]
            val_ko = iip.getMatchValue(bin_ko, frame, TL, BR)

            # 閾値以上ならばノックアウト
            if val_ko > thd_val:
                count = 'ko'
                point = 500
            else:
                # カウントの取得
                TL = TL_cnt[i]
                BR = BR_cnt[i]
                count = iip.getNumber(frame,
                                      TL,
                                      BR,
                                      num_cnt,
                                      image_unit=bin_cnt)

                if count >= 0:
                    point = count * 5
                else:
                    point = 0

            # リストに記録
            judge_list[1][i] = count
            judge_list[1][i + 2] = point

    return judge_list
Exemplo n.º 5
0
def getResult(frame, rule):
    ''' リザルト数字取得 '''
    # 出力リスト
    list_top = ['pt_'   + str(i) for i in range(1, 9)] \
             + ['kill_' + str(i) for i in range(1, 9)] \
             + ['sp_'   + str(i) for i in range(1, 9)]
    result_list = [list_top, [0 for i in range(24)]]

    # ナワバリバトルは塗りポイントも取得
    if rule == 'turf':
        # 単位「p」画像
        bin_ptw = cv2.imread('.\\pbm\\result_point_win_p.pbm', -1)
        bin_ptl = cv2.imread('.\\pbm\\result_point_lose_p.pbm', -1)

        # 数字画像読み込み
        num_ptw = []
        num_ptl = []
        for num in range(10):
            # 勝利側
            bin_num = cv2.imread(
                '.\\pbm\\result_point_win_' + str(num) + '.pbm', -1)
            num_ptw.append(bin_num)
            # 敗北側
            bin_num = cv2.imread(
                '.\\pbm\\result_point_lose_' + str(num) + '.pbm', -1)
            num_ptl.append(bin_num)

        # 8プレイヤー分
        for i in range(8):
            # 対象座標
            TL = [L_pnt, T_pnt[i]]
            BR = [R_pnt, B_pnt[i]]

            # 勝利側
            if i < 4:
                num_pnt = iip.getNumber(frame,
                                        TL,
                                        BR,
                                        num_ptw,
                                        image_unit=bin_ptw)
                # 勝利ボーナス1000ptを差し引く
                num_pnt -= 1000

            # 敗北側
            else:
                num_pnt = iip.getNumber(frame,
                                        TL,
                                        BR,
                                        num_ptl,
                                        image_unit=bin_ptl)
            # リストに記録
            result_list[1][i] = num_pnt

    # たおした数とスペシャル回数
    # 数字画像読み込み 数字は共用
    num_ksw = []
    num_ksl = []
    for num in range(10):
        # 勝利側
        bin_num = cv2.imread('.\\pbm\\result_killsp_win_' + str(num) + '.pbm',
                             -1)
        num_ksw.append(bin_num)
        # 敗北側
        bin_num = cv2.imread('.\\pbm\\result_killsp_lose_' + str(num) + '.pbm',
                             -1)
        num_ksl.append(bin_num)

    # 8プレイヤー分
    for i in range(8):
        # たおした数
        TL_kil = [L_kil, T_kil[i]]
        BR_kil = [R_kil, B_kil[i]]
        # スペシャル回数
        TL_spw = [L_spw, T_spw[i]]
        BR_spw = [R_spw, B_spw[i]]

        # 勝利側
        if i < 4:
            num_kil = iip.getNumber(frame, TL_kil, BR_kil, num_ksw)
            num_spw = iip.getNumber(frame, TL_spw, BR_spw, num_ksw)

        # 敗北側
        else:
            num_kil = iip.getNumber(frame, TL_kil, BR_kil, num_ksl)
            num_spw = iip.getNumber(frame, TL_spw, BR_spw, num_ksl)

        # リストに記録
        result_list[1][i + 8] = num_kil
        result_list[1][i + 16] = num_spw

    return result_list