diff --git a/ground_station/.idea/workspace.xml b/ground_station/.idea/workspace.xml index f381a36..991b2b2 100644 --- a/ground_station/.idea/workspace.xml +++ b/ground_station/.idea/workspace.xml @@ -24,8 +24,8 @@ - - + + @@ -36,8 +36,8 @@ - - + + @@ -66,11 +66,11 @@ - + - - + + @@ -78,10 +78,10 @@ - + - + @@ -103,10 +103,10 @@ @@ -539,16 +539,6 @@ - - - - - - - - - - @@ -567,19 +557,19 @@ - + - - + + - + - + @@ -587,24 +577,34 @@ - + - - + + - + - - + + + + + + + + + + + + AAAAsC92Kuu3oLrABnhEDJd2fqLpSLKMDnz1RoGljcqcyx6rWWvT/BV+wcLNHGnvYk97nqnk/pKm4cGIiar9MRU3nZkNwyjJxPVtt3haC8iDCZdLJZ6CmktPYqrohRIav09rau96cPFO/I//1EIneIP/1ljcNiibrP6ukAATwUH19NLQaGz1/EYXXVq+qowSGeFE7dAFp107pLkmub5CsKj/8zF+PCqHoF8AEDn937Vn/JpXGWVGlieBMxMrucAQD8JqIA== diff --git a/ground_station/Framework/VideoSystems/RoverVideoCoordinator.py b/ground_station/Framework/VideoSystems/RoverVideoCoordinator.py index 54352e9..c17b77e 100644 --- a/ground_station/Framework/VideoSystems/RoverVideoCoordinator.py +++ b/ground_station/Framework/VideoSystems/RoverVideoCoordinator.py @@ -27,6 +27,8 @@ EXCLUDED_CAMERAS = ["zed"] # RoverVideoCoordinator Class Definition ##################################### class RoverVideoCoordinator(QtCore.QThread): + pixmap_ready_signal = QtCore.pyqtSignal(str) + def __init__(self, shared_objects): super(RoverVideoCoordinator, self).__init__() @@ -34,8 +36,8 @@ class RoverVideoCoordinator(QtCore.QThread): self.shared_objects = shared_objects self.right_screen = self.shared_objects["screens"]["right_screen"] self.primary_video_display_label = self.right_screen.primary_video_label # type:QtWidgets.QLabel - self.primary_video_display_label = self.right_screen.secondary_video_label # type:QtWidgets.QLabel - self.primary_video_display_label = self.right_screen.tertiary_video_label # type:QtWidgets.QLabel + self.secondary_video_display_label = self.right_screen.secondary_video_label # type:QtWidgets.QLabel + self.tertiary_video_display_label = self.right_screen.tertiary_video_label # type:QtWidgets.QLabel # ########## Get the settings instance ########## self.settings = QtCore.QSettings() @@ -49,25 +51,26 @@ class RoverVideoCoordinator(QtCore.QThread): self.setup_cameras_flag = True # ########## Class Variables ########## - self.global_start_signal = None - self.global_connect_signals_and_slots_signal = None - self.global_kill_signal = None - + # Camera variables + self.camera_threads = {} self.valid_cameras = [] - self.camera_threads = {} - - # ########## Setup cameras ########## + # Setup cameras self.__get_cameras() self.__setup_video_threads() + self.primary_label_current_setting = 0 + self.secondary_label_current_setting = 1 + self.tertiary_label_current_setting = 0 + + self.camera_data = {x: {"new_opencv": False} for x in self.valid_cameras} + print self.camera_data + def run(self): self.logger.debug("Starting Video Coordinator Thread") while self.run_thread_flag: - if self.setup_cameras_flag: - self.setup_cameras_flag = False self.msleep(100) self.__wait_for_camera_threads() @@ -101,7 +104,8 @@ class RoverVideoCoordinator(QtCore.QThread): self.camera_threads[camera].wait() def connect_signals_and_slots(self): - pass + for thread in self.camera_threads: + self.camera_threads[thread].image_ready_signal.connect(self.pixmap_ready__slot) def setup_signals(self, start_signal, signals_and_slots_signal, kill_signal): start_signal.connect(self.start) @@ -111,6 +115,16 @@ class RoverVideoCoordinator(QtCore.QThread): for camera in self.camera_threads: self.camera_threads[camera].setup_signals(start_signal, signals_and_slots_signal, kill_signal) + def pixmap_ready__slot(self, camera): + if self.valid_cameras[self.primary_label_current_setting] == camera: + self.primary_video_display_label.setPixmap(self.camera_threads[camera].pixmap_1280x720_image) + + if self.valid_cameras[self.secondary_label_current_setting] == camera: + self.secondary_video_display_label.setPixmap(self.camera_threads[camera].pixmap_640x360_image) + + if self.valid_cameras[self.tertiary_label_current_setting] == camera: + self.tertiary_video_display_label.setPixmap(self.camera_threads[camera].pixmap_640x360_image) + def on_kill_threads_requested__slot(self): self.run_thread_flag = False diff --git a/ground_station/Framework/VideoSystems/RoverVideoReceiver.py b/ground_station/Framework/VideoSystems/RoverVideoReceiver.py index c2c96f9..4a78384 100644 --- a/ground_station/Framework/VideoSystems/RoverVideoReceiver.py +++ b/ground_station/Framework/VideoSystems/RoverVideoReceiver.py @@ -25,8 +25,7 @@ FONT = cv2.FONT_HERSHEY_TRIPLEX # RoverVideoReceiver Class Definition ##################################### class RoverVideoReceiver(QtCore.QThread): - publish_message_signal = QtCore.pyqtSignal() - image_ready_signal = QtCore.pyqtSignal() + image_ready_signal = QtCore.pyqtSignal(str) def __init__(self, camera_name): super(RoverVideoReceiver, self).__init__() @@ -54,12 +53,15 @@ class RoverVideoReceiver(QtCore.QThread): # Image variables self.raw_image = None - self.opencv_image = None - self.pixmap = None + self.opencv_1280x720_image = None + self.opencv_640x360_image = None + + self.pixmap_1280x720_image = None + self.pixmap_640x360_image = None # Processing variables self.bridge = CvBridge() # OpenCV ROS Video Data Processor - self.video_enabled = False + self.video_enabled = True self.new_frame = False # Assign local callbacks @@ -80,10 +82,26 @@ class RoverVideoReceiver(QtCore.QThread): def __show_video_enabled(self): if self.new_frame: - self.opencv_image = self.bridge.compressed_imgmsg_to_cv2(self.raw_image, "rgb8") - self.opencv_image = cv2.resize(self.opencv_image, (1280, 720)) - self.pixmap = QtGui.QPixmap.fromImage(qimage2ndarray.array2qimage(self.opencv_image)) - self.image_ready_signal.emit() + opencv_image = self.bridge.compressed_imgmsg_to_cv2(self.raw_image, "rgb8") + + height, width, _ = opencv_image.shape + + if width != 1280 and height != 720: + self.opencv_1280x720_image = cv2.resize(opencv_image, (1280, 720)) + else: + self.opencv_1280x720_image = opencv_image + + if width != 640 and height != 360: + self.opencv_640x360_image = cv2.resize(opencv_image, (640, 360)) + else: + self.opencv_640x360_image = opencv_image + + self.pixmap_1280x720_image = QtGui.QPixmap.fromImage(qimage2ndarray.array2qimage( + self.opencv_1280x720_image)) + self.pixmap_640x360_image = QtGui.QPixmap.fromImage(qimage2ndarray.array2qimage( + self.opencv_640x360_image)) + + self.image_ready_signal.emit(self.camera_name) self.new_frame = False def __show_video_disabled(self): @@ -91,13 +109,9 @@ class RoverVideoReceiver(QtCore.QThread): fps_image = np.zeros((720, 1280, 3), np.uint8) self.pixmap = QtGui.QPixmap.fromImage(qimage2ndarray.array2qimage(fps_image)) - self.image_ready_signal.emit() + self.image_ready_signal.emit(self.camera_name) self.new_frame = False - def __on_image_update_ready(self): - pass - # self.video_display_label.setPixmap(self.pixmap) - def __image_data_received_callback(self, raw_image): self.raw_image = raw_image self.new_frame = True @@ -117,7 +131,7 @@ class RoverVideoReceiver(QtCore.QThread): self.video_enabled = True def connect_signals_and_slots(self): - self.image_ready_signal.connect(self.__on_image_update_ready) + pass def setup_signals(self, start_signal, signals_and_slots_signal, kill_signal): start_signal.connect(self.start)