From 39952bd1af4b4f880794074beaee44cb9f1cd11b Mon Sep 17 00:00:00 2001 From: Niklas Hahn Date: Tue, 6 Sep 2022 11:01:14 +0200 Subject: [PATCH] Select images by index --- labelImg.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/labelImg.py b/labelImg.py index efd8a2976..d767796f1 100755 --- a/labelImg.py +++ b/labelImg.py @@ -169,10 +169,17 @@ def __init__(self, default_filename=None, default_prefdef_class_file=None, defau self.dock.setObjectName(get_str('labels')) self.dock.setWidget(label_list_container) + # Text field to find images by index + self.idx_text_box = QLineEdit() + self.jump_button = QPushButton('Show image', self) + self.jump_button.clicked.connect(self.jump_on_click) + self.file_list_widget = QListWidget() self.file_list_widget.itemDoubleClicked.connect(self.file_item_double_clicked) file_list_layout = QVBoxLayout() file_list_layout.setContentsMargins(0, 0, 0, 0) + file_list_layout.addWidget(self.idx_text_box) + file_list_layout.addWidget(self.jump_button) file_list_layout.addWidget(self.file_list_widget) file_list_container = QWidget() file_list_container.setLayout(file_list_layout) @@ -769,6 +776,17 @@ def file_item_double_clicked(self, item=None): if filename: self.load_file(filename) + # Takes index from text box and opens corresponding file + def jump_on_click(self): + self.cur_img_idx = int(self.idx_text_box.text()) - 1 + if self.cur_img_idx > self.img_count: + return + filename = self.m_img_list[self.cur_img_idx] + if filename: + self.load_file(filename) + + self.idx_text_box.setText("") + # Add chris def button_state(self, item=None): """ Function to handle difficult examples