Commit b6ee6620 authored by Gihan Jayatilaka's avatar Gihan Jayatilaka

minor edit

parent 74de4b52
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -19,7 +19,7 @@ DELTA = 5
#NUMPAT33 = 384
READ_FILE = "../tvstatic"
READ_FILE = "../multipleVideos"
EXTENSION = ".mp4"
......
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import cv2
import numpy as np
import sys
FILE_NAME='../tvstatic'
GRID_X=20
GRID_Y=20
if len(sys.argv)>3:
FILE_NAME=(sys.argv[1].split("-"))[0]
GRID_X=int(sys.argv[2])
GRID_Y=int(sys.argv[3])
CELLS_PER_FRAME=GRID_X*GRID_Y
def binArray(x):
ans=np.zeros((CELLS_PER_FRAME),dtype=np.uint8)
for i in range(CELLS_PER_FRAME):
ans[i]=x&1
x=x>>1
return ans
video = cv2.VideoCapture('{}-code-{}x{}.mp4'.format(FILE_NAME,GRID_X,GRID_Y))
pattern = open('{}-code-{}x{}.csv'.format(FILE_NAME,GRID_X,GRID_Y))
npzFile = '{}-ideal-{}x{}.npz'.format(FILE_NAME,GRID_X,GRID_Y)
XX=[]
YY=[]
while video.isOpened():
ret, frame = video.read()
pat = pattern.readline()
if ret:
YY.append(binArray(int(pat)))
frame=cv2.resize(frame,(299,299),interpolation = cv2.INTER_LINEAR)
XX.append(frame)
else:
break
if len(YY)==8000:
break
video.release()
pattern.close()
XX=np.array(XX)
YY=np.array(YY)
np.savez(npzFile, X=XX, Y=YY)
print("X shape",XX.shape,"Y shape",YY.shape)
# In[ ]:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment