Different number of mappedBytes in QVideoFrame in android versus ios

  • I'm working on a mobile application where I would like to process a QVideoFrame in OpenCV (or QImage). I am able to properly receive a QVideoFrame in Android, where I receive a logical number of bytes (3110400 for a 1920x1080 image). When I run the same code on ios, i receive a weird number of bytes (3136384 for a 1920x1080 image).

    After I map the QVideoFrame, I am able to properly process the Image using the NV21 format (as reported by the QVideoFrame pixelFormat() function). In ios, I am able to process the image (using the NV12 format), but I noticed that there is a shift in the colors (about 16 columns to the left). This is unsurprising, as I am only reading in 3110400 bytes versus the full 3136384 bytes.

    Both Android and ios report a QVideoFrame size of 1920x1080. Is there a way to properly read a QVideoFrame for processing such that there is no shift in the data?

  • I was able to resolve the issue by changing the QCameraViewFinderSettings on my QCamera to use QVideoFrame::Format_ARGB32 @ 1920x1080. After this change, the QVideoFrame reported the proper number of mappedBytes.

    One interesting note, I had to QCameraViewFinderSettings.setMinimumFrameRate(0). For some reason there was a lag on the viewfinder in low light, but changing this setting fixed it.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.