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] - Blame information for rev 45

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 45 qaztronic
#
2
 
3
import os
4
import numpy as np
5
import matplotlib.pyplot as plt
6
 
7
fname = 'count.raw'
8
number_of_frames = 4
9
width = 32
10
height = 32
11
# dtype='uint16'
12
dtype=np.dtype('uint16')
13
 
14
data = np.arange(number_of_frames*width*height, dtype=dtype)
15
# data = np.ones((number_of_frames, width, height), dtype=dtype)
16
# data = np.zeros((number_of_frames, width, height), dtype=dtype)
17
# data *= 32
18
 
19
with open(fname, 'w+') as infile:
20
  data.tofile(infile, format=dtype.str)
21
 
22
infile.close()
23
 
24
statinfo = os.stat(fname)
25
print(statinfo.st_size, ': file size')
26
print(statinfo.st_size / (width * height * dtype.itemsize), ': frames')
27
print(dtype.itemsize, ': itemsize')
28
 
29
 
30
# with open(fname, 'r') as infile:
31
  # data = np.fromfile(infile, dtype=dtype).reshape(number_of_frames, width, height)
32
 
33
data = np.memmap(fname, dtype=dtype, mode='r', shape=(number_of_frames, width, height))
34
 
35
for i in range(number_of_frames):
36
  print('Frame #', i)
37
  fig, ax = plt.subplots()
38
  im = ax.imshow(data[i], cmap='gray')
39
  ax.set(xticks=[], yticks=[])
40
  fig.colorbar(im)
41
  plt.show()
42
 

powered by: WebSVN 2.1.0

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