Hi,
I am looking at this forum
I did my own segmentation, and when I tried to print out the number of class, I got 21, but I only have 4 classes including background… not sure why.
P.S.: My classes.txt only has four lines.
P.S.: I follow this link for custom-segmentation (maybe the problem is from here…?)
num_classes = net.GetNumClasses()
print("######################")
print("grid size: {:d}x{:d}".format(grid_width,grid_height))
print("num classes: {:d}".format(num_classes))
print("######################")
class_mask = buffers.mask
mask_array = jetson.utils.cudaToNumpy(class_mask)
# compute the number of times each class occurs in the mask
class_histogram, _ = np.histogram(mask_array, num_classes)
print('grid size: {:d}x{:d}'.format(grid_width, grid_height))
print('num classes: {:d}'.format(num_classes))
print('-----------------------------------------')
print(' ID class name count %')
print('-----------------------------------------')
for n in range(num_classes):
percentage = float(class_histogram[n]) / float(grid_width * grid_height)
print(' {:>2d} {:<18s} {:>3d} {:f}'.format(n, str(net.GetClassDesc(n)),class_histogram[n], percentage))
######################
grid size: 10x10
num classes: 21
-----------------------------------------
ID class name count %
-----------------------------------------
0 background 651332 6513.320000
1 label1 1942 19.420000
2 label2 1765 17.650000
3 label3 1695 16.950000
4 None 1598 15.980000
5 None 1530 15.300000
6 None 1514 15.140000
7 None 1493 14.930000
8 None 1429 14.290000
9 None 1390 13.900000
10 None 1372 13.720000
11 None 1356 13.560000
12 None 1347 13.470000
13 None 1335 13.350000
14 None 1347 13.470000
15 None 1316 13.160000
16 None 1328 13.280000
17 None 1322 13.220000
18 None 1357 13.570000
19 None 1388 13.880000
20 None 12044 120.440000
And I would like to get the center point of each segment, top, bottom, far left and far right points. Is there any easy way to do it? If not, I may need to use the opencv contour for each segment…Thx