I created a subclass of QVideoWidget in order to display Video Frames from a camera (Basler, Pylon C++ API). Briefly, frames are converted to cv::Mat and then analyzed by a Neural Network. After that, I subclassed a QAbstractVideoSurface that presents frame to the VideoWidget.
When I try to display my frame in the QVideoWidget, the function void paintEvent(QPaintEvent *event) is triggered by update() or repaint(), but nothing is displayed on the widget. What's wrong?
I checked from the beginning of the pipeline, to the end, everything is OK (the frame contains data, the pixel format is OK, size OK, I can save a video file with actual frames in it, etc). I can see the widget in UI. I really suspect my paintEvent function.
Here is my paintEvent(QPaintEvent *event) function:
// VideoWidget.h
protected:
void paintEvent(QPaintEvent *event) override;
// VideoWidget.cpp
void VideoWidget::paintEvent(QPaintEvent *event) {
QPainter p(this);
p.drawImage(QRectF(m_targetRect), m_frameConv);
QVideoWidget::paintEvent(event);
}
PS: I'm on MacOS 11 (it didn't work neither on MacOSX), I'm using CMake 3.17.