Instance annotations in KITTI-360 2D instacne datasets

68 views Asked by At

I am trying to count the instance of the vehicle in each image in KITTI-360 instance segmented dataset. For a trial, I first tried to do it on the single image. But I am getting only one instance value when I run my code. Which means that all the instances of the vehicle class are denoted by only one value in the image. I have attached the code that I used for finding this below.

I want to know why this is? or if I am doing something wrong in my code?

""" This file is for the verification of the instance confirmation for the pixel values

"""
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]])


  

Note: the values of the pixels that I have taken above I choose by opening the image in paint and noting down the pixel coordinates in x and y in any locations where I can physically see that the two separate instances of the class are present.

Hope someone is able to help me with this.

1

There are 1 answers

0
programmer_04_03 On

I found the answer to my own question. The easiest way to find the instance in an image is to read the image using the cv2.imread(image, cv2.IMREAD_ANYDEPTH)

The reason for doing this is, the KITTI-360 images are 8 bit images. So, we can use the regular imread for reading the image as a RGB image but that will not give the correct instance ids. When using the method above will convert the image into a single channel read and that single channel will contain the instance ids of each object.

I hope this helps someone else.