Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Camera Preview Full Screen
Forum Updated to NodeBB v4.3 + New Features

Camera Preview Full Screen

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 503 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    Hello, I am using the Camera element for my android application, the camera opens successfully and I can take an image. I'm getting the output with VideoOutput. I want to make this preview full screen. Can you help me?

    fillMode: VideoOutput.Stretch
    

    The fillMode above works, but the camera image is distorted. How can I set the aspect ratio?

    Full Code

    
    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    import QtMultimedia
    
    Page {
        MediaDevices {
            id: deviceList
        }
    
        Camera {
            id: mainCamera
            active: true
            cameraDevice: deviceList.defaultVideoInput
            focusMode: Camera.FocusModeAutoNear
    
        }
    
        CaptureSession {
            camera: mainCamera
            videoOutput: videoOutput
        }
    
    
        VideoOutput {
            id: videoOutput
            anchors.fill: parent
            fillMode: VideoOutput.Stretch
        }
    
        Component.onCompleted: {
            mainCamera.active = false
            mainCamera.active = true
        }
    }
    
    

    Result

    alt text

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      @NullByte said in Camera Preview Full Screen:

      VideoOutput

      Have you tried different types of fillMode ?
      fillMode : enumeration

      Set this property to define how the video is scaled to fit the target area.
      
          Stretch - the video is scaled to fit.
          PreserveAspectFit - the video is scaled uniformly to fit without cropping
          PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary
      
      The default fill mode is PreserveAspectFit.
      

      https://doc.qt.io/qt-5/qml-qtmultimedia-videooutput.html#fillMode-prop

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      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