def endSelection(self, widget): if not self.insertionThread.isRunning(): self.insertionThread.srcImage = self.source self.insertionThread.options = self.options self.insertionThread.destImage = Image.from_qimage(self._imageCopy) self.insertionThread.destImage.scene_description = self._scene_description self.insertionThread.bbox = (self._topLeftPoint.x(), self._topLeftPoint.y(), self._bottomRightPoint.x(), self._bottomRightPoint.y()) self.insertionThread.widget = widget self.insertionThread.start()
def save(self, path): path = os.path.abspath(path) parent = os.path.dirname(path) if not os.path.exists(parent): os.makedirs(parent) Image.from_qimage(self._image).save(path)
def update(self, filepath): self.setSourceImage(Image.from_filepath(filepath))
((207, 300, 40, 43), (250,410,111,104), (434, 402, 150, 150)), ((318, 403, 167, 160),), ((334, 414, 49, 43), (230, 370, 72, 85)), ((520, 1200, 450, 585),(1191,840,402,375),(798,843,99,100)), ((474, 489, 280, 243),(848,598,350,350)), ((1790,1058,450,570),)] foregrounds = ['bookcase','couch1','chair1','counter1','couch2'] bbs = zip(backgrounds, valid_obj_bboxes) for background, bboxes in bbs: print("Loading background %s" % background) # load background and scene description bgpath = "../bg/%s.jpg" % background bg = Image.from_any(bgpath) sd = estimate_scene_description(bg) bg.scene_description = sd for foreground in foregrounds: print("Processing %s" % foreground) for i, (endX, endY, sizeX, sizeY) in enumerate(bboxes): fgpath = "../fg/%s.jpg" % foreground fg = Image.from_any(fgpath) aspect = fg.shape[0] / float(fg.shape[1]) bbox = (endX - sizeX, int(endY - (aspect * sizeX)), endX, endY) print endX, endY, sizeX, sizeY, bbox magic_insert(fg, bg, bbox, generate_shadow=True).save('demo/%s_%s_%s_0comp.png' % (background, foreground, i)) magic_insert_shadow_only(fg, bg, bbox).save('demo/%s_%s_%s_1shadowsoft.png' % (background, foreground, i))