Results 1 to 5 of 5

Thread: Convert QVidoFrame to QPixMap / QImage is very slow

  1. #1
    Join Date
    Sep 2014
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X Android

    Default Convert QVidoFrame to QPixMap / QImage is very slow

    I've used QVideoProbe to access camera frames. My platform is Android. I've converted each camera frames to QImage and then pixmap and show on QLabel. My problem is this process is very slow. frames are showned very slowly. can i convert QVideoFrame straight to QPixMap or other faster way to showing camera frames? here is my code:
    QCamera *camera = new QCamera(this);

    camera->setCaptureMode(QCamera::CaptureViewfinder);

    QVideoProbe *videoProbe = new QVideoProbe(this);

    bool ret = videoProbe->setSource(camera);
    qDebug() <<"videoProbe->setSource(camera):" << ret;

    if (ret) {
    connect(videoProbe, SIGNAL(videoFrameProbed(const QVideoFrame &)),
    this, SLOT(present(const QVideoFrame &)));

    }

    camera->start();
    ...
    ...


    bool MainWindow:resent(const QVideoFrame &frame)
    {
    qDebug() <<"counter:" << ++counter;

    QVideoFrame cloneFrame(frame);
    if(cloneFrame.map(QAbstractVideoBuffer::ReadOnly))
    {
    QImage img(
    cloneFrame.size(), QImage::Format_ARGB32);
    qt_convert_NV21_to_ARGB32(cloneFrame.bits(),
    (quint32 *)img.bits(),
    cloneFrame.width(),
    cloneFrame.height());

    label->setPixmap(QPixmap::fromImage(img));

    cloneFrame.unmap();
    }

    return true;
    }


    I've used QPainter and passed it a QImage / OPixmap and used painter.drawImage and painter.drawPixmap. but still camera frames are shown very slowly in QPainter.

  2. #2
    Join Date
    Sep 2014
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X Android

    Default Convert QVidoFrame to QPixMap / QImage is very slow

    I've used QVideoProbe to access camera frames. My platform is Android. I've converted each camera frames to QImage and then pixmap and show on QLabel. My problem is this process is very slow. frames are showned very slowly. can i convert QVideoFrame straight to QPixMap or other faster way to showing camera frames? here is my code:
    QCamera *camera = new QCamera(this);

    camera->setCaptureMode(QCamera::CaptureViewfinder);

    QVideoProbe *videoProbe = new QVideoProbe(this);

    bool ret = videoProbe->setSource(camera);
    qDebug() <<"videoProbe->setSource(camera):" << ret;

    if (ret) {
    connect(videoProbe, SIGNAL(videoFrameProbed(const QVideoFrame &)),
    this, SLOT(present(const QVideoFrame &)));

    }

    camera->start();
    ...
    ...


    bool MainWindow:resent(const QVideoFrame &frame)
    {
    qDebug() <<"counter:" << ++counter;

    QVideoFrame cloneFrame(frame);
    if(cloneFrame.map(QAbstractVideoBuffer::ReadOnly))
    {
    QImage img(
    cloneFrame.size(), QImage::Format_ARGB32);
    qt_convert_NV21_to_ARGB32(cloneFrame.bits(),
    (quint32 *)img.bits(),
    cloneFrame.width(),
    cloneFrame.height());

    label->setPixmap(QPixmap::fromImage(img));

    cloneFrame.unmap();
    }

    return true;
    }


    I've used QPainter and passed it a QImage / OPixmap and used painter.drawImage and painter.drawPixmap. but still camera frames are shown very slowly in QPainter.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Convert QVidoFrame to QPixMap / QImage is very slow

    If you only need to display the video, have you tried using the camera as the media object of a QVideoWidget or the video widget as the camera's view finder?

    Cheers,
    _

  4. #4
    Join Date
    Sep 2014
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X Android

    Default Re: Convert QVidoFrame to QPixMap / QImage is very slow

    Thanks for your reply. Yes I've tried using QVideoWidget and QCameraViewFinder for camera live streaming
    , but on android nothing displayed. camera setviewfinder not worked on android for me.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Convert QVidoFrame to QPixMap / QImage is very slow

    Does it work on the desktop?
    I.e. is it a bug on Android or does this not work at all?

    Cheers,
    _

Similar Threads

  1. Convert QPixmap to QByteArray ?
    By probine in forum Qt Programming
    Replies: 5
    Last Post: 13th March 2014, 09:23
  2. convert to QPixmap
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2011, 05:18
  3. Replies: 4
    Last Post: 28th August 2008, 14:13
  4. What's faster: QPixmap-to-QImage or QImage-to-QPixmap
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2006, 18:11
  5. QPixmap::grabWindow too slow
    By niko in forum Newbie
    Replies: 2
    Last Post: 31st August 2006, 07:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.