def setup_i3(self): p = self.__setup_via_pairs_layers() il1 = ImageLayer("foo", bytes(b"12344")) il2 = ImageLayer("bar", bytes(b"12345")) il3 = ImageLayer("quux", bytes(b"12346")) p.imagery.add_imagelayer(il1) p.imagery.add_imagelayer(il2) p.imagery.add_imagelayer(il3) p.stackup.layers[0].imagelayers = [il1, il2] p.stackup.layers[1].imagelayers = [il3] return p
def __action(self): # Build a filter string known_image_types = [('Windows Bitmaps', ['*.bmp', '*.dib']), ('JPEG files', ['*.jpg', '*.jpeg']), ('JPEG2K files', ['*.jp2']), ('PNG Files', ['*.png']), ('Portable Image Format files', ['*.pbm', '*.pgm', '*.ppm']), ('TIFF files', ['*.tiff', '*.tif']) ] known_image_types.insert(0, ('All Images', list(itertools.chain.from_iterable(i[1] for i in known_image_types)))) filter_string = ";;".join("%s (%s)" % (i[0], " ".join(i[1])) for i in known_image_types) fname, _ = QtGui.QFileDialog.getOpenFileName(self.window, "Open Image", filter=filter_string) if not fname: return il = ImageLayer.fromFile(self.window.project, fname) # Allow the user to align the image dlg = LayerAlignmentDialog(self.window, self.window.project, il) res = dlg.exec_() if res == QtGui.QDialog.Accepted: self.window.project.imagery.add_imagelayer(il)
def __action(self): # Build a filter string known_image_types = [('Windows Bitmaps', ['*.bmp', '*.dib']), ('JPEG files', ['*.jpg', '*.jpeg']), ('JPEG2K files', ['*.jp2']), ('PNG Files', ['*.png']), ('Portable Image Format files', ['*.pbm', '*.pgm', '*.ppm']), ('TIFF files', ['*.tiff', '*.tif'])] known_image_types.insert( 0, ('All Images', list( itertools.chain.from_iterable(i[1] for i in known_image_types)))) filter_string = ";;".join("%s (%s)" % (i[0], " ".join(i[1])) for i in known_image_types) fname, _ = QtGui.QFileDialog.getOpenFileName(self.window, "Open Image", filter=filter_string) if not fname: return il = ImageLayer.fromFile(self.window.project, fname) # Allow the user to align the image dlg = LayerAlignmentDialog(self.window, self.window.project, il) res = dlg.exec_() if res == QtGui.QDialog.Accepted: self.window.project.imagery.add_imagelayer(il)
def deserialize(self, msg): # Keypoints may be used by the imagelayers during deserialize # Deserialize first to avoid a finalizer for i in msg.keypoints: self.__keypoints.append(KeyPoint.deserialize(self.__project, i)) for i in msg.imagelayers: self.__imagelayers.append(ImageLayer.deserialize(self.__project, i))
def deserialize(self, msg: ser.Imagery) -> None: # Keypoints may be used by the imagelayers during deserialize # Deserialize first to avoid a finalizer for i in msg.keypoints: self.__keypoints.append(KeyPoint.deserialize(self.__project, i)) for i in msg.imagelayers: self.__imagelayers.append(ImageLayer.deserialize(self.__project, i))
def add_imagelayer(self, imagelayer: ImageLayer) -> None: print(imagelayer._project, self) assert imagelayer._project is None or imagelayer._project is self.__project imagelayer._project = self.__project if imagelayer.alignment is not None: imagelayer.alignment._project = self.__project self.__imagelayers.append(imagelayer)
def addImage(self): fname, _ = QtGui.QFileDialog.getOpenFileName(self, "Open Image") if not fname: return il = ImageLayer.fromFile(self.project, fname) # Allow the user to align the image dlg = LayerAlignmentDialog(self, self.project, il) res = dlg.exec_() if res == QtGui.QDialog.Accepted: self.project.imagery.add_imagelayer(il)