Ejemplo n.º 1
0
# -*- coding: utf-8  -*-
# -*- author: jokker -*-

import os
from JoTools.utils.FileOperationUtil import FileOperationUtil
from JoTools.txkjRes.deteRes import DeteRes

xml_dir = r"C:\Users\14271\Desktop\连接件训练\xml_angle"
save_dir = r"C:\Users\14271\Desktop\连接件训练\xml"
img_dir = r"E:\连接件训练数据集"

for each_xml_path in FileOperationUtil.re_all_file(xml_dir,
                                                   endswitch=['.xml']):
    a = DeteRes(xml_path=each_xml_path)
    a.img_path = os.path.join(img_dir,
                              os.path.split(each_xml_path)[1][:-4] + '.jpg')
    a.angle_obj_to_obj()
    # a.save_to_xml(os.path.join(save_dir, os.path.split(each_xml_path)[1]))
    a.draw_dete_res(
        os.path.join(r"C:\Users\14271\Desktop\连接件训练\img",
                     os.path.split(each_xml_path)[1][:-4] + '.jpg'))
Ejemplo n.º 2
0
json_dir = r"C:\data\004_绝缘子污秽\val\json"

a = SegmentJson()
dete_res = DeteRes()

for each_json_path in list(
        FileOperationUtil.re_all_file(json_dir, endswitch=['.json']))[20:]:

    print(each_json_path)

    a.parse_json_info(each_json_path, parse_img=True, parse_mask=True)

    dete_res.img = Image.fromarray(a.image_data)

    for each_obj in a.shapes:
        print(each_obj.box)
        box = each_obj.box
        dete_res.add_obj(box[0], box[1], box[2], box[3], tag=each_obj.label)

    b = Image.fromarray(a.mask.astype(np.uint8) * 100)
    b.save(r"C:\Users\14271\Desktop\del\112233.png")

    dete_res.draw_dete_res(r"C:\Users\14271\Desktop\del\1100.png")

    # a.save_mask(r"C:\Users\14271\Desktop\del\del.npy")

    break

a.print_as_fzc_format()
Ejemplo n.º 3
0
        loc = res['result']['face_list'][i]['location']
        x1, y1 = loc['left'], loc['top']
        width, height = loc['width'], loc['height']
        x2, y2 = x1 + width, y1 + height
        face_info.append([int(x1), int(y1), int(x2), int(y2)])

    return face_info


# OperateDeteRes.crop_imgs(img_dir, xml_dir=img_dir, save_dir=save_dir)

# todo 测试正脸的图片

for img_path in FileOperationUtil.re_all_file(
        img_dir, lambda x: str(x).endswith(('.JPG', '.jpg'))):
    dete_res = DeteRes(assign_img_path=img_path)
    res = dete_face(img_path)
    print(res)
    for index, each_res in enumerate(res):
        x1, y1, x2, y2 = each_res
        dete_res.add_obj(x1=x1,
                         y1=y1,
                         x2=x2,
                         y2=y2,
                         tag='face',
                         assign_id=index)
    save_path = os.path.join(save_dir, os.path.split(img_path)[1])
    dete_res.draw_dete_res(save_path)

    time.sleep(3)
# -*- coding: utf-8  -*-
# -*- author: jokker -*-

import time
from JoTools.txkjRes.deteRes import DeteRes

img_path = r"C:\Users\14271\Desktop\del\test.jpg"
xml_path = r"C:\Users\14271\Desktop\del\test.xml"

a = DeteRes(xml_path)

a.img_path = img_path

a.draw_dete_res(r"C:\Users\14271\Desktop\del\draw_res_a.jpg")

# # b = a.deep_copy()
#
# c = DeteRes(json_dict=a.save_to_json())
#
# res = c.deep_copy()
#
# res.print_as_fzc_format()
# print('-'*50)
# a.print_as_fzc_format()
#
# print(a.img.width)
# print(a.img.height)
#
# print(res.img.width)
# print(res.img.height)
#