Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to record video using QGraphicsView with Overlay text?

How to record video using QGraphicsView with Overlay text?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 494 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.
  • N Offline
    N Offline
    nikita.panchal09
    wrote on last edited by
    #1

    Hi,

    I want to overlay text on Live video and record video with overlay text. I have tried two ways as per below but not succeed.

    1. Using QGraphicsView:
      Problem: Unable to find a way to record video using QGraphicsView.

      *QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
      foreach (const QCameraInfo &cameraInfo, cameras)
      {
      if (cameraInfo.deviceName() == "/dev/video0")
      pCamera = new QCamera(cameraInfo, this);
      }

      QGraphicsVideoItem *videoItem = new QGraphicsVideoItem;
      scene = new QGraphicsScene(this);
      graphicsView = new QGraphicsView(scene);

      scene->addItem(videoItem);
      text = scene->addText("Hello World"); //Text Overlay
      scene->addItem(text);

      pCamera->setViewfinder(videoItem);
      QVBoxLayout *cBox2 = new QVBoxLayout();
      cBox2->addWidget(graphicsView);
      cBox2->setSpacing(0);

      ui->scrollArea->setLayout(cBox2);

      pMediaRecorder = new QMediaRecorder(pCamera);
      updateRecorderState(pMediaRecorder->state());
      connect(pMediaRecorder, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(updateRecorderState(QMediaRecorder::State)));

      if (pCamera->isCaptureModeSupported(QCamera::CaptureVideo))
      pCamera->setCaptureMode(QCamera::CaptureVideo);
      pMediaRecorder->setOutputLocation(QUrl::fromLocalFile(DATA_STORE_LOCATION"sample.mp4"));
      pMediaRecorder->record();*

      It is not recording video with overlay text.

    2. Using CameraViewfinder:
      Problem: Unable to find a way to add overlay and perform zoom Operations.

      *QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
      foreach (const QCameraInfo &cameraInfo, cameras)
      {
      if (cameraInfo.deviceName() == "/dev/video0")
      pCamera = new QCamera(cameraInfo, this);
      }

      pCameraViewfinder = new QCameraViewfinder(this);
      pCameraImageCapture = new QCameraImageCapture(pCamera, this);
      pVBoxLayout = new QVBoxLayout();

      //Set Camera View
      pCamera->setViewfinder(pCameraViewfinder);
      pVBoxLayout->addWidget(pCameraViewfinder);
      ui->scrollArea->setLayout(pVBoxLayout);

      pMediaRecorder = new QMediaRecorder(pCamera);
      updateRecorderState(pMediaRecorder->state());
      connect(pMediaRecorder, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(updateRecorderState(QMediaRecorder::State)));

      if (pCamera->isCaptureModeSupported(QCamera::CaptureVideo))
      pCamera->setCaptureMode(QCamera::CaptureVideo);
      pMediaRecorder->setOutputLocation(QUrl::fromLocalFile(DATA_STORE_LOCATION"sample.mp4"));
      pMediaRecorder->record();*

    Looking to hearing from you.

    Thanks,
    Nikita Panchal

    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