-
Notifications
You must be signed in to change notification settings - Fork 1
/
dec_video.py
43 lines (40 loc) · 1.08 KB
/
dec_video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import cv2,sys,glob
import numpy as np
from imgstg import decode
# imgloc = input('enter location of video which you want to decode : ')
imgloc = 'project1.mkv'
cap = cv2.VideoCapture(imgloc)
count = 100000
ms = ''
for i in range (0,250):
ms+=' '
# extracting frames and saving it new folder
while(cap.isOpened()):
ret, frame = cap.read()
if(ret):
# print('Read %d frame :'%count,ret)
# frame = cv2.flip(frame,1)
# this line flips the image horizontally ; for vertical,both replace 1 by 0,2 respectively
cv2.imwrite('D:/data/frame{:d}.png'.format(count),frame)
# this above one saves it in the location
count += 1
else:
break
i=100000
msg,m = '',''
while(i<count):
imgoc = 'D:/data/frame%d.png'%i
m = decode(imgoc)
mr = m[::-1]
if(mr==m):
break
msg = msg + m
# print (msg)
print ('message %d decoded'%i)
i+=1
msg = msg.rstrip()
msg = msg.replace("||||||||||||","\n")
print ('msg decoded')
print (msg)
cap.release()
cv2.destroyAllWindows()