From 816ba0804ccb061017a8c4580d86bc248ba0b3e7 Mon Sep 17 00:00:00 2001
From: Mahmoud Ahmed Ali <mahmoudali2929@gmail.com>
Date: Tue, 14 Feb 2023 17:56:40 +0000
Subject: [PATCH] Add 3d bbox file

---
 bbox_3d.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 bbox_3d.py

diff --git a/bbox_3d.py b/bbox_3d.py
new file mode 100644
index 0000000..ce904d1
--- /dev/null
+++ b/bbox_3d.py
@@ -0,0 +1,28 @@
+import numpy as np
+
+
+def get_bbox(ext):
+    pcd_bbox = np.array([
+        [ext[0], ext[1], ext[2]],
+        [- ext[0], ext[1], ext[2]],
+        [ext[0], - ext[1], ext[2]],
+        [- ext[0], - ext[1], ext[2]],
+        [ext[0], ext[1], - ext[2]],
+        [- ext[0], ext[1], - ext[2]],
+        [ext[0], - ext[1], - ext[2]],
+        [- ext[0], - ext[1], - ext[2]]
+    ])
+
+    return pcd_bbox
+
+
+def generate_3d_bbox(data_name):
+    objs = {"Banana": [0.029497003182768822, 0.15110498666763306, 0.060593008995056152],
+            "Orange": [0.073495000600814819, 0.075856998562812805, 0.074581995606422424],
+            "Pear": [0.066010989248752594, 0.12873399630188942, 0.06739199161529541]}
+    for key, val in objs.items():
+        ext = [x / 2 for x in val]
+        bbox = get_bbox(ext)
+        np.savetxt(f'{data_name}/Bbox/{key}_bbox_3d.txt', bbox)
+        # print(ext)
+
-- 
GitLab