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. Error displaying video from the camera

Error displaying video from the camera

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.4k 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.
  • nageshN Offline
    nageshN Offline
    nagesh
    wrote on last edited by
    #4

    @DQUY05 said in Error displaying video from the camera:

    The video surface is not compatible with any format supported by the camera

    There was some discussion regarding this topic.
    https://forum.qt.io/topic/93173/camera-access-in-android-device

    There is Camera example in Qt.

    you also need to check whether mode is supported before calling setCaptureMode using isCaptureModeSupported(QCamera::CaptureViewfinder)

    DQUY05D 1 Reply Last reply
    0
    • nageshN nagesh

      @DQUY05 said in Error displaying video from the camera:

      The video surface is not compatible with any format supported by the camera

      There was some discussion regarding this topic.
      https://forum.qt.io/topic/93173/camera-access-in-android-device

      There is Camera example in Qt.

      you also need to check whether mode is supported before calling setCaptureMode using isCaptureModeSupported(QCamera::CaptureViewfinder)

      DQUY05D Offline
      DQUY05D Offline
      DQUY05
      wrote on last edited by
      #5

      @nagesh said in Error displaying video from the camera:

      @DQUY05 said in Error displaying video from the camera:

      The video surface is not compatible with any format supported by the camera

      There was some discussion regarding this topic.
      https://forum.qt.io/topic/93173/camera-access-in-android-device

      There is Camera example in Qt.

      you also need to check whether mode is supported before calling setCaptureMode using isCaptureModeSupported(QCamera::CaptureViewfinder)

      it has support (ui->inform->setText("with support");)

           const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
           for (const QCameraInfo &cameraInfo : cameras) {
               if (cameraInfo.deviceName() == "back")
               {
                   camera = new QCamera(cameraInfo);
                   if(camera->isCaptureModeSupported(QCamera::CaptureViewfinder))
                   {
                   ui->inform->setText("with support");
                   }
                   viewfinder = new QCameraViewfinder();
                   viewfinder->setMinimumSize( 50, 50 );
                   camera->setCaptureMode(QCamera::CaptureViewfinder);
                   camera->setViewfinder(viewfinder);
                   viewfinder->show();
                   camera->start();
               }
           }
      

      Can you show me how to use the QVideoFrame :: Format_NV21 converter?
      https://forum.qt.io/topic/93173/camera-access-in-android-device

      Many thanks!

      1 Reply Last reply
      0
      • nageshN Offline
        nageshN Offline
        nagesh
        wrote on last edited by
        #6

        @DQUY05 I never used Qmultimedia module..

        check in the below link qt docs..
        https://doc.qt.io/qt-5/android-platform-notes.html
        it says
        The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the Video QML Type.

        DQUY05D 2 Replies Last reply
        1
        • nageshN nagesh

          @DQUY05 I never used Qmultimedia module..

          check in the below link qt docs..
          https://doc.qt.io/qt-5/android-platform-notes.html
          it says
          The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the Video QML Type.

          DQUY05D Offline
          DQUY05D Offline
          DQUY05
          wrote on last edited by
          #7

          @nagesh said in Error displaying video from the camera:

          @DQUY05 I never used Qmultimedia module..

          check in the below link qt docs..
          https://doc.qt.io/qt-5/android-platform-notes.html
          it says
          The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the Video QML Type.

          Thank you !

          I have never written in QML before, but I must try it

          1 Reply Last reply
          0
          • nageshN nagesh

            @DQUY05 I never used Qmultimedia module..

            check in the below link qt docs..
            https://doc.qt.io/qt-5/android-platform-notes.html
            it says
            The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the Video QML Type.

            DQUY05D Offline
            DQUY05D Offline
            DQUY05
            wrote on last edited by
            #8

            @nagesh said in Error displaying video from the camera:

            @DQUY05 I never used Qmultimedia module..

            check in the below link qt docs..
            https://doc.qt.io/qt-5/android-platform-notes.html
            it says
            The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the Video QML Type.

            Hi Mr.
            I tried with QML to get video from camera, rendering on QML is fine, but c ++ has connection but no output image in SLOT, i spend a lot of time but still no result

            .qml

                Camera
                {
                    id: camera
                    objectName: "set_camera"
            
                    imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
            
                    exposure
                    {
                        exposureCompensation: -1.0
                        exposureMode: Camera.ExposurePortrait
                    }
            
                    focus
                    {
                        focusMode: Camera.FocusContinuous
                        focusPointMode: Camera.FocusPointCenter
                    }
            
                    flash.mode: Camera.FlashRedEyeReduction  // giảm hiệu ứng mắt đỏ flash
            
                    imageCapture
                    {
                        onImageCaptured:
                        {
                            photoPreview.source = preview  // Show the preview in an Image
                        }
                    }
            
                }
            
                VideoOutput
                {
                    orientation: 270  // xoay khung camera
                    source: camera
                    anchors.fill: parent
                    focus : false // to receive focus and capture key events when visible
                }
            

            .cpp

                QQmlApplicationEngine engine;
                engine.load(QUrl(QStringLiteral("qrc:/motlan.qml")));
            
                QObject *qmlCamera = engine.rootObjects().at(0)->findChild<QObject*>("set_camera");
                ui->inform->setText(qmlCamera->objectName());  // I test show is fine !
                QCamera *camera1 = qvariant_cast<QCamera*>(qmlCamera->property("mediaObject"));   
            
                probe_.setSource(camera1);
                connect(&probe_,SIGNAL(videoFrameProbed(const QVideoFrame &)),
                                this, SLOT(present(const QVideoFrame &)));
            

            Thanks !

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              Hi,

              What do you mean by "no output image in slot" ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              DQUY05D 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                What do you mean by "no output image in slot" ?

                DQUY05D Offline
                DQUY05D Offline
                DQUY05
                wrote on last edited by
                #10

                @SGaist said in Error displaying video from the camera:

                Hi,

                What do you mean by "no output image in slot" ?

                Yes, I mean I don't get a signal or signal that is not in QVideoFrame format, or when I switch to Widget environment, qml is disabled when win.show():

                int main(int argc, char *argv[])
                {
                    QApplication a(argc, argv);
                    MainWindow win;
                
                    QQmlApplicationEngine engine;
                    engine.load(QUrl(QStringLiteral("qrc:/motlan.qml")));
                
                    QTest::qWait(5000);
                
                    win.show();
                    return a.exec();
                }
                

                Many thanks!

                W 1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  It looks like you are trying to do some strange mix.

                  What is your exact goal with your application ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  DQUY05D 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    It looks like you are trying to do some strange mix.

                    What is your exact goal with your application ?

                    DQUY05D Offline
                    DQUY05D Offline
                    DQUY05
                    wrote on last edited by
                    #12

                    @SGaist said in Error displaying video from the camera:

                    It looks like you are trying to do some strange mix.

                    What is your exact goal with your application ?

                    My aim is to get video from camera using Qml, then pass real-time VideoFrame into Ui :: MainWindow widget, (because I tried a lot of different ways to get Video Camera on Ui :: MainWindow widget but failed)
                    To me this is very important, I am stuck !

                    Thanks!

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      If you use a QQuickWidget properly you'll have your QtQuick interface show in your QMainWindow.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • DQUY05D DQUY05

                        @SGaist said in Error displaying video from the camera:

                        Hi,

                        What do you mean by "no output image in slot" ?

                        Yes, I mean I don't get a signal or signal that is not in QVideoFrame format, or when I switch to Widget environment, qml is disabled when win.show():

                        int main(int argc, char *argv[])
                        {
                            QApplication a(argc, argv);
                            MainWindow win;
                        
                            QQmlApplicationEngine engine;
                            engine.load(QUrl(QStringLiteral("qrc:/motlan.qml")));
                        
                            QTest::qWait(5000);
                        
                            win.show();
                            return a.exec();
                        }
                        

                        Many thanks!

                        W Offline
                        W Offline
                        WXJ0620
                        wrote on last edited by
                        #14

                        @DQUY05 I had the same problem. Have you solved it now?Thanks

                        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