From f19e8aeb6decae04681b66b4928c4ed253592244 Mon Sep 17 00:00:00 2001 From: apicis Date: Sat, 22 Oct 2022 13:04:46 +0100 Subject: [PATCH 1/4] Update perception_pipeline.py Added flag to visualise LoDE on the RGB views. Suggestion: set true when passing also the videos and calibration paths since it slows the computation --- perception_pipeline.py | 1 + 1 file changed, 1 insertion(+) diff --git a/perception_pipeline.py b/perception_pipeline.py index 7ba9580..cb961ff 100644 --- a/perception_pipeline.py +++ b/perception_pipeline.py @@ -137,6 +137,7 @@ def PublicTestingDataParser(args): parser.add_argument('--use_LoDE', type=int, choices=[0,1], default=0) parser.add_argument('--LoDE_hstep', type=float, default=0.001) parser.add_argument('--LoDE_rstep', type=float, default=18.0) + parser.add_argument('--visualise_LoDE', type=bool, default=False) parser.add_argument('--record', type=int, choices=[0,1], default=0) parser.add_argument('--max_num_frames', type=int, default=-1) # Path to videos From 15d24fdb42aae17860e30e173604501a8c685a01 Mon Sep 17 00:00:00 2001 From: apicis Date: Sat, 22 Oct 2022 13:07:14 +0100 Subject: [PATCH 2/4] Update container.py Added property visualise_LoDE to the class container. Updated the code of ShapeFitting method to visualise the LoDE estimation and the object mask in the RGB views --- libs/perception/container.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/libs/perception/container.py b/libs/perception/container.py index 3f31447..5fe69f6 100755 --- a/libs/perception/container.py +++ b/libs/perception/container.py @@ -219,6 +219,7 @@ def __init__(self, args, ncams): self.zt1 = None self.zt = None + self.visualise_LoDE = args.visualise_LoDE @@ -301,7 +302,7 @@ def computeAnglesRad(self): self.anglesrad = anglesrad - def ShapeFitting(self, _c1, _c2, _objmask1, _objmask2, h_step, r_step): + def ShapeFitting(self, _c1, _c2, _objmask1, _objmask2, h_step, r_step, rgb1, rgb2): c1 = copy.deepcopy(_c1) c2 = copy.deepcopy(_c2) @@ -382,7 +383,19 @@ def ShapeFitting(self, _c1, _c2, _objmask1, _objmask2, h_step, r_step): if (np.count_nonzero(areIn_c1) == areIn_c1.shape[0]) and (np.count_nonzero(areIn_c2) == areIn_c2.shape[0]): converged_circ = True - break + if self.visualise_LoDE: + for p, isIn in zip(p2d_c1, areIn_c1): + if isIn: + cv2.circle(rgb1, (int(p[0]), int(p[1])), 2, (255, 0, 0), -1) + else: + cv2.circle(rgb1, (int(p[0]), int(p[1])), 2, (0, 0, 255), -1) + + for p, isIn in zip(p2d_c2, areIn_c2): + if isIn: + cv2.circle(rgb2, (int(p[0]), int(p[1])), 2, (255, 0, 0), -1) + else: + cv2.circle(rgb2, (int(p[0]), int(p[1])), 2, (0, 0, 255), -1) + break if rad==minDiameter/2: break @@ -400,6 +413,12 @@ def ShapeFitting(self, _c1, _c2, _objmask1, _objmask2, h_step, r_step): self.estRadius = convRadius[round(0.1*len(convRadius)):round(0.9*len(convRadius))] self.estHeights = convHeights[round(0.1*len(convHeights)):round(0.9*len(convHeights))] + if self.visualise_LoDE: + dim = (rgb1.shape[1] // 2, rgb2.shape[0] // 2) + cv2.imshow("LoDE [blue] and object mask [green]", np.hstack([cv2.resize(rgb1, dim, interpolation=cv2.INTER_AREA), + cv2.resize(rgb2, dim, interpolation=cv2.INTER_AREA)])) + cv2.waitKey(10) + # Localisation and dimension estimation via shape reconstruction in 3D # Output: @@ -462,7 +481,7 @@ def LoDE(self, rgb1, rgb2, c1, c2, instances1, instances2, h_step, r_step): objmask2 = np.uint8(255.* (instances2['masks'][j] >= 0.5)) # print('ShapeFitting') - self.ShapeFitting(c1, c2, objmask1, objmask2, h_step, r_step) + self.ShapeFitting(c1, c2, objmask1, objmask2, h_step, r_step, rgb1, rgb2) # print('ComputeDimensions') # Compute container dimensions From d53b1a33a75a446c6c6e8d414f06fd22ce80149e Mon Sep 17 00:00:00 2001 From: apicis Date: Mon, 24 Oct 2022 12:27:59 +0100 Subject: [PATCH 3/4] Update perception_pipeline.py --- perception_pipeline.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perception_pipeline.py b/perception_pipeline.py index cb961ff..78d3ce1 100644 --- a/perception_pipeline.py +++ b/perception_pipeline.py @@ -4,11 +4,12 @@ # Author: Ricardo Sanchez Matilla # Author: Yik Lung Pang # Author: Alessio Xompero +# Author: Tommaso Apicella # Email: corsmal-benchmark@qmul.ac.uk # # # Created Date: 2020/02/13 -# Modified Date: 2020/10/05 +# Modified Date: 2022/10/24 # # Centre for Intelligent Sensing, Queen Mary University of London, UK # From 2e7799408b2a255acffa8423805228e789ace9a7 Mon Sep 17 00:00:00 2001 From: apicis Date: Mon, 24 Oct 2022 20:58:07 +0100 Subject: [PATCH 4/4] Update container.py --- libs/perception/container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/perception/container.py b/libs/perception/container.py index 5fe69f6..f9bf2c4 100755 --- a/libs/perception/container.py +++ b/libs/perception/container.py @@ -4,7 +4,7 @@ # Authors: # - Yik Lung Pang: y.l.pang@qmul.ac.uk # - Alessio Xompero: a.xompero@qmul.ac.uk -# +# - Tommaso Apicella: t.apicella@qmul.ac.uk # MIT License # Copyright (c) 2021 CORSMAL