Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. VideoFrameProbed signal transfers empty frames

VideoFrameProbed signal transfers empty frames

Scheduled Pinned Locked Moved Unsolved Language Bindings
2 Posts 2 Posters 603 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    keesaev
    wrote on last edited by keesaev
    #1

    Hi guys, I've been developing this app that would capture video from camera and send it through UDP socket.

    I've got a Camera object in main.qml

            Camera {
                id: qmlCamera
                objectName: "qmlCamera"
            }
                VideoOutput {
                    id: senderVideo
                    source: qmlCamera
                    focus : visible
                }
    

    Here is the code that should refer to that Camera object and establish a connection between videoFrameProbed signal and onVideoFrameProbed slot:

    class videoSender : public QObject
    {
        Q_OBJECT
    public:
        explicit videoSender(QObject *parent = nullptr)
            : m_camera(qvariant_cast<QCamera*>(parent->property("mediaObject"))),
              m_videoProbe(new QVideoProbe)
        {
            initializeSocket();
    
            if(m_videoProbe->setSource(m_camera))
                qDebug() << "setSource success";
            connect(m_videoProbe, SIGNAL(videoFrameProbed(const QVideoFrame)),
                    this, SLOT(onVideoFrameProbed(const QVideoFrame)));
        }
    ...
    

    That's how I initialize the videoSender object:

        QObject *qmlCamera = engine.rootObjects().at(0)->findChild<QObject*>("qmlCamera");
        videoSender *vs = new videoSender(qmlCamera);
    

    It works as intended until I try to process a videoProbe in this slot:

    void videoSender::onVideoFrameProbed(const QVideoFrame &videoFrame){
    
        qDebug() << videoFrame.bits();  // returns 0x0
        qDebug() << videoFrame.mappedBytes();   // returns 0
    
        QImage img(videoFrame.bits(),
                   videoFrame.width(),
                   videoFrame.height(),
                   videoFrame.bytesPerLine(),
                   QVideoFrame::imageFormatFromPixelFormat(videoFrame.pixelFormat()));
    
        QByteArray data;
        QDataStream ds(&data, QIODevice::ReadWrite);
    
        ds.writeRawData((const char*)img.bits(), img.byteCount());
        ds.device()->seek(0);
        qDebug() << data.size();  // returns 0
    
        m_socket->writeDatagram(data, QHostAddress::LocalHost, 7755);
    }
    

    So a good thing is that videoFrameProbed signal is actually emitted, but it seems to transfer an empty frame that bits and mappedBytes attributes are set to 0. Also .isValid() method returns true and .size() returns the actual size of the camera window.
    I might be missing something here as this is my first project with multimedia. Also sorry for my bad english

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You are assuming that you have an image in QVideoFrame which might not be the case.

      See QVideoFrame::handleType.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved