OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [sim/] [tests/] [tb_video_frame_dpi/] [view_raw.py] - Rev 45

Compare with Previous | Blame | View Log

#
 
import os
import numpy as np
import matplotlib.pyplot as plt
 
fname = 'count.raw'
number_of_frames = 4
width = 32
height = 32
# dtype='uint16'
dtype=np.dtype('uint16')
 
data = np.arange(number_of_frames*width*height, dtype=dtype)
# data = np.ones((number_of_frames, width, height), dtype=dtype)
# data = np.zeros((number_of_frames, width, height), dtype=dtype)
# data *= 32
 
with open(fname, 'w+') as infile:
  data.tofile(infile, format=dtype.str)
 
infile.close()
 
statinfo = os.stat(fname)
print(statinfo.st_size, ': file size')
print(statinfo.st_size / (width * height * dtype.itemsize), ': frames')
print(dtype.itemsize, ': itemsize')
 
 
# with open(fname, 'r') as infile:
  # data = np.fromfile(infile, dtype=dtype).reshape(number_of_frames, width, height)
 
data = np.memmap(fname, dtype=dtype, mode='r', shape=(number_of_frames, width, height)) 
 
for i in range(number_of_frames):
  print('Frame #', i)
  fig, ax = plt.subplots()
  im = ax.imshow(data[i], cmap='gray')
  ax.set(xticks=[], yticks=[])
  fig.colorbar(im)
  plt.show()
 
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.