def __screenshot(self, view=None): """Insert a screenshot of the given view panel into the notebook. If ``view`` is not specified, the first view is assumed. """ if view is None: view = self.__frame.viewPanels[0] with tempdir.tempdir(): screenshot.screenshot(view, 'screenshot.png') return display.Image('screenshot.png')
def do_test(): from fsleyes.actions.screenshot import screenshot screenshot(ortho, 'file.png') benchmark = op.join(datadir, 'test_screenshot_ortho.png') screenshot = imread('file.png') benchmark = imread(benchmark) result = compare_images(screenshot, benchmark, 500) if result[0]: code[0] = 0 else: code[0] = 1 print('Image difference: {}'.format(result))
def realCaptureFrame(ctx): idx = len(ctx.frames) fname = op.join(tempdir, '{}.gif'.format(idx)) frame = panel.getMovieFrame(overlay, opts) if not progfunc(idx): raise Cancelled() # The 3D X/Y/Z movie mode performs # rotations, rather than moving the # display location through the X/Y/Z # axes. The "frame" returned by # getMovieFrame is a rotation matrix. # We convert these rotation matrices # into rms-deviations (average # deviation of the current frame from # the starting frame), which has an # inverted "V"-shaped wave form as the # scene is rotated 360 degrees. So # we continue capturing frames until # the rmsdev of the current frame is: # # - close to 0 (i.e. very similar to # the rotation matrix of the starting # frame), and # # - less than the most recent frame (i.e. # has rotated past 180 degrees, and is # rotating back twoards the starting # point) if is3d: if len(ctx.frames) == 0: ctx.startFrame = frame # normalise the rotmat for this # frame to the rms difference # from the starting rotmat frame = transform.rmsdev(ctx.startFrame, frame) # Keep capturing frames until we # have performed a full 360 degree # rotation (rmsdev of current # frame is decreasing towards 0) if len(ctx.frames) > 1 and \ frame < ctx.frames[-1] and \ abs(frame) < 0.1: raise Finished() # All other movie frames have a range # (fmin, fmax) and start at some arbitrary # point within this range. We capture frames # until a full loop through this range has # been completed. else: # Have we looped back to fmin? ctx.looped = getattr(ctx, 'looped', False) if not ctx.looped and \ len(ctx.frames) > 1 and \ frame < ctx.frames[-1]: ctx.looped = True # We have done one full loop, and # have reached the starting frame. if ctx.looped and \ len(ctx.frames) > 1 and \ frame >= ctx.frames[0]: raise Finished() screenshot.screenshot(panel, fname) ctx.images.append(PIL.Image.open(fname)) ctx.frames.append(frame)
def __screenshot(self, view): """Insert a screenshot of the given view into the notebook. """ with tempdir.tempdir(): screenshot.screenshot(view, 'screenshot.png') return display.Image('screenshot.png')