def pg_video_background(video, out, frames, tmp_path): if os.path.exists(out): return out result = find_background(video, frames, debug=True, tmp_path=tmp_path) rgb = result['background'] imwrite(rgb, out) return out
def write_image(name, values): time_us = timestamp * 1000 * 1000 dirname2 = os.path.join(dirname, name) if not os.path.exists(dirname2): os.makedirs(dirname2) filename = os.path.join(dirname2, 'ms%08d.png' % time_us) if np.nanmin(values) < 0: rgb = posneg(values) else: rgb = scale(values) rgb = rgb_zoom(rgb, K=4) imwrite(rgb, filename) logger.debug('print to %r' % filename)
def main(): parser = OptionParser(usage=usage) parser.add_option("-i", "--input", dest='video', type="string", help='Input video.') parser.add_option("-o", "--output", dest='background', type="string", help='Output png.') parser.add_option("-f", "--frames", dest='frames', type="string", default='1.0,2,3.4', help='Frames to use; floats separated by comma.') (options, args) = parser.parse_args() if args: msg = 'No argument necessary.' raise Exception(msg) video = options.video background = options.background frames = map(float, options.frames.split(',')) result = find_background(video, frames, debug=True) imwrite(result['background'], background) return 0
def write_debug(rgb, id_image): if debug: f = join(tmp_path, '%s.png' % id_image) # print('Writing %s' % f) imwrite(rgb, f)