From 8fed00cf55eb67156d1364165a711ae5b76d904c Mon Sep 17 00:00:00 2001 From: tux3 Date: Sun, 10 May 2015 00:35:07 +0200 Subject: [PATCH] Avoid unecessary copying of video frames And release some more data when possible --- src/video/cameraworker.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video/cameraworker.cpp b/src/video/cameraworker.cpp index df6da8e9a..d4b1abb17 100644 --- a/src/video/cameraworker.cpp +++ b/src/video/cameraworker.cpp @@ -173,6 +173,8 @@ void CameraWorker::unsubscribe() if (--refCount <= 0) { cam.release(); + frame = cv::Mat3b(); + queue.clear(); refCount = 0; } } @@ -201,7 +203,7 @@ void CameraWorker::doWork() return; } - QByteArray frameData(reinterpret_cast(frame.data), frame.total() * frame.channels()); + QByteArray frameData = QByteArray::fromRawData(reinterpret_cast(frame.data), frame.total() * frame.channels()); emit newFrameAvailable(VideoFrame{frameData, QSize(frame.cols, frame.rows), VideoFrame::BGR}); }