From b2cea07f479a29f1285deca5b82af74f276efd55 Mon Sep 17 00:00:00 2001 From: SimLeek Date: Sun, 24 Dec 2017 20:36:34 -0700 Subject: [PATCH] moved code to correct location --- cv_window_sub.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 cv_window_sub.py diff --git a/cv_window_sub.py b/cv_window_sub.py new file mode 100644 index 0000000..33a3a5f --- /dev/null +++ b/cv_window_sub.py @@ -0,0 +1,46 @@ +import cv2, pubsub + +if False: + from typing import List + +cvWindows = [] +frameDict={} + +def cv_win_sub(*, + names, # type: List[str] + inputVidGlobalNames # type: List[str] + ): + global cvWindows + for name in names: + cvWindows.append(name) + cv2.namedWindow(name) + + global frameDict + while True: + #global camImg + for i in range(len(inputVidGlobalNames)): + if inputVidGlobalNames[i] in frameDict and frameDict[inputVidGlobalNames[i]] is not None: + cv2.imshow(names[i%len(names)], frameDict[inputVidGlobalNames[i]]) + if cv2.waitKey(1)& 0xFF==ord('q'): + for name in names: + cv2.destroyWindow(name) + return + + +camImg = None +if __name__ == '__main__': + import importlib + import os, sys + sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + + cv_webcam_pub = importlib.import_module('cv_webcam_pub') + + def camHandler(frame, camId): + frameDict[str(camId)+"Frame"]= frame + + t = cv_webcam_pub.init_cv_cam_pub_handler(0, camHandler) + + cv_win_sub(names=['cammy', 'cammy2'], inputVidGlobalNames=[str(0)+"Frame"]) + + pubsub.publish("cvcamhandlers.0.cmd", 'q') + t.join() \ No newline at end of file