PaddleCV-SIG / PaddleLabel

飞桨智能标注,让标注快人一步
https://paddlecv-sig.github.io/PaddleLabel/
Apache License 2.0
236 stars 38 forks source link

【bug】paddlelabel标注导出加载出来的位置偏移 #204

Closed andyz168 closed 8 months ago

andyz168 commented 10 months ago

win10 分辨率1920*1080,图片用的样例图片也有问题

import matplotlib.pyplot as plt
from pycocotools.coco import COCO
from skimage import io

# 加载COCO数据集的标注文件
coco = COCO(f'D:\\img_sources\\new\\aa\\train.json')

# 获取所有图像的ID
image_ids = coco.getImgIds()

# 可视化每个图像的标注信息
for image_id in image_ids:
    # 获取图像的信息
    image_info = coco.loadImgs(image_id)[0]

    print(image_info['file_name'])
    # 加载图像
    image_path = f'D:\\img_sources\\new\\aa\\' + image_info['file_name']
    image = io.imread(image_path)

    # 获取图像的标注信息
    annotations_ids = coco.getAnnIds(imgIds=image_id)
    annotations = coco.loadAnns(annotations_ids)
    print("imgid----",image_id,"anids",annotations_ids,"annotations",annotations)

    # 可视化标注信息
    plt.imshow(image)
    coco.showAnns(annotations)
    plt.axis('off')
    plt.show()

使用这段代码加载出来的和paddlelabel标记的位置有偏移 image image

image

andyz168 commented 10 months ago
const getEvtParam = (e: Konva.KonvaEventObject<MouseEvent>) => {
    return {
      e: e,
      mouseX: (e.evt.offsetX - dragEndPos.x - canvasWidth / 2) / props.scale + imageWidth / 2,
      mouseY: (e.evt.offsetY - dragEndPos.y - canvasHeight / 2) / props.scale + imageHeight / 2,
      offsetX: -imageWidth / 2,
      offsetY: -imageHeight / 2,
      canvasRef: canvasRef,
      stageRef: stageRef,
      img: image,
    };
  };

看了代码,前端是用了一个偏移量,保存到数据库中的是鼠标点击的位置+偏移量。

andyz168 commented 10 months ago
        annotations = Annotation._get(project_id=project.project_id, many=True)
        for ann in annotations:
            if ann.type != "polygon":
                continue

            r = ann.result.split(",")
            r = [float(t) for t in r]
            width, height = (
                coco.imgs[ann.data_id]["width"],
                coco.imgs[ann.data_id]["height"],
            )
            width = int(width)
            height = int(height)
            for idx in range(0, len(r), 2):
                # r[idx] += width / 2
                # r[idx + 1] += height / 2
                r[idx] += height / 2
                r[idx + 1] += width / 2

bug已经修复,看注释掉的地方 文件地址 paddlelabel/task/instance_segmentation.py image

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.