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. QML Camera error

QML Camera error

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
cameracamerabin
1 Posts 1 Posters 399 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.
  • B Offline
    B Offline
    B0bbyR4y
    wrote on last edited by B0bbyR4y
    #1

    Hi,

    System information:
    NVIDIA Jetson Xavier NX (aarch64)
    Qt 5.15 (qmake)
    Cross compilaton using Qt Creator on Ubuntu 22.04

    Problem Description:
    I am using the Camera & VideoOutput QML components (https://doc.qt.io/qt-5/qml-qtmultimedia-camera.html & https://doc.qt.io/qt-5/qml-qtmultimedia-videooutput.html) together with a v4l2loopback device. I use this device as a sink in my GStreamer pipeline (v4l2sink) and as a source for the Camera QML component. Every few seconds I get this message:

    CameraBin error: "Failed to allocate a buffer"
    

    This is a block diagram of my GStreamer pipeline:
    liveViewQmlCameraError.png

    The video that is streamed into the v4l2sink is captured using the Camera QML component.
    This is the code for the Camera QML component (the QML component Loader - named liveViewLoader - is not included in this code snippet as this is not relevant for the issue in my opinion):

    import QtQuick 2.0
    import QtMultimedia 5.15
    
    Item
    {
    	/*
    	 * If the video stream does not exist on creation, the camera will never work.
    	 * The Component + Loader circumvents this by reloading the camera components after a timeout has occured.
    	 * The video device itself has to exist before the start, though.
    	 */
    	id:             wrappingItem
    	anchors.fill:   parent
    
    	property string videoDeviceFile: "/dev/video2"
    	Timer
    	{
    		id:         cameraTimeoutTimer
    		interval:   1000 /* in ms */
    		running:    false
    		repeat:     false
    		onTriggered:
    		{
    			liveViewLoader.restart();
    		}
    	}
    
    	Component
    	{
    		id: liveViewComponent
    		Item
    		{
    			height: wrappingItem.height
    			width:  wrappingItem.width
    
    			id: liveViewComponentItem
    
    			Camera
    			{
    				id:             camera
    				captureMode:    Camera.CaptureStillImage
    				deviceId:       wrappingItem.videoDeviceFile
    				onCameraStatusChanged:
    				{
    					console.log("Live view camera state changed to", camera.cameraStatus)
    					var liveViewRunning = (camera.cameraStatus == Camera.ActiveStatus);
    					// If the camera changed state, but it's not running, set a timeout to restart the camera via the Loader.
    					cameraTimeoutTimer.start();
    					if ( liveViewRunning )
    					{
    						cameraTimeoutTimer.stop();
    					}
    				}
    
    				Component.onCompleted:
    				{
    					checkAndHandleCameraAvailability();
    				}
    			}
    
    			VideoOutput
    			{
    				id:             videoOutputArea
    				source:         camera
    				anchors.fill:   parent
    				flushMode:      VideoOutput.EmptyFrame
    				focus:          visible
    			}
    
    			function checkAndHandleCameraAvailability()
    			{
    				// If the selected camera is not available, the camera will automatically select a different camera that's available on the system. This is a workaround to disable that behavior.
    				camera.deviceId = wrappingItem.videoDeviceFile
    
    				let videoDeviceIsAvailable = (camera.deviceId === wrappingItem.videoDeviceFile);
    				if (videoDeviceIsAvailable)
    					return;
    
    				console.log("Camera is currently using video device", camera.deviceId)
    				console.log("AvlStreamHandler.videoDeviceFile: ", AvlStreamHandler.videoDeviceFile)
    				console.log("Video device", wrappingItem.videoDeviceFile, "is not available.")
    				liveViewLoader.stop();
    			}
    		}
    	}
    

    Question:
    Can anyone give me a hint why I get the "CameraBin error: "Failed to allocate a buffer"" error message and how this error could possibly be resolved?

    Best regards
    B0bbyR4y

    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