当前位置: 首页>>代码示例>>Python>>正文


Python png.from_array方法代码示例

本文整理汇总了Python中png.from_array方法的典型用法代码示例。如果您正苦于以下问题:Python png.from_array方法的具体用法?Python png.from_array怎么用?Python png.from_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在png的用法示例。


在下文中一共展示了png.from_array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_time_steps

# 需要导入模块: import png [as 别名]
# 或者: from png import from_array [as 别名]
def _generate_time_steps(self, trajectory_list):
    """Transforms time step observations to frames of a video."""
    for time_step in gym_env_problem.GymEnvProblem._generate_time_steps(
        self, trajectory_list):
      # Convert the rendered observations from numpy to png format.
      frame_np = np.array(time_step.pop(env_problem.OBSERVATION_FIELD))
      frame_np = frame_np.reshape(
          [self.frame_height, self.frame_width, self.num_channels])
      # TODO(msaffar) Add support for non RGB rendered environments
      frame = png.from_array(frame_np, "RGB", info={"bitdepth": 8})
      frame_buffer = six.BytesIO()
      frame.save(frame_buffer)

      # Put the encoded frame back.
      time_step[_IMAGE_ENCODED_FIELD] = [frame_buffer.getvalue()]
      time_step[_IMAGE_FORMAT_FIELD] = [_FORMAT]
      time_step[_IMAGE_HEIGHT_FIELD] = [self.frame_height]
      time_step[_IMAGE_WIDTH_FIELD] = [self.frame_width]

      # Add the frame number
      time_step[_FRAME_NUMBER_FIELD] = time_step[env_problem.TIMESTEP_FIELD]
      yield time_step 
开发者ID:tensorflow,项目名称:tensor2tensor,代码行数:24,代码来源:rendered_env_problem.py

示例2: main

# 需要导入模块: import png [as 别名]
# 或者: from png import from_array [as 别名]
def main():
	if len(sys.argv) != 2:
		print "python %s <filename>" % sys.argv[0]
		sys.exit(1)

	try:
		filename = sys.argv[1]
		with open(filename, 'rb') as f:
			saved_state = pickle.load(f)
		
		bitmap = saved_state['bitmap']

	except:
		print "[!] Could not load bitmap"
		sys.exit(1)

	# Get rough code coverage value
	coverage = get_coverage(bitmap)
	print "[*] Code coverage (basic block calls): %.2f" % coverage

	if HAS_PYPNG:		
		# Create PNG image from bitmap values
		p = populate_array(bitmap)
		img = png.from_array(p, 'RGB')
		img.save('status_graph.png')

		print "[*] Created PNG file" 
开发者ID:carlosgprado,项目名称:BrundleFuzz,代码行数:29,代码来源:CreateStatusGraph.py

示例3: main

# 需要导入模块: import png [as 别名]
# 或者: from png import from_array [as 别名]
def main(wb):
    wb.open()
    regs = wb.regs
    # # #
    print("dumping framebuffer memory...")
    dump = []
    for n in range(DUMP_SIZE//(WORDS_PER_PACKET*4)):
        data = wb.read(SDRAM_BASE + n*WORDS_PER_PACKET*4, WORDS_PER_PACKET)
        for pixel in data:
            dump += extract_rgb(pixel)
    dump = [dump[x:x+LINE_SIZE] for x in range(0, len(dump), LINE_SIZE)]
    print("dumping to png file...")
    png.from_array(dump, "RGB").save("dump.png")
    # # #
    wb.close() 
开发者ID:timvideos,项目名称:HDMI2USB-litex-firmware,代码行数:17,代码来源:test_dump.py


注:本文中的png.from_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。