Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
6.2.2
-
None
Description
I am trying to upgrade a cvCamera project from Qt 5.x to Qt 6.2.2. the main logic is to use opencv's videoCapture to open the camera, and then put camera frame into a VideoOutput through video sink and videoframe. The problem here is:
the user interface of the VideoOutput doesn't get updated automatically, only when i drag the application window around or minimize and restroe the window should the ui get the latest camera frame.
could you help having a look at this issue?
below are some snippers of my code:
void CVCamera::imageReceived() { //Update VideoOutput // if(videoSurface) // if(!videoSurface->present(*videoFrame)) // DPRINT("Could not present QVideoFrame to QAbstractVideoSurface, error: %d",videoSurface->error()); if(videoSink) { //if(videoFrame->isMapped()) // videoFrame->unmap(); videoSink->setVideoFrame(*videoFrame); } }
const QVideoFrameFormat videoFrameFormat(size, QVideoFrameFormat::PixelFormat::Format_BGRA8888_Premultiplied); videoFrame = new QVideoFrame(videoFrameFormat); if(videoFrame) videoFrame->map(QVideoFrame::ReadOnly); cv::Mat screenImage; if(videoFrame) screenImage = cv::Mat(height,width,CV_8UC4,videoFrame->bits(0)); while(running && videoFrame != NULL && camera != NULL){ if(!camera->grabFrame()) continue; unsigned char* cameraFrame = camera->retrieveFrame(); //Get camera image into screen frame buffer if(videoFrame){ cv::Mat tempMat(height,width,CV_8UC3,cameraFrame); cv::cvtColor(tempMat,screenImage,cv::COLOR_RGB2RGBA); } emit imageReady(); }
// code placeholder import QtQuick import QtQuick.Controls import QtQuick.Window import QtMultimedia import CVCamera Window { visible: true //Width and height stuff is for desktop only, they seem to be ignored on Android (this is expected good behavior) width: camera0.size.width + camera1.size.width height: camera0.size.height maximumWidth: camera0.size.width + camera1.size.width maximumHeight: camera0.size.height CVCamera { id: camera0 device: 0 size: "640x480" videoSink: output0.videoSink } CVCamera { id: camera1 device: 1 size: "640x480" videoSink: output1.videoSink } VideoOutput { id: output0 } VideoOutput { id: output1 anchors.left: output0.right } }