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. QCamera Problems!
Forum Updated to NodeBB v4.3 + New Features

QCamera Problems!

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 6 Posters 10.8k Views 3 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.
  • mranger90M Offline
    mranger90M Offline
    mranger90
    wrote on last edited by
    #17

    I've been able to use it many time with various Linuxi and through several Qt releases.
    Are you able to use the camera outside of Qt, for example with the Cheese app ?

    Hasan VaezH 2 Replies Last reply
    0
    • mranger90M mranger90

      I've been able to use it many time with various Linuxi and through several Qt releases.
      Are you able to use the camera outside of Qt, for example with the Cheese app ?

      Hasan VaezH Offline
      Hasan VaezH Offline
      Hasan Vaez
      wrote on last edited by Hasan Vaez
      #18

      @mranger90
      Thank you for your reply.
      Yes, I can use it outside of QT. I tested it with Cheese app in Ubuntu 16.04 LTS without any problem.
      I also have not any problem in other OS like MAC and WINDOWS.

      1 Reply Last reply
      0
      • mranger90M mranger90

        I've been able to use it many time with various Linuxi and through several Qt releases.
        Are you able to use the camera outside of Qt, for example with the Cheese app ?

        Hasan VaezH Offline
        Hasan VaezH Offline
        Hasan Vaez
        wrote on last edited by Hasan Vaez
        #19

        @mranger90
        Please tell me what plugins did you install for qmultimedia in QT5?

        1 Reply Last reply
        0
        • mranger90M Offline
          mranger90M Offline
          mranger90
          wrote on last edited by
          #20

          Unfortunately I don't have any of those systems in front of me now and won't until Monday.
          Off the top of my head I'm pretty sure I've installed libgstreamerdev and maybe gstpluginsbase?
          Not sure of the exact package names.

          1 Reply Last reply
          0
          • mranger90M Offline
            mranger90M Offline
            mranger90
            wrote on last edited by
            #21

            Ok, I just set up an Ubuntu 16.04 VM with VMWare on my pathetically underpowered home system which is running Win 10 as the native OS.
            Installed Qt 5.10.0.
            Have a Microsoft LifeCam HD-600 usb camera.
            VMWare is set up to use USB 1.1.
            Cheese can access and display the camera.
            To build the Examples/multimediaWidgets/camera project I had to install:
            libgl-mesa-dev
            mesa-common-dev
            libpulse-dev

            Other than a little fiddling with the camera parameters that's all I had to do to get it to work on a stock ubuntu 16.04 install.
            I'd have to dig out some of my other apps to test with, but it looks like this should work for you. If you can post a more complete set of your code I'd be happy to test it tomorrow.

            Hasan VaezH 1 Reply Last reply
            1
            • mranger90M mranger90

              Ok, I just set up an Ubuntu 16.04 VM with VMWare on my pathetically underpowered home system which is running Win 10 as the native OS.
              Installed Qt 5.10.0.
              Have a Microsoft LifeCam HD-600 usb camera.
              VMWare is set up to use USB 1.1.
              Cheese can access and display the camera.
              To build the Examples/multimediaWidgets/camera project I had to install:
              libgl-mesa-dev
              mesa-common-dev
              libpulse-dev

              Other than a little fiddling with the camera parameters that's all I had to do to get it to work on a stock ubuntu 16.04 install.
              I'd have to dig out some of my other apps to test with, but it looks like this should work for you. If you can post a more complete set of your code I'd be happy to test it tomorrow.

              Hasan VaezH Offline
              Hasan VaezH Offline
              Hasan Vaez
              wrote on last edited by Hasan Vaez
              #22

              @mranger90 said in QCamera Problems!:

              libpulse-dev

              Thank you arranger for your comments.
              I install another Ubuntu 16.04, Qt5.10.0 (along with 3 components: libgl1-mesa-dev mesa-common-dev libpulse-dev)
              Test the Camera example with VMWARE MAC CAM and also with LOGITEC CAM.

              The problem remained!

              My codes are:
              1- Camera example in QT folder
              2- The following simple codes:

              QCamera *Camera;
              QCameraImageCapture *ImageCapture;
              QCameraInfo *CameraInfo;

              void MainWindow::on_pushButton_clicked()
              {
              Camera = new QCamera;
              ImageCapture = new QCameraImageCapture(Camera);

              Camera->setViewfinder(ui->wCamera);
              ui->wCamera->setAspectRatioMode(Qt::KeepAspectRatioByExpanding);
              Camera->setCaptureMode(QCamera::CaptureViewfinder);
              Camera->start();
              }

              All things seems to be correct, there should be a small point which I don't know what is it??

              1 Reply Last reply
              0
              • mranger90M Offline
                mranger90M Offline
                mranger90
                wrote on last edited by
                #23

                ok, Heres the simplest code I could create that runs with my setup:
                Mainwindow.h

                #ifndef MAINWINDOW_H
                #define MAINWINDOW_H
                
                #include <QMainWindow>
                #include <QCamera>
                
                namespace Ui {
                class MainWindow;
                }
                
                class MainWindow : public QMainWindow
                {
                    Q_OBJECT
                
                public:
                    explicit MainWindow(QWidget *parent = 0);
                    ~MainWindow();
                
                private slots:
                    void on_actionStart_triggered();
                
                private:
                    Ui::MainWindow *ui;
                    QCamera *m_camera;
                };
                
                #endif // MAINWINDOW_H
                
                

                mainwindow.cpp

                #include "mainwindow.h"
                #include "ui_mainwindow.h"
                
                #include <QVideoWidget>
                #include <QCameraInfo>
                #include <QCameraViewfinderSettings>
                #include <QDebug>
                
                MainWindow::MainWindow(QWidget *parent) :
                    QMainWindow(parent),
                    ui(new Ui::MainWindow)
                {
                    ui->setupUi(this);
                    QVideoWidget *videoDisplay = new QVideoWidget;
                    setCentralWidget(videoDisplay);
                
                    // get a list of available cameras
                    QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
                    // just pick the first
                    if (cameras.size() > 0) {
                        qDebug() << "creating camera from " << cameras.at(0).deviceName() << cameras.at(0).description();
                        m_camera = new QCamera(cameras.at(0));
                        if (m_camera) {
                            m_camera->setViewfinder(videoDisplay);
                            m_camera->setCaptureMode(QCamera::CaptureViewfinder);
                            QCameraViewfinderSettings settings = m_camera->viewfinderSettings();
                            // change resolution to 320x240
                            settings.setResolution(QSize(320,240));
                            m_camera->setViewfinderSettings(settings);
                
                
                        }
                    }
                }
                
                MainWindow::~MainWindow()
                {
                    delete ui;
                }
                
                void MainWindow::on_actionStart_triggered()
                {
                    if (m_camera) {
                        m_camera->start();
                    }
                }
                
                

                camtest.pro

                
                QT       += core gui multimedia multimediawidgets
                
                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                
                TARGET = camtest
                TEMPLATE = app
                
                DEFINES += QT_DEPRECATED_WARNINGS
                SOURCES += \
                        main.cpp \
                        mainwindow.cpp
                
                HEADERS += \
                        mainwindow.h
                
                FORMS += \
                        mainwindow.ui
                
                

                Mainwindow is just a stock MainWindow with a menu item to start video capture.

                Let me know if this works.

                Hasan VaezH 1 Reply Last reply
                2
                • mranger90M mranger90

                  ok, Heres the simplest code I could create that runs with my setup:
                  Mainwindow.h

                  #ifndef MAINWINDOW_H
                  #define MAINWINDOW_H
                  
                  #include <QMainWindow>
                  #include <QCamera>
                  
                  namespace Ui {
                  class MainWindow;
                  }
                  
                  class MainWindow : public QMainWindow
                  {
                      Q_OBJECT
                  
                  public:
                      explicit MainWindow(QWidget *parent = 0);
                      ~MainWindow();
                  
                  private slots:
                      void on_actionStart_triggered();
                  
                  private:
                      Ui::MainWindow *ui;
                      QCamera *m_camera;
                  };
                  
                  #endif // MAINWINDOW_H
                  
                  

                  mainwindow.cpp

                  #include "mainwindow.h"
                  #include "ui_mainwindow.h"
                  
                  #include <QVideoWidget>
                  #include <QCameraInfo>
                  #include <QCameraViewfinderSettings>
                  #include <QDebug>
                  
                  MainWindow::MainWindow(QWidget *parent) :
                      QMainWindow(parent),
                      ui(new Ui::MainWindow)
                  {
                      ui->setupUi(this);
                      QVideoWidget *videoDisplay = new QVideoWidget;
                      setCentralWidget(videoDisplay);
                  
                      // get a list of available cameras
                      QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
                      // just pick the first
                      if (cameras.size() > 0) {
                          qDebug() << "creating camera from " << cameras.at(0).deviceName() << cameras.at(0).description();
                          m_camera = new QCamera(cameras.at(0));
                          if (m_camera) {
                              m_camera->setViewfinder(videoDisplay);
                              m_camera->setCaptureMode(QCamera::CaptureViewfinder);
                              QCameraViewfinderSettings settings = m_camera->viewfinderSettings();
                              // change resolution to 320x240
                              settings.setResolution(QSize(320,240));
                              m_camera->setViewfinderSettings(settings);
                  
                  
                          }
                      }
                  }
                  
                  MainWindow::~MainWindow()
                  {
                      delete ui;
                  }
                  
                  void MainWindow::on_actionStart_triggered()
                  {
                      if (m_camera) {
                          m_camera->start();
                      }
                  }
                  
                  

                  camtest.pro

                  
                  QT       += core gui multimedia multimediawidgets
                  
                  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                  
                  TARGET = camtest
                  TEMPLATE = app
                  
                  DEFINES += QT_DEPRECATED_WARNINGS
                  SOURCES += \
                          main.cpp \
                          mainwindow.cpp
                  
                  HEADERS += \
                          mainwindow.h
                  
                  FORMS += \
                          mainwindow.ui
                  
                  

                  Mainwindow is just a stock MainWindow with a menu item to start video capture.

                  Let me know if this works.

                  Hasan VaezH Offline
                  Hasan VaezH Offline
                  Hasan Vaez
                  wrote on last edited by Hasan Vaez
                  #24

                  @mranger90
                  Thank you for for taking these times.
                  I think I found the problem.

                  Camera sources uses some codes which is not compatible with some old camera and also with VMWare cams, as it uses some parameters which can not be found in old cams and VMware cams.

                  VMWare cameras use USB 2.0 and 3.0 and can not set as USB 1.1.

                  QCamera has high probability problem with VMWare and also with Cameras with USB 1.1!

                  The finial test is to purchase a new Cam and test it in Linux.

                  I think this problem comes from Hardware and all of my configs are set OK.

                  If the problem become solved by changing a new Cam I should report it as s bug, Cuz some users use their QT written programs in VMWare machines.

                  Would you please tell me whether you test your codes in VMWare or not?

                  Thank and regards.

                  1 Reply Last reply
                  0
                  • mranger90M Offline
                    mranger90M Offline
                    mranger90
                    wrote on last edited by
                    #25

                    Yes, I set this up in a VMWare 12 player last night.
                    Actually, it is very system and camera dependent.
                    For instance, on my low powered home system I MUST set VMWare to use USB 1.1
                    or there will be problems. That is the camera is recognized but not video will be displayed.
                    Also, due to the low capabilities of my system, I do not get a valid display unless the camera is set to 320x240.
                    I really don't believe this is a Qt issue because so much is dependent on the underlying system capabilities, both in hardware and software. Perhaps if you play around with the QViewFinder settings, you may find a combination that works.

                    Hasan VaezH 1 Reply Last reply
                    1
                    • mranger90M mranger90

                      Yes, I set this up in a VMWare 12 player last night.
                      Actually, it is very system and camera dependent.
                      For instance, on my low powered home system I MUST set VMWare to use USB 1.1
                      or there will be problems. That is the camera is recognized but not video will be displayed.
                      Also, due to the low capabilities of my system, I do not get a valid display unless the camera is set to 320x240.
                      I really don't believe this is a Qt issue because so much is dependent on the underlying system capabilities, both in hardware and software. Perhaps if you play around with the QViewFinder settings, you may find a combination that works.

                      Hasan VaezH Offline
                      Hasan VaezH Offline
                      Hasan Vaez
                      wrote on last edited by
                      #26

                      @mranger90
                      Agree, I have tested in windows and the video does not work.

                      1 Reply Last reply
                      0
                      • gfxxG Offline
                        gfxxG Offline
                        gfxx
                        wrote on last edited by
                        #27

                        Sorrry ... I see these olt post only now .... because try to work my app on my hystorical pc with intel I5 4th gen, ubuntu 16.04 update every mouth .... normally for camera pourpuse I use an other pc with ubuntu 16.04 and work well .... these historical pc actually not work with camera.cpp example provided for QT5.10 .... In these pc there are v4l gstreamer mesa opencv etc etc all updated to recent version .... in the past I used modified by me libv4l.so version (or similar one) and my opencv app work on these pc. But I suppose that modified version is updated and rewrite now from software center updater.

                        Any how ... there are another problem similar to your ... and the problem generally become from firmware of camera not from SO. In the past i modified v4l lib because the firmware of camera was not "standard".

                        regards
                        Giorgio

                        bkt

                        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