Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Receiving NV21 pixel format from camera using an implemented QAbstractVideoSurface class but result is gray not colorful
Forum Updated to NodeBB v4.3 + New Features

Receiving NV21 pixel format from camera using an implemented QAbstractVideoSurface class but result is gray not colorful

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 384 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.
  • J Offline
    J Offline
    Jafar.Sag.Sibil
    wrote on last edited by Jafar.Sag.Sibil
    #1

    The following code is used to write every video frame.
    but the result is gray.

    problem 1 :

    frame.image().isNull();// true forever
    

    problem 2 :

    frame.image().convertToFormat(someFormat).isNull();//true forever
    

    problem 3 :

    QImage	defaultImage ( frame.bits ( ), frame.width ( ), frame.height ( ), frame.bytesPerLine ( ), QImage::Format_Grayscale8 );// this operation does not work for every format and many of those make our result image null other than Alpha8, Mono, MonoLSB (all make our image terrible), Indexed, grayscale8 (gray style)
    

    videosurface.cpp

    bool VideoSurfacer::present ( const QVideoFrame & f )
    {
    	QVideoFrame frame ( f );
    	if ( frame.isValid ( ) && frame.map ( QAbstractVideoBuffer::MapMode::ReadWrite ) )
    		{
    			QImage	defaultImage ( frame.bits ( ), frame.width ( ), frame.height ( ), frame.bytesPerLine ( ), QImage::Format_Grayscale8 );
    			QString path = QStandardPaths::writableLocation ( QStandardPaths::GenericDataLocation ) + "/download/" + QString::number ( ++i );
    			QFile ( path + ".jpg" ).remove ( );
    			defaultImage.save ( path + ".jpg", "JPG" );
    
    			frame.unmap ( );
    		}
    	return true;
    }
    

    attention : QVideoFrame::imageFormatFromPixelformat(frame.pixelFormat());
    returns Format_Invalid which makes our image terrible like Mono etc

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

      So from the documentation you can only access it when mapping the frame. So you have to manage the data yourself.

      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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Did you check the handle type ?

        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
        1
        • J Offline
          J Offline
          Jafar.Sag.Sibil
          wrote on last edited by
          #3

          Handle type is NoHandle

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

            So from the documentation you can only access it when mapping the frame. So you have to manage the data yourself.

            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