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. the availability of the camera

the availability of the camera

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 186 Views 1 Watching
  • 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.
  • J Offline
    J Offline
    julie546
    wrote on last edited by julie546
    #1

    I have activated both cameras and you find below my code please I would like to identify each time which camera is available
    for example:
    if both cameras are available my interface will show me:
    cameraAvant available
    cameraArriere available
    if the cameraAvant is not available the interface will tell me
    cameraAvant is not available and cameraArriere available
    how i can do it please
    I made this code there but even if there is a camera is not available it tells me that:
    cameraAvant available
    cameraArriere available

    if (QCameraInfo::availableCameras().count()>0) // compter les nombres des camera disponible
    {
    qDebug() << "Caméra disponible" << QCameraInfo::availableCameras().count();
    cameraArriere = new QCamera("/dev/video0",this); // l'obtention de source de camera Avant
    layoutArriere = new QVBoxLayout();
    cameraArriere->setViewfinder(viewfinderArriere);
    layoutArriere->addWidget(viewfinderArriere);
    cameraArriere->start();
    ui->label->setText("CameraArriere is available");

         cameraAvant = new QCamera("/dev/video2",this); // l'obtention de source de 
        camera Arriere
         layoutAvant = new QVBoxLayout();
         cameraAvant->setViewfinder(viewfinderAvant);
         layoutAvant->addWidget(viewfinderAvant);
         cameraAvant->start();
         ui->label_4->setText("cameraAvant is available");
    

    else {
    QMessageBox::warning(this, " " , "Both camera not available");
    }

    Pl45m4P 1 Reply Last reply
    0
    • J julie546

      I have activated both cameras and you find below my code please I would like to identify each time which camera is available
      for example:
      if both cameras are available my interface will show me:
      cameraAvant available
      cameraArriere available
      if the cameraAvant is not available the interface will tell me
      cameraAvant is not available and cameraArriere available
      how i can do it please
      I made this code there but even if there is a camera is not available it tells me that:
      cameraAvant available
      cameraArriere available

      if (QCameraInfo::availableCameras().count()>0) // compter les nombres des camera disponible
      {
      qDebug() << "Caméra disponible" << QCameraInfo::availableCameras().count();
      cameraArriere = new QCamera("/dev/video0",this); // l'obtention de source de camera Avant
      layoutArriere = new QVBoxLayout();
      cameraArriere->setViewfinder(viewfinderArriere);
      layoutArriere->addWidget(viewfinderArriere);
      cameraArriere->start();
      ui->label->setText("CameraArriere is available");

           cameraAvant = new QCamera("/dev/video2",this); // l'obtention de source de 
          camera Arriere
           layoutAvant = new QVBoxLayout();
           cameraAvant->setViewfinder(viewfinderAvant);
           layoutAvant->addWidget(viewfinderAvant);
           cameraAvant->start();
           ui->label_4->setText("cameraAvant is available");
      

      else {
      QMessageBox::warning(this, " " , "Both camera not available");
      }

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @julie546

      Either check if your QCameraobject is valid or use the Qt signals and the camera status enum (the latter is probably the better way)

      • https://doc.qt.io/qt-5/qcamera.html#statusChanged
      • https://doc.qt.io/qt-5/qcamera.html#Status-enum

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      2

      • Login

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