Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QVideoFrames pixel format to Camera_Raw : for processing frames realtime.

QVideoFrames pixel format to Camera_Raw : for processing frames realtime.

Scheduled Pinned Locked Moved General and Desktop
qcameraqabstractvideosimageraw images
2 Posts 2 Posters 1.6k Views
  • 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.
  • A Offline
    A Offline
    alok_pathak
    wrote on 12 May 2015, 09:12 last edited by alok_pathak 5 Dec 2015, 09:30
    #1

    Hi Friends

    I am working on a project that requires me to use the Macbook Camera. The idea is to process the video frames as they come.

    I read through the following document :
    http://doc.qt.io/qt-5/cameraoverview.html

    which tells me that :

    "For advanced usage (like processing viewfinder frames as they come, to detect objects or patterns), you can also derive from QAbstractVideoSurface and set that as the viewfinder for the QCamera object. In this case you will need to render the viewfinder image yourself."

    Hence, I create a class CameraFrameGrabber which looks like this :

    #include "cameraframegrabber.h"
    
    CameraFrameGrabber::CameraFrameGrabber(QObject *parent) :
        QAbstractVideoSurface(parent)
    {
    
    }
    
    QList<QVideoFrame::PixelFormat> CameraFrameGrabber::supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
    {
    //    Q_UNUSED(handleType);
    
        if (handleType == QAbstractVideoBuffer::NoHandle) {
                return QList<QVideoFrame::PixelFormat>()
                        << QVideoFrame::Format_CameraRaw;
            }
    
        return QList<QVideoFrame::PixelFormat>()
              << QVideoFrame::Format_RGB24;
    }
    
    bool CameraFrameGrabber::present(const QVideoFrame &frame)
    {
        if (frame.isValid()) {
            QVideoFrame cloneFrame(frame);
            QAbstractVideoBuffer::HandleType handleType;
            cloneFrame.map(QAbstractVideoBuffer::ReadOnly);
            qDebug()<<cloneFrame;
    
              const QImage image(cloneFrame.bits(),
                             cloneFrame.width(),
                              cloneFrame.height(),
                              QVideoFrame::imageFormatFromPixelFormat(cloneFrame .pixelFormat()));
                   
            emit frameAvailable(image);
            cloneFrame.unmap();
    
            return true;
        }
        return false;
    }
    

    My issue is I need the images in Camera_Raw format. But I only end up getting the pixel format of the QVideoFrame as RGB_32. I am not able to change the QVideoFrame format. Can you please help me solve this?

    Thank you

    Regards

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 May 2015, 20:48 last edited by
      #2

      Hi and welcome to devnet,

      AFAIK, you need to go lower level in order to modify the type of the generated image

      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

      2/2

      14 May 2015, 20:48

      • Login

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