Commit f4d3196a authored by Gihan Jayatilaka's avatar Gihan Jayatilaka

corners

parent 953ee6c2
......@@ -52,12 +52,16 @@ def toBin(x,dim=0):
if __name__ == "__main__":
coder=rs.RSCoder(n=12,k=6)
print("python msg-decoding-1.py msg.npz 12 6")
print("python msg-decoding-1.py msg.npz N K")
# print("python msg-decoding-1.py msg.npz")
INPUT_FILE=sys.argv[1]
OUTPUT_FILE=sys.argv[2]
RS_N=int(sys.argv[3])
RS_K=int(sys.argv[4])
coder=rs.RSCoder(n=RS_N,k=RS_K)
file=np.load(INPUT_FILE)
msg=file['ar'].astype(np.int32)
# print("MSG",msg)
......@@ -79,7 +83,7 @@ if __name__ == "__main__":
# print("FRAMES",frames)
# print("FRAMES.shape",frames.shape)
frames=np.reshape(frames,(-1,12,8))
frames=np.reshape(frames,(-1,RS_N,8))
# print("FRAMES",frames)
# print("FRAMES.shape",frames.shape)
......@@ -88,7 +92,7 @@ if __name__ == "__main__":
for f in range(frames.shape[0]):
str=""
#chars=[]#np.zeros(shape=(12),dtype=np.int32)
for c in range(12):
for c in range(RS_N):
# print(frames[f,c,:])
# print(np.power(2,np.arange(7,-1,-1)))
# print(frames[f,c,:]*np.power(2,np.arange(7,-1,-1)))
......@@ -102,9 +106,17 @@ if __name__ == "__main__":
str=str+a
# print(str)
strDecoded=coder.decode(str)
print(strDecoded)
ans=ans+strDecoded[0]
try:
strDecoded=coder.decode(str)
strDecoded=strDecoded[0]
for s in range(len(strDecoded)):
if ord(strDecoded[s])<127:
ans=ans+strDecoded
except:
ans=ans+""
print("DECODED : ",ans)
......
......@@ -8,7 +8,6 @@ import unireedsolomon.rs as rs
def toBin(x,dim=0):
if dim==0:
ans=bin(ord(x))[2:]
ans=list(ans)
ans.reverse()
......@@ -16,14 +15,7 @@ def toBin(x,dim=0):
ans.append(0)
ans.reverse()
print(x,ans)
# print("2 -- ", ans)
# ans.reverse()
# print("3 -- ", ans)
# print(ans)
# ans=list(ans)
ans=map(int,ans)
# print("3 -- ", ans)
ans=list(ans)
print(ans)
ans=np.array(ans)
......@@ -47,23 +39,33 @@ def toBin(x,dim=0):
return np.array(ar)
def breakDownString(str):
def breakDownString(str,k):
ans=[]
while len(str)>6:
ans.append(str[:6])
str=str[6:]
while len(str)>k:
ans.append(str[:k])
str=str[k:]
ans.append(str)
return ans
if __name__ == "__main__":
print("python msg-encoding-1.py msg.txt code.npz 10 10")
print("python msg-encoding-1.py msg.txt code.npz 10 10 12 6")
print("python msg-encoding-1.py msg.txt code.npz 10 10 n k")
TEXT_FILE=sys.argv[1]
OUTPUT_FILE=sys.argv[2]
CELLS_PER_HEIGHT=int(sys.argv[3])
CELLS_PER_WIDTH=int(sys.argv[4])
RS_N=int(sys.argv[5])
RS_K=int(sys.argv[6])
if 12%RS_N!=0:
print("You should be able to put an integer number of blocks in a screen frame")
quit(0)
coder=rs.RSCoder(n=12,k=6)
coder=rs.RSCoder(n=RS_N,k=RS_K)
originalMsg=""
fd = open(TEXT_FILE,'r')
......@@ -71,7 +73,7 @@ if __name__ == "__main__":
for line in fd:
originalMsg=originalMsg+line
segmentedMsg=breakDownString(originalMsg)
segmentedMsg=breakDownString(originalMsg,RS_K)
print(segmentedMsg)
encodedMsg=[]
for m in segmentedMsg:
......
......@@ -38,7 +38,7 @@ def videoToVarThread(rgbX,X,alp,channel):
if __name__ == "__main__":
ORIGINAL_H=1440
ORIGINAL_H=1080
ORIGINAL_W=1920
if GMM:
alphas=[0.01,0.02,0.05,0.1,0.2,0.5,0.8]
......@@ -48,26 +48,16 @@ if __name__ == "__main__":
vars=np.zeros(shape=(299,299,3,N),dtype=np.float16)
meanVars=np.zeros(shape=(299,299,N),dtype=np.float16)
print("python video-cropping-1.py recorded.mp4 screen-detection-model.h5 cropped.mp4 200")
print("python video-cropping-1.py recorded.mp4 screen-detection-model.h5 cropped.mp4 0 200 corners.npz")
RECORDED_VIDEO_FILE=sys.argv[1]
MODEL_FILE=sys.argv[2]
OUTPUT_FILE=sys.argv[3]
FRAMES_TO_SKIP=0
try:
FRAMES_TO_SKIP=int(sys.argv[4])
except:
print("Not skipping any frames by default")
NO_FRAMES=99999999
try:
NO_FRAMES=int(sys.argv[5])
except:
print("Cropping the full video.")
MANUAL=False
try:
MANUAL=(sys.argv[6]=='manual')
except:
print("Automatic cropping")
FRAMES_TO_SKIP=int(sys.argv[4])
NO_FRAMES=int(sys.argv[5])
CORNERS_SAVE_FILE=sys.argv[6]
vidIn=cv2.VideoCapture(RECORDED_VIDEO_FILE)
ret,fr=vidIn.read()
......@@ -191,8 +181,9 @@ if __name__ == "__main__":
corners=np.array(corners)
np.savez(CORNERS_SAVE_FILE,corners=corners)
if DEBUG:
print("Shape of corners = {}".format(corners.shape))
print("Shape of corners = {} saved to {}".format(corners.shape,CORNERS_SAVE_FILE))
vidIn.release()
......
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