def readImage(self, filename, sbimage): image = QImage() if (image.load(filename.getString())): # Keep in 8-bits mode if that was what we read if (image.depth() == 8 and image.isGrayscale()): c = 1 else: # FIXME: consider if we should detect allGrayscale() and alpha (c = 2) c = 3 if image.hasAlphaChannel(): c = 4 image.convertToFormat(QImage.Format_ARGB32) else: image.convertToFormat(QImage.Format_RGB32) # FIXME 20080508 jkg: implement when pivy is ready #sbimage.setValue(SbVec2s(image.width(), image.height()), c, None) return True return False
def saveYoloFormat(self, filename, shapes, imagePath, imageData, classList, lineColor=None, fillColor=None, databaseSrc=None): imgFolderPath = os.path.dirname(imagePath) imgFolderName = os.path.split(imgFolderPath)[-1] imgFileName = os.path.basename(imagePath) #imgFileNameWithoutExt = os.path.splitext(imgFileName)[0] # Read from file path because self.imageData might be empty if saving to # Pascal format image = QImage() image.load(imagePath) imageShape = [ image.height(), image.width(), 1 if image.isGrayscale() else 3 ] writer = YOLOWriter(imgFolderName, imgFileName, imageShape, localImgPath=imagePath) writer.verified = self.verified for shape in shapes: points = shape['points'] label = shape['label'] # Add Chris difficult = int(shape['difficult']) bndbox = LabelFile.convertPoints2BndBox(points) writer.addBndBox(bndbox[0], bndbox[1], bndbox[2], bndbox[3], label, difficult) writer.save(targetFile=filename, classList=classList) return