Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions BB_Overlapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import numpy as np
import pandas as pd

def reader(filename):
df = pd.read_csv(filename)
return df

def check_overlapping(obj1, rect1, obj2, rect2):
#case1:
my_str = []
if(rect1[0][0] >= rect2[0][0] and rect1[0][1] >= rect2[0][1] and rect1[1][0] >= rect2[1][0] and rect1[1][1] >= rect2[1][1]):
my_str.append(obj1 + ' partOf ' + obj2)
#case2:
if(rect1[1][0] >= rect2[0][1] and rect1[0][1] < rect2[0][0]):
my_str.append(obj1 + ' overlapWith ' + obj2)
#case3:
else:
my_str.append(obj1 + ' collocateWith ' + obj2)

return my_str

def detector(df):
num_rows = len(df.index)
str_value = []
for i in range(num_rows):
for j in range(i+1, num_rows):
obj1 = (df.iloc[i]["label"])
obj2 = (df.iloc[j]["label"])
top_left1 = (int(df.iloc[i]["Top_Left_x"]), int(df.iloc[i]["Top_Left_y"]))
bottom_right1 = (int(df.iloc[i]["Bottom_Right_x"]), int(df.iloc[i]["Bottom_Right_y"]))
top_left2 = (int(df.iloc[j]["Top_Left_x"]), int(df.iloc[j]["Top_Left_y"]))
bottom_right2 = (int(df.iloc[j]["Bottom_Right_x"]), int(df.iloc[j]["Bottom_Right_y"]))
rect1 = (top_left1, bottom_right1)
rect2 = (top_left2, bottom_right2)
#print(top_left1, bottom_right1)
#print(top_left2, bottom_right2)
str_value = check_overlapping(obj1, rect1, obj2, rect2)

return str_value



if __name__ == "__main__":
df = reader("~/Desktop/convertcsv.csv")
str_value_new= detector(df)
13 changes: 13 additions & 0 deletions Bounding_Box_csv.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
label,confidence,Top_Left_x,Top_Left_y,Bottom_Right_x,Bottom_Right_y
car,0.33,0,1084,84,1247
car,0.52,1251,1106,1412,1170
car,0.47,1497,1111,1648,1174
car,0.2,1684,1112,1802,1171
car,0.29,1855,1118,2004,1176
car,0.22,2096,1115,2172,1158
car,0.26,2266,1108,2361,1149
car,0.44,2417,1091,2542,1157
car,0.48,2629,1082,2745,1129
car,0.78,516,1037,1286,1444
stop sign,0.16,2561,978,2611,1045
pottedplant,0.77,1418,1146,2126,1683
Binary file added Image_42.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Image_42_output_from_YOLO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"label": "car", "confidence": 0.33, "topleft": {"x": 0, "y": 1084}, "bottomright": {"x": 84, "y": 1247}}, {"label": "car", "confidence": 0.52, "topleft": {"x": 1251, "y": 1106}, "bottomright": {"x": 1412, "y": 1170}}, {"label": "car", "confidence": 0.47, "topleft": {"x": 1497, "y": 1111}, "bottomright": {"x": 1648, "y": 1174}}, {"label": "car", "confidence": 0.2, "topleft": {"x": 1684, "y": 1112}, "bottomright": {"x": 1802, "y": 1171}}, {"label": "car", "confidence": 0.29, "topleft": {"x": 1855, "y": 1118}, "bottomright": {"x": 2004, "y": 1176}}, {"label": "car", "confidence": 0.22, "topleft": {"x": 2096, "y": 1115}, "bottomright": {"x": 2172, "y": 1158}}, {"label": "car", "confidence": 0.26, "topleft": {"x": 2266, "y": 1108}, "bottomright": {"x": 2361, "y": 1149}}, {"label": "car", "confidence": 0.44, "topleft": {"x": 2417, "y": 1091}, "bottomright": {"x": 2542, "y": 1157}}, {"label": "car", "confidence": 0.48, "topleft": {"x": 2629, "y": 1082}, "bottomright": {"x": 2745, "y": 1129}}, {"label": "car", "confidence": 0.78, "topleft": {"x": 516, "y": 1037}, "bottomright": {"x": 1286, "y": 1444}}, {"label": "stop sign", "confidence": 0.16, "topleft": {"x": 2561, "y": 978}, "bottomright": {"x": 2611, "y": 1045}}, {"label": "pottedplant", "confidence": 0.77, "topleft": {"x": 1418, "y": 1146}, "bottomright": {"x": 2126, "y": 1683}}]
66 changes: 66 additions & 0 deletions Spatial_Relation_Output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
['car collocateWith car']
['car collocateWith car']
['car collocateWith car']
['car collocateWith car']
['car collocateWith car']
['car collocateWith car']
['car collocateWith car']
['car collocateWith car']
['car collocateWith car']
['car collocateWith stop sign']
['car collocateWith pottedplant']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car collocateWith car']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car collocateWith car']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car collocateWith car']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car collocateWith car']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['car overlapWith car']
['car overlapWith car']
['car overlapWith car']
['car collocateWith car']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['car overlapWith car']
['car overlapWith car']
['car collocateWith car']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['car overlapWith car']
['car collocateWith car']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['car collocateWith car']
['car partOf stop sign', 'car overlapWith stop sign']
['car overlapWith pottedplant']
['car overlapWith stop sign']
['car overlapWith pottedplant']
['stop sign overlapWith pottedplant']
Loading