Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andyz168 opened this issue Oct 21, 2023 · 3 comments
Closed

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

andyz168 opened this issue Oct 21, 2023 · 3 comments

Comments

@andyz168
Copy link

andyz168 commented Oct 21, 2023

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 andyz168 changed the title paddlelabel标注导出加载出来的位置偏移 【bug】paddlelabel标注导出加载出来的位置偏移 Oct 21, 2023
@andyz168
Copy link
Author

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
Copy link
Author

        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

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant