def args_for_test(self): image_area = ImageArea(None, None, generate_block(1, 1)) image_area_h = ImageArea(generate_line(1), None, generate_block(1, 1)) image_area_p = ImageArea(None, generate_block(1, 1), generate_block(1, 1)) image_area_hp = ImageArea(generate_line(2), generate_block(1, 1), generate_block(1, 1)) tail = Tail(None, None) return [ VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1), image_area, None, tail), VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1, EOL=0), image_area, None, tail), VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1, EOL=1), image_area, gen_eol_labels(1, LBLSIZE=1), tail), VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, NBB=1), image_area_p, None, tail), VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, EOL=0, NBB=1), image_area_p, None, tail), VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, EOL=1, NBB=1), image_area_p, gen_eol_labels(2, LBLSIZE=2), tail), VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1, NLB=1), image_area_h, None, tail), VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1, EOL=0, NLB=1), image_area_h, None, tail), VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1, EOL=1, NLB=1), image_area_h, gen_eol_labels(1, LBLSIZE=1), tail), VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, NBB=1, NLB=1), image_area_hp, None, tail), VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, EOL=0, NBB=1, NLB=1), image_area_hp, None, tail), VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, EOL=1, NBB=1, NLB=1), image_area_hp, gen_eol_labels(2, LBLSIZE=2), tail), ]
def back_migrate_image_area(old_binary_header_len, pds4_tail, pds4_image_area): # type: (int, Tail, ImageArea) -> ImageArea """ Move any binary prefixes from the tail back into the image area. Remove any added padding from the binary header. """ if pds4_image_area.binary_header is None: pds3_binary_header = None else: pds3_binary_header = \ pds4_image_area.binary_header[:old_binary_header_len] return ImageArea(pds3_binary_header, pds4_tail.binary_prefixes_at_tail, pds4_image_area.binary_image_lines)
def migrate_image_area(new_recsize, pds3_image_area): # type: (int, ImageArea) -> ImageArea """ Drop the binary labels. """ if pds3_image_area.binary_header is None: pds4_binary_header = None else: pds3_len = len(pds3_image_area.binary_header) pds4_len = round_to_multiple_of(pds3_len, new_recsize) excess = pds4_len - pds3_len padding = excess * '\0' pds4_binary_header = pds3_image_area.binary_header + padding return ImageArea(pds4_binary_header, None, pds3_image_area.binary_image_lines)
def __init__(self, parent=None): self.image_dir = '' self.image_map_list = [] self.image_map = [] self.image_index = 0 self.image_name = '' self.classes_list = CLASSES self.roi_list_one = [] # 保存一张图片的roi self.roi_list_many = [] # 保存多张图片的roi self.low = 0 self.high = 1024 * 1024 super(Pic_Menu, self).__init__(parent) self.mainLayout = QtWidgets.QVBoxLayout() self.containerLayout = QtWidgets.QVBoxLayout() # 垂直图片展示布局管理器 self.filtrate_area = QtWidgets.QHBoxLayout() # 上部类别布局管理器 self.image_area_layout = QtWidgets.QHBoxLayout() # 中间图片展示布局管理包括文件列表和展示 self.photo_change_area = QtWidgets.QHBoxLayout() # 底部图片切换布局管理 self.mainSpliter = QtWidgets.QSplitter(Qt.Horizontal) self.dirModel = QtWidgets.QDirModel(self) self.dirModel.setFilter(QDir.Dirs | QDir.NoDotAndDotDot) # 文件夹列表view self.dirTreeView = QtWidgets.QTreeView() # 绑定model self.dirTreeView.setModel(self.dirModel) # self.dirTreeView.setRootIndex(self.dirModel.index(dir)) # 设置文件夹路径 # self.dirTreeView.expand(self.dirModel.index(dir)) #展开当前文件夹 # self.dirTreeView.scrollTo(self.dirModel.index(dir)) #视图滚动 self.dirTreeView.hideColumn(1) # 控制显示列数据 self.dirTreeView.hideColumn(2) self.dirTreeView.hideColumn(3) # DirTree事件响应 self.dirTreeView.selectionModel().selectionChanged.connect( self.dirTreeClicked) self.mainSpliter.addWidget(self.dirTreeView) self.imageContainer = QtWidgets.QFrame(self.mainSpliter) self.imageContainer.setMinimumWidth(int(self.geometry().width() * 0.6)) # 类别筛选框 classLabel = QtWidgets.QLabel("类别选择") classLabel.setFixedWidth(60) self.filtrate_area.addWidget(classLabel) self.check_box = ComboCheckBox(CLASSES) self.check_box.setFixedWidth(350) self.filtrate_area.addWidget(self.check_box) # bounding-box筛选框 self.box_input = BoxInput() self.box_input.setFixedWidth(200) self.filtrate_area.addWidget(self.box_input) self.confirm_button = QtWidgets.QPushButton('确定') self.confirm_button.setFixedWidth(150) self.confirm_button.clicked.connect(self.confim_choice) self.filtrate_area.addWidget(self.confirm_button) self.containerLayout.addLayout(self.filtrate_area) # 图片显示区域 self.image_list = ImageList() self.image_list.image_name.connect(self.get_name) # self.image_list.connect(self, QtCore.SIGNAL("transfer_child"), self.w2.receive) self.image_area_layout.addWidget(self.image_list) # self.item_area = QtWidgets.QWidget() # self.item_area.setFixedSize(800, 800) # # self.image_area = QtWidgets.QLabel(self.item_area) # self.image_area.setFixedSize(800, 800) # self.image_area.setStyleSheet("background-color: rgb(255, 255, 255); border:1px solid black") # # self.image_area_layout.addWidget(self.item_area) self.image_area = ImageArea() self.image_area_layout.addWidget(self.image_area) self.containerLayout.addLayout(self.image_area_layout) # 图片切换按钮 self.pre_photo_button = QtWidgets.QPushButton('上一张') self.next_photo_button = QtWidgets.QPushButton('下一张') self.pre_photo_button.setFixedWidth(150) self.next_photo_button.setFixedWidth(150) self.pre_photo_button.clicked.connect(self.pre_photo) self.next_photo_button.clicked.connect(self.next_photo) self.photo_change_area.addWidget(self.pre_photo_button) self.photo_change_area.addWidget(self.next_photo_button) self.containerLayout.addLayout(self.photo_change_area) self.imageContainer.setLayout(self.containerLayout) self.mainSpliter.addWidget(self.imageContainer) self.mainLayout.addWidget(self.mainSpliter)
def test__init__(self): image_area = ImageArea(None, None, generate_block(1, 1)) image_area_h = ImageArea(generate_line(1), None, generate_block(1, 1)) image_area_p = ImageArea(None, generate_block(1, 1), generate_block(1, 1)) image_area_hp = ImageArea(generate_line(2), generate_block(1, 1), generate_block(1, 1)) tail = Tail(None, None) # Verify that bad inputs raise an exception. # missing sections: with self.assertRaises(Exception): VicarFile(None, image_area, gen_labels({}), tail) with self.assertRaises(Exception): VicarFile(gen_labels(1, RECSIZE=1, LBLSIZE=1, EOL=1), None, gen_labels(1, ), tail) with self.assertRaises(Exception): VicarFile(gen_labels(1, RECSIZE=1, LBLSIZE=1, EOL=1), image_area, gen_labels(1), None) # inconsistent keywords: with self.assertRaises(Exception): # missing RECSIZE VicarFile(gen_labels(1), image_area, gen_labels(1), tail) with self.assertRaises(Exception): # missing EOL VicarFile(gen_labels(1, RECSIZE=1, LBLSIZE=1), image_area, gen_labels(1), tail) with self.assertRaises(Exception): # zero EOL VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1, EOL=0), image_area, gen_labels(1), tail) with self.assertRaises(Exception): # nonzero NBB but no binary prefixes VicarFile(gen_labels(1, RECSIZE=1, LBLSIZE=1, NBB=1), image_area, None, tail) with self.assertRaises(Exception): # zero NBB but with binary prefixes VicarFile(gen_labels(2, RECSIZE=2, LBLSIZE=2, NBB=0), image_area_p, None, tail) with self.assertRaises(Exception): # nonzero NLB but no binary header VicarFile(gen_labels(1, RECSIZE=1, LBLSIZE=1, NLB=1), image_area, None, tail) with self.assertRaises(Exception): # zero NLB but with binary header VicarFile(gen_labels(1, RECSIZE=1, LBLSIZE=1, NLB=0), image_area_h, None, tail) with self.assertRaises(Exception): # RECSIZE of 1 but ImageArea says 2 VicarFile(gen_labels(1, RECSIZE=1, LBLSIZE=1, NLB=0), image_area_p, None, tail) # two binary_prefixes with self.assertRaises(Exception): VicarFile(gen_labels(2, RECSIZE=2, LBLSIZE=2, NBB=1), image_area_p, None, Tail(generate_block(2, 2), None)) # TODO Create a case with both binary prefixes and a # MigrationTask. # verify that these do not raise VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1), image_area, None, tail) VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, NBB=1), image_area_p, None, tail) VicarFile(gen_labels(RECSIZE=1, LBLSIZE=1, NLB=1), image_area_h, None, tail) VicarFile(gen_labels(RECSIZE=2, LBLSIZE=2, NBB=1, NLB=1), image_area_hp, None, tail)