Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Dealing with the disappearance of QVideoProbe and QCameraViewfinder in Qt 6.x
Qt 6.12 LTS is out! See what's new in the release blog

Dealing with the disappearance of QVideoProbe and QCameraViewfinder in Qt 6.x

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.5k 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.
  • F Offline
    F Offline
    Francky033
    wrote on last edited by Francky033
    #1

    Hello,
    Under Qt 5.x, I was using QVideoProbe to get images from a camera. Unfortunately, this function has disappeared in version 6.x

    const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
    
    if (!cameras.empty())
    {
    	camera_sensor = new QCamera(QCamera::BackFace);
    
    	if (camera_sensor)
    	{
    		viewfinder = new QCameraViewfinder();
    
    		if (viewfinder)
    	       {
    			camera_sensor->setViewfinder(viewfinder);
    		        camera_sensor->setCaptureMode(QCamera::CaptureStillImage);
    
    			videoProbe = new QVideoProbe(this);
    
    			if (videoProbe->setSource(camera_sensor)) {
    				// Probing succeeded, videoProbe->isValid() should be true.
    				connect(videoProbe, SIGNAL(videoFrameProbed(QVideoFrame)),
    													this, SLOT(recupererImagesCamera(QVideoFrame)));
    			}
    
    			camera_sensor->start();
    			// Viewfinder frames should now also be emitted by
    			// the video probe, even in still image capture mode.
    			// Another alternative is to install the probe on a
    			// QMediaRecorder connected to the camera to get the
    			// recorded frames, if they are different from the
    			// viewfinder frames.
    	}
    }
    

    I try painfully to go through the QVideoSink class but without success.

    const QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
    
    if (!cameras.empty())
    {
            camera_sensor = new QCamera(QCameraDevice::BackFace);
    
    	if (camera_sensor)
    	{
    		viewfinder = new QVideoSink(this);
    
    		if (viewfinder)
    	       {
            		videoFrame = new QMediaCaptureSession();
    
    			videoFrame->setCamera(camera_sensor);
    
    			videoFrame->setVideoSink(viewfinder);
    
    			connect(viewfinder, &QVideoSink::videoFrameChanged,
    				this, &QWinStars3View::recupererImagesCamera2);
    											
    		}
         }
    }
    

    I try painfully to go through the QVideoSink class but without success.

    Thanx !

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      Hello, have you checked the Camera Example came with Qt installation?
      From my understanding, we use a QVideoWidget as the viewfinder (preview widget), and you don't need to create a QVideoSink because QVideoWidget already have one.
      So should be something like

      viewfinder = new QVideoWidget(this);
      videoFrame = new QMediaCaptureSession();
      videoFrame->setCamera(camera_sensor);
      videoFrame->setVideoOutput(viewfinder);
      connect(viewfinder->videoSink(), &QVideoSink::videoFrameChanged, this, &QWinStars3View::recupererImagesCamera2);
      camera_sensor->start();
      

      If you don't need a preview widget, then use QVideoSink only as in your code. Seems that should work after you start the camera.

      1 Reply Last reply
      2
      • F Offline
        F Offline
        Francky033
        wrote on last edited by Francky033
        #3

        Thanks Bonnie!

        It works perfectly (I will use QVideoSink )!

        Have a great day!

        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
        • Unsolved