Skip to content

为什么在处理DroneVehicle数据集时,只删去了上下左右4个像素的白边? #1

@Zmj5812

Description

@Zmj5812

您好,首先感谢您的工作,这给了我很大的启发。现在我也在考虑这个方向的相关工作。在处理DroneVehicle数据集时看到了一处我不理解的地方,在/workspace/DPAL/dataset/preprocess_DroneVehicle.py文件中,您处理DroneVehicle这个数据集时仅仅只删去了上下左右4个像素点的白边,但是DroneVehicle数据集上下左右共有100个像素点的白边,为什么不全部删去呢?源代码如下:
def process_images_and_annotations(image_folder, new_image_folder, json_path, new_json_path):
# 处理图像,拆去上下左右4%的白边
for filename in os.listdir(image_folder):
if filename.endswith(('.jpg', '.png', '.jpeg')):
image_path = os.path.join(image_folder, filename)
img = Image.open(image_path)
new_img = img.crop((4, 4, img.width - 4, img.height - 4))
new_image_path = os.path.join(new_image_folder, filename)
new_img.save(new_image_path)

# 处理标注
with open(json_path, 'r') as f:
    data = json.load(f)

for annotation in data['annotations']:
    bbox = annotation['bbox']
    x, y, w, h = bbox


    new_x = x - 4 if x > 4 else 0
    new_y = y - 4 if y > 4 else 0

    new_w = w if new_x + w < 832 else 832 - new_x
    new_h = h if new_y + h < 704 else 704 - new_y
    annotation['bbox'] = [new_x, new_y, new_w, new_h]

with open(new_json_path, 'w') as f:
    json.dump(data, f)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions