From 397be5c51b206768e9da8579db29b017ce0016e7 Mon Sep 17 00:00:00 2001 From: Till Raab <till.raab@uni-tuebingen.de> Date: Wed, 8 Nov 2023 16:04:04 +0100 Subject: [PATCH] bbox correcter --- correct_bboxes.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/correct_bboxes.py b/correct_bboxes.py index ae89da3..f660cde 100644 --- a/correct_bboxes.py +++ b/correct_bboxes.py @@ -43,24 +43,34 @@ class Bbox_correct_UI(QMainWindow): self.gridLayout.addWidget(self.win, 0, 0) self.plot_handels[0].getViewBox().invertY(True) + self.plot_handels[0].getViewBox().setMouseEnabled(x=False, y=False) img = Image.open(img_path) img_gray = ImageOps.grayscale(img) img_array = np.array(img_gray).T - labels = np.loadtxt(label_path, delimiter=' ') + self.labels = np.loadtxt(label_path, delimiter=' ') self.plot_handels[0].setImage(np.array(img_array)) - for l in labels: + self.ROIs = [] + for enu, l in enumerate(self.labels): x_center, y_center, width, height = l[1:] * img_array.shape[1] x0, y0, = x_center-width/2, y_center-height/2 - ROI = pg.RectROI((x0, y0), size=(width, height)) + ROI = pg.RectROI((x0, y0), size=(width, height), removable=True) + # ROI.sigRemoveRequested.connect(lambda: ) + self.ROIs.append(ROI) self.plot_widgets[0].addItem(ROI) + self.plot_widgets[0].setYRange(0, img_array.shape[0], padding=0) self.plot_widgets[0].setXRange(0, img_array.shape[1], padding=0) + # def kill_me(self, ROI): + # print('yay') + # print(ROI) + # self.win.removeItem(ROI) + def main_UI(): app = QApplication(sys.argv) # create application img_path = sys.argv[1]