From 9b77f571171b3d9b4130017f184865011c42c0ed Mon Sep 17 00:00:00 2001 From: Gandhi-Sagar Date: Sat, 4 Nov 2017 16:08:48 -0400 Subject: [PATCH] this is used for labelling and other preproc --- labeling_and_other_preproc.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 labeling_and_other_preproc.py diff --git a/labeling_and_other_preproc.py b/labeling_and_other_preproc.py new file mode 100644 index 0000000..27a164d --- /dev/null +++ b/labeling_and_other_preproc.py @@ -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)) + +