Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Zoom QCameraViewfinder Video possible?
QtWS25 Last Chance

Zoom QCameraViewfinder Video possible?

Scheduled Pinned Locked Moved Solved General and Desktop
qcameraviewfindvideoscalezoom
2 Posts 1 Posters 1.7k 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.
  • P Offline
    P Offline
    pauledd
    wrote on 12 Nov 2016, 16:48 last edited by pauledd 11 Dec 2016, 16:50
    #1

    Hi there,

    I have a simple app that shows me the live video of a webcam
    that looks through my telescope.

    I use a QCamera and a QCameraViewfinder object to view the live
    video from /dev/video0. The QCameraViewfinder is limited in size with 375x380. The video is set to 640x480. Of cause it gets squashed within the viewfinder dimension. But I am interested in the area around the circle (the red square). Is there any way to zoom into the red square triggered by a push button?
    image of the app

    I just stumbled upon the QGraphicsVideoItem that has a "setScale" Attribute. Is that the right way? But if yes how do I connect my QCamera to a QGraphicsVideoItem?

    EDIT:
    Here's some code that I use to build my camera:

            camera = new QCamera("/dev/video0");
    	cameraVf = new QCameraViewfinder(frame4);
    	camera->setViewfinder(cameraVf);
    	cameraVf->setGeometry(5,40,375,380);
    	QCameraViewfinderSettings vfsettings;
    	vfsettings.setPixelFormat(QVideoFrame::Format_YUV420P);
    	vfsettings.setResolution(640,480);
    	camera->setViewfinderSettings(vfsettings);
    	cameraVf->show();
    
    1 Reply Last reply
    1
    • P Offline
      P Offline
      pauledd
      wrote on 12 Nov 2016, 21:16 last edited by pauledd
      #2

      I think I found a solution. I roughly quadrupled the QCameraViewfinder size and repositioned it to the middle.
      Its all done with "cameraVf->setGeometry(x,y,x,y);". And I parented the viewfinder to a new QFrame
      to have a frame and to have the viewfinder not overlaying the start button.

      alt text

      mainwindow.cpp

      ...
              QFrame *frameVideo = new QFrame(frame4);		// extra frame where the video is in
      	frameVideo->setGeometry(5,35,375,380);
      	
      	camera = new QCamera("/dev/video0");
      	cameraVf = new QCameraViewfinder(frameVideo);
      	camera->setViewfinder(cameraVf);
      	cameraVf->setGeometry(0,0,375,380);
      	QCameraViewfinderSettings vfsettings;
      	vfsettings.setPixelFormat(QVideoFrame::Format_YUV420P);
      	vfsettings.setResolution(640,480);
      	camera->setViewfinderSettings(vfsettings);
      	cameraVf->show();
      ...
      
      void MainWindow::onZoomClicked(){
      	if(cameraVf->width() != 1600)
      	{
      		cameraVf->setGeometry(-590,-490,1600,1440);  // zoom in
      	}
      	else
      	{
      		cameraVf->setGeometry(0,0,375,380);		// zoom out
      	}
      }
      
      1 Reply Last reply
      1

      1/2

      12 Nov 2016, 16:48

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved