Ejemplo n.º 1
0
def process(img_data):
    char_result = []
    report = proc.preprocessing(img_data)  # 中央視窗裁剪
    report = proc.report_processing(report)  # 傷害報告類型圖片處理
    char_list = unitproc.process(report)  # 角色頭像鎖定

    if len(char_list) == 0:
        return None

    positions = [char["position"] for char in char_list]
    startX = np.min(positions)

    for i in range(len(char_list)):
        char = char_list[i]
        objUnit = unitproc.unit(char["unit_head"])
        objUnit.detect()
        result = objUnit.getResult()
        if result == False:
            continue

        result["damage"] = damage.process(
            positions[i], char["unit_head"].shape,
            report) if positions[i][0] == startX else 0
        char_result.append(result)

    return char_result
Ejemplo n.º 2
0
def process(img) -> list:
    report = proc.preprocessing(img)
    report = proc.search_processing(report)
    char_list = unitproc.process(report)
    result = []

    if len(char_list) == 0:
        return None

    for char in char_list:
        objUnit = unitproc.unit(char["unit_head"])
        objUnit.detect()
        result.append(objUnit.getResult())

    return result
Ejemplo n.º 3
0
def process(img_data):
    char_result = {
        "left": {
            "result": -1,
            "team": []
        },
        "right": {
            "result": -1,
            "team": []
        }
    }
    result_length = {"left": 0, "right": 0}
    report = proc.preprocessing(img_data)  # 中央視窗裁剪
    teams = proc.upload_processing(report)  # 傷害報告類型圖片處理
    if len(teams) == 0:
        return None

    types = ["left", "right"]
    for side in types:
        team = unitproc.process(teams[side])  # 角色頭像鎖定
        if len(team) == 0:
            return None
        for char in team:
            objUnit = unitproc.unit(char["unit_head"])
            objUnit.detect()
            result = objUnit.getResult()
            if result == False:
                print("找不到這角色")
            else:
                char_result[side]["team"].append(result)

        result_length[side] = getResult(teams[side + "Result"])

    if (result_length["right"] > result_length["left"]):
        char_result["right"]["result"] = 0
        char_result["left"]["result"] = 1
    else:
        char_result["right"]["result"] = 1
        char_result["left"]["result"] = 0

    return char_result
Ejemplo n.º 4
0
from module.princess import unitproc
from module.image import proc
import cv2

report = cv2.imread("assets/b.png") # 讀取圖片
report = proc.preprocessing(report) # 中央視窗裁剪
report = proc.report_processing(report) # 傷害報告類型圖片處理
char_list = unitproc.process(report) # 角色頭像鎖定

for char in char_list:
    objUnit = unitproc.unit(char)
    objUnit.detect()
    result = objUnit.getResult()
    if result == False:
        print("找不到這角色")
    else:
        print(result)