From f95f52df195edff0924617b9bec03b8333b48e71 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 17 Mar 2019 02:06:47 +0100 Subject: [PATCH] Few fixes in camera plugin --- platypush/plugins/camera/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/platypush/plugins/camera/__init__.py b/platypush/plugins/camera/__init__.py index dbba08a0..8d14b066 100644 --- a/platypush/plugins/camera/__init__.py +++ b/platypush/plugins/camera/__init__.py @@ -162,20 +162,21 @@ class CameraPlugin(Plugin): if device_id in self._is_recording: self._is_recording[device_id].clear() - if wait_thread_termination and device_id in self._recording_threads: - self.logger.info('A recording thread is running, waiting for termination') - if self._recording_threads[device_id].is_alive(): - self._recording_threads[device_id].join() + if device_id in self._recording_threads: + if wait_thread_termination: + self.logger.info('A recording thread is running, waiting for termination') + if self._recording_threads[device_id].is_alive(): + self._recording_threads[device_id].join() del self._recording_threads[device_id] if device_id in self._devices: self._devices[device_id].release() del self._devices[device_id] self.fire_event(CameraRecordingStoppedEvent(device_id=device_id)) + self.logger.info("Device {} released".format(device_id)) if device_id in self._recording_info: del self._recording_info[device_id] - self.logger.info("Device {} released".format(device_id)) def _store_frame_to_file(self, frame, frames_dir, image_file): @@ -282,8 +283,8 @@ class CameraPlugin(Plugin): frame = cv2.cvtColor(frame, color_transform) if rotate: + rows, cols = frame.shape if not rotation_matrix: - rows, cols = frame.shape rotation_matrix = cv2.getRotationMatrix2D( (cols/2, rows/2), rotate, 1) @@ -296,7 +297,7 @@ class CameraPlugin(Plugin): scale_x = scale_x or 1 scale_y = scale_y or 1 frame = cv2.resize(frame, None, fx=scale_x, fy=scale_y, - interpolation = cv.INTER_CUBIC) + interpolation = cv2.INTER_CUBIC) self._store_frame_to_file(frame=frame, frames_dir=frames_dir, image_file=image_file)