From efdeb95bbecd718b0dfbfde15e919f73e8781a68 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 11 Feb 2023 08:52:11 -0800 Subject: [PATCH] opencv: fixup color conversion fast path --- plugins/opencv/src/opencv/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/opencv/src/opencv/__init__.py b/plugins/opencv/src/opencv/__init__.py index a0d9caaa3..6a3d918fd 100644 --- a/plugins/opencv/src/opencv/__init__.py +++ b/plugins/opencv/src/opencv/__init__.py @@ -213,12 +213,10 @@ class OpenCVPlugin(DetectPlugin): raise Exception('can not run motion detection on image') def run_detection_avframe(self, detection_session: DetectionSession, avframe, settings: Any, src_size, convert_to_src_size) -> Tuple[ObjectsDetected, Any]: - format = avframe.format - if format != 'yuv420p' or format != 'yuvj420p': - format = 'yuvj420p' + if avframe.format.name != 'yuv420p' and avframe.format.name != 'yuvj420p': + mat = avframe.to_ndarray(format='gray8') else: - format = None - mat = avframe.to_ndarray(format=format) + mat = np.ndarray((avframe.height, avframe.width, self.pixelFormatChannelCount), buffer=avframe.planes[0], dtype=np.uint8) detections = self.detect( detection_session, mat, settings, src_size, convert_to_src_size) if not detections or not len(detections['detections']):