Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QVideoFrames pixel format to Camera_Raw : for processing frames realtime.

    General and Desktop
    qcamera qabstractvideos image raw images
    2
    2
    1333
    Loading More Posts
    • 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
      alok_pathak last edited by alok_pathak

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • First post
          Last post