Skip to content

Commit

Permalink
this is used for labelling and other preproc
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandhi-Sagar authored Nov 4, 2017
1 parent d577500 commit 9b77f57
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions labeling_and_other_preproc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import cv2
import skvideo.io as skio

vd = skio.vread('serve.mp4')
nb_frames, _, _, _ = vd.shape
labels = []
for i in range(0, nb_frames):
img = vd[i, :]
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ngray = gray
cv2.normalize(gray, ngray, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
print(str(ngray.max()) + " " + str(ngray.min()))
print(ngray.shape)
cv2.imshow('window', ngray)
k = cv2.waitKey(0)
# 1048603 is Esc on this system, don't know generalization
if k == 1048603:
labels.append(1)
else:
labels.append(0)
with open('serve.labels', mode='wt', encoding='utf-8') as f:
f.write('\n'.join(str(label) for label in labels))


0 comments on commit 9b77f57

Please sign in to comment.