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 switches not to Active State
Qt 6.11 is out! See what's new in the release blog

QCamera switches not to Active State

Scheduled Pinned Locked Moved Unsolved General and Desktop
camera
14 Posts 3 Posters 7.5k Views 2 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.
  • Andy314A Offline
    Andy314A Offline
    Andy314
    wrote on last edited by Andy314
    #1

    I have Windows-Desktop program which work on the PC an some tablets. Now I have an other tablet and cannot take photos with it.

    The problem is that the camera switches not to active state.
    I get only Loaded and Starting Status, but in the docu I read.

    [slot] void QCamera::start()
    Starts the camera.
    State is changed to QCamera::ActiveState if camera is started successfully, otherwise error() signal is emitted.
    While the camera state is changed to QCamera::ActiveState, starting the camera service can be asynchronous with the actual status reported with QCamera::status property.

    I have conneted the error slot of the camera, but I get no signal.

    With a connected USB-Webcam all works correct!

    What can be the problem with the internal camera ?

    PS. The System ist Windows 10, 64-bit, Qt 5.6.0.
    Must I active some user-rights for the camera maybe?

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

      Hi,

      Maybe a silly question, but is it working correctly outside of Qt ?

      Can you give more information about the hardware you have ?

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

      Andy314A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Maybe a silly question, but is it working correctly outside of Qt ?

        Can you give more information about the hardware you have ?

        Andy314A Offline
        Andy314A Offline
        Andy314
        wrote on last edited by
        #3

        Hi @SGaist ,
        the camera works with the store Camera app from Microsoft and with some camera desktop programs.
        May be I found a correlation. For my tested tablets, Qt works always with camera connected via USB, external or internal (you can see it in the devicemanger under driver.)
        All cameras internal connected (how ever the producer made this) do not work!

        Any ideas ?

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

          What does the device manager say about the internal camera ?

          What do you get if you list all available cameras from Qt ?

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

          Andy314A 1 Reply Last reply
          0
          • SGaistS SGaist

            What does the device manager say about the internal camera ?

            What do you get if you list all available cameras from Qt ?

            Andy314A Offline
            Andy314A Offline
            Andy314
            wrote on last edited by Andy314
            #5

            Hello @SGaist,

            In the device-manger I see under Image-Processings (translation from German) the Intel(R) Imaging Signal-Projessor 2400.
            When I scan with Qt I get 2 camera names.
            Tablet 1:
            HM 2056Front and HM 2056Rear
            Tablet 2:
            IMX175 and OV27200

            This differs indeed from the name in the device-manager. So I dont see the real camera name here, especialy the 2 camera names for front and rear, in the device manager.

            This differs complete for a USB connected camera - here I see in the device manager the same name as in Qt.

            But I find under System Devices entries for it.
            Camera Sensor IMX175 and Camera Sensor OV27200.

            Maybe this is the problem. Any ideas to solve the problem ?


            An other thing that I do not understand is the constructor of a QCamera:

            Cam=new QCamera(QByteArray(" Nonsens "), this);
            This gives always a pointer != NULL,
            How can I check if the returned QCamera is valid ?

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

              Because there's no reason for new to return a null pointer. If new would fail it will throw a std::bad_alloc error.

              What I usually do is to follow the QCamera detailed explanation example. Doing so you ensure that you create a valid camera.

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

              Andy314A 1 Reply Last reply
              0
              • SGaistS SGaist

                Because there's no reason for new to return a null pointer. If new would fail it will throw a std::bad_alloc error.

                What I usually do is to follow the QCamera detailed explanation example. Doing so you ensure that you create a valid camera.

                Andy314A Offline
                Andy314A Offline
                Andy314
                wrote on last edited by
                #7

                Yes, this is indeed near to my code. I use the CameraInfo to construct the QCamera. Nevertheless I tested with the QByteArray in the constructor. This should work too but
                it gives for every nonsens-camera name a valid pointer. This confused me.
                Is there a way to check if the constructed QCamera is valid?

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

                  That's basic C++: new will create a new object. It has absolutely not reason to return a null pointer. The fact that you are giving random invalid parameter to the constructor has no influence on the functionality of new.

                  For more detailed information, look here.

                  You can always check the error function but I don't think that it will work on a just constructed camera (might be wrong though, test it).

                  As for your application, it's up to you to not allow your users to enter invalid values. Use QCameraInfo::availableCameras to create a list of device name they can access so you ensure that you are always working with supported devices.

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

                  Andy314A 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    That's basic C++: new will create a new object. It has absolutely not reason to return a null pointer. The fact that you are giving random invalid parameter to the constructor has no influence on the functionality of new.

                    For more detailed information, look here.

                    You can always check the error function but I don't think that it will work on a just constructed camera (might be wrong though, test it).

                    As for your application, it's up to you to not allow your users to enter invalid values. Use QCameraInfo::availableCameras to create a list of device name they can access so you ensure that you are always working with supported devices.

                    Andy314A Offline
                    Andy314A Offline
                    Andy314
                    wrote on last edited by
                    #9

                    Yes of course I was a little bit stupid. I was so absorbed from my primary camera problem that I forgot the C++ basics. New MUST give something back if there is enough memory for allocating it.

                    The errorfunction give no error - but it switches not to active state :-( . That seem the only problem ....

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

                      Does it also happen if you use the QCameraInfo matching the device name ?

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

                      Andy314A 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Does it also happen if you use the QCameraInfo matching the device name ?

                        Andy314A Offline
                        Andy314A Offline
                        Andy314
                        wrote on last edited by Andy314
                        #11

                        cam = new QCamera(CamInfos[0], this);
                        This is the code from the integrated Qt example -> does not work on tablet

                        Direct Devicename:
                        QString devname = CamInfos[0].deviceName();
                        Cam= new QCamera(QByteArray(devname.toUtf8()), this);

                        I took this code with converting to Utf8. I get no access on the tablet. Not activated.

                        On my PC with a USB WebCam it works, but it is independent from the device name. For any device name it seem that I get my one and only WebCam. So that I cannot check of if the name converting is correct. Is this a default behaviour of the QCamera - constructor that it picks a camera if the device name does not match?

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

                          AFAIK, it should just get you an invalid camera.

                          So currently, you get both cameras from your tablet listed but none get started properly ?

                          Does it also happen with the QML Camera example ?

                          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
                          • D Offline
                            D Offline
                            Drshaw19
                            wrote on last edited by
                            #13

                            I am seeing this very same issue on a different tablet with the same cameras: Camera Sensor IMX175 and Camera Sensor OV27200. Seeing this issue even with the latest qt bits and still seeing this issue. Did you ever figure this out?

                            Andy314A 1 Reply Last reply
                            0
                            • D Drshaw19

                              I am seeing this very same issue on a different tablet with the same cameras: Camera Sensor IMX175 and Camera Sensor OV27200. Seeing this issue even with the latest qt bits and still seeing this issue. Did you ever figure this out?

                              Andy314A Offline
                              Andy314A Offline
                              Andy314
                              wrote on last edited by
                              #14

                              @Drshaw19
                              No, never solved the problem.
                              I take the standard windows camera now. The communication is a little bit complicated but it works for me.

                              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