[Interest] QAbstractVideoSurface as viewfinder on iOS

Igor Mironchik igor.mironchik at gmail.com
Tue Sep 29 21:20:01 CEST 2015


Solved. The solution is simple: I didn't map QVideoFrame. That is why 
frame was empty...

On 29.09.2015 14:21, Igor Mironchik wrote:
> Hi guys,
>
> I decided to implement my custom video surface and use it as view 
> finder with QCamera.
>
> I wrote:
>
> ViewFinderSurface::ViewFinderSurface( const QCamera & camera, QObject 
> * parent )
>     :    QAbstractVideoSurface( parent )
>     ,    m_camera( camera )
> {
> }
>
> bool
> ViewFinderSurface::present( const QVideoFrame & frame )
> {
>     if( !isActive() )
>         return false;
>
>     qDebug() << "FRAME" << frame.bits() << frame.width() << 
> frame.height() << frame.bytesPerLine();
>
>     QImage image( frame.bits(), frame.width(), frame.height(), 
> frame.bytesPerLine(),
>         QVideoFrame::imageFormatFromPixelFormat( frame.pixelFormat() ) );
>
>     qDebug() << "IMAGE is NULL" << image.isNull();
>
>     QCameraInfo cameraInfo( m_camera );
>
>     const QScreen * screen = QGuiApplication::primaryScreen();
>     const int screenAngle = screen->angleBetween( 
> screen->nativeOrientation(),
>         screen->orientation() );
>
>     int rotation = 0;
>
>     if( cameraInfo.position() == QCamera::BackFace )
>         rotation = ( cameraInfo.orientation() - screenAngle ) % 360;
>     else
>         rotation = ( 360 - cameraInfo.orientation() + screenAngle ) % 
> 360;
>
>     image = image.transformed( QTransform().rotate( rotation ) );
>
>     emit newFrame( QPixmap::fromImage( image ) );
>
>     return true;
> }
>
> QList< QVideoFrame::PixelFormat >
> ViewFinderSurface::supportedPixelFormats( 
> QAbstractVideoBuffer::HandleType type ) const
> {
>     Q_UNUSED( type )
>
>     return QList< QVideoFrame::PixelFormat > ()
>         << QVideoFrame::Format_ARGB32
>         << QVideoFrame::Format_ARGB32_Premultiplied
>         << QVideoFrame::Format_RGB32
>         << QVideoFrame::Format_RGB24
>         << QVideoFrame::Format_RGB565
>         << QVideoFrame::Format_RGB555
>         << QVideoFrame::Format_ARGB8565_Premultiplied
>         << QVideoFrame::Format_BGRA32
>         << QVideoFrame::Format_BGRA32_Premultiplied
>         << QVideoFrame::Format_BGR32
>         << QVideoFrame::Format_BGR24
>         << QVideoFrame::Format_BGR565
>         << QVideoFrame::Format_BGR555
>         << QVideoFrame::Format_BGRA5658_Premultiplied
>         << QVideoFrame::Format_AYUV444
>         << QVideoFrame::Format_AYUV444_Premultiplied
>         << QVideoFrame::Format_YUV444
>         << QVideoFrame::Format_YUV420P
>         << QVideoFrame::Format_YV12
>         << QVideoFrame::Format_UYVY
>         << QVideoFrame::Format_YUYV
>         << QVideoFrame::Format_NV12
>         << QVideoFrame::Format_NV21
>         << QVideoFrame::Format_IMC1
>         << QVideoFrame::Format_IMC2
>         << QVideoFrame::Format_IMC3
>         << QVideoFrame::Format_IMC4
>         << QVideoFrame::Format_Y8
>         << QVideoFrame::Format_Y16
>         << QVideoFrame::Format_Jpeg
>         << QVideoFrame::Format_CameraRaw
>         << QVideoFrame::Format_AdobeDng;
> }
>
> But I always receive empty QVideoFrame... What's wrong?

-- 
Best Regards,
Igor Mironchik.




More information about the Interest mailing list