KITTI-360 2D实例数据集中的实例注释



我试图在KITTI-360实例分割数据集中计算每个图像中的车辆实例。作为试验,我首先尝试在单个图像上做。但是当我运行代码时,我只得到一个实例值。这意味着车辆类的所有实例在图像中仅用一个值表示。我在下面附上了我用来找到这个的代码。

我想知道这是为什么?或者如果我在我的代码中做错了什么?

""该文件用于验证像素值

的实例确认。

"""
This file is for the verification of the instance confirmation for the pixel values 
"""
#Imports 
import os
import numpy as np
import cv2
import json
# Import image from the file location
CWD = os.getcwd()
print(CWD)
instance_folder = os.path.join(CWD, 'image_my_data', "instance")
print(instance_folder)
instance_image_path =  os.path.join(instance_folder, "0000004402.png")
print(instance_image_path)
instance_image_array = cv2.imread(instance_image_path)
# print the size of the image for reference
print(instance_image_array.shape)
# Following are pixel values are measured and wanted to see what are the instance values at these pixel locations.
# Pixel location as tuples
pixel_location_1 = (210, 815)
pixel_location_2 = (200, 715)

# print the pixel location, for the above values
print('pixel values at (210, 815)', instance_image_array[pixel_location_1[0], pixel_location_1[1]])
print('pixel values at (200, 715)', instance_image_array[pixel_location_2[0], pixel_location_2[1]])

注意:我在上面选择的像素值是通过在paint中打开图像并记下x和y中像素坐标的任何位置,我可以在物理上看到类的两个独立实例存在。

希望有人能帮我解决这个问题。

我找到了自己问题的答案。在映像中查找实例的最简单方法是使用cv2读取映像。cv2.IMREAD_ANYDEPTH imread(图片)

这样做的原因是,KITTI-360图像是8位图像。因此,我们可以使用常规imread将图像读取为RGB图像,但这不会给出正确的实例id。当使用上述方法时,将图像转换为单个通道读取,并且该通道将包含每个对象的实例id。

我希望这能帮助到别人。

最新更新