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. Help capturing an image

Help capturing an image

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 4 Posters 4.0k 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.
  • J Offline
    J Offline
    John1123
    wrote on last edited by
    #7

    Ok, ill look into emitting the image that it captures, but I still have the problem where capture() wont capture an image

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

      Did you try to save the image in a file to see how it looks ?

      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
      • J Offline
        J Offline
        John1123
        wrote on last edited by John1123
        #9

        An image can't be captured in the first place, whenever I call capture it redirects to readyForCapture and isReadyForCapture changes from true to false. This also applies to captureToFile()

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

          Which version of Qt are you using ?
          On which OS ?
          With which device ?

          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
          • J Offline
            J Offline
            John1123
            wrote on last edited by
            #11

            I'm running QT on 6.6.3, I'm on windows, and I'm using my webcam

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

              Which version of Windows ?
              What is the model of your webcam ?

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

                my webcam is a Logi C615 HD WebCam, and im on windows 10

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

                  Can you check again with 6.7 ?

                  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
                  • J Offline
                    J Offline
                    John1123
                    wrote on last edited by
                    #15

                    I've checked again in 6.7 and it still doesn't work.

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

                      Ok, then can you switch the backend to use the native rather than ffmpeg ?

                      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
                      • J Offline
                        J Offline
                        John1123
                        wrote on last edited by
                        #17

                        How would I do that?

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

                          It's described here.

                          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
                          1
                          • J Offline
                            J Offline
                            John1123
                            wrote on last edited by John1123
                            #19

                            So I've tried it, and now isReadyForCapture doesn't change to false after capture() is called but it still doesn't capture an image

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

                              Can you provide a minimal compilable example that shows this behaviour ?

                              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
                              • J Offline
                                J Offline
                                John1123
                                wrote on last edited by John1123
                                #21

                                Sorry for the late reply but I'm unable to provide a minimal example. I've been digging around though and it seems to always crash after the signal imageAvailable(int id, const QVideoFrame &frame). I don't really know why that happens. I tried to do an
                                auto image = frame.toImage();
                                but this always crashes as well. I've looked into the camera example thats proved and in there it works fine

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

                                  Then I would compare what is done differently in your application based on the 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
                                  • J Offline
                                    J Offline
                                    John1123
                                    wrote on last edited by John1123
                                    #23

                                    Yeah I did that and mine looks like it should work. After looking some more though whenever I debug I get this error I do the frame.toImage().
                                    Exception at 0x7ffa5092469e, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)

                                    I saw online that this happens when it tries to access an invalid address but I don't see how this happens for me. This is how I have my imageAvailable

                                    void VideoCapture::imageAvailable(int id, const QVideoFrame &frame){
                                    QVideoFrame frame2(frame);
                                    frame2.map(QVideoFrame::ReadOnly);
                                    if (frame2.isValid())
                                    {
                                    qDebug() << "\n" << "frame2 is valid!\n";
                                    }
                                    else
                                    qDebug() << "\n" << "frame2 is NOT valid!\n";

                                    if (frame2.isReadable())
                                    {
                                        qDebug() << "\n" <<  "frame2 is readable!\n";
                                    }
                                    else
                                        qDebug() << "\n" <<  "frame2 is NOT readable!\n";
                                    
                                    if (frame2.isMapped())
                                    {
                                        qDebug() << "\n" <<  "frame2 is mapped!\n";
                                    }
                                    else
                                        qDebug() << "\n" <<  "frame2 is NOT mapped!\n";
                                    qDebug() << "\n" <<  "frame2 map mode : " << frame2.mapMode() << "\n";
                                    qDebug() << "\n" <<  "frame2 plane count : " << frame2.planeCount() << "\n";
                                    qDebug() << "\n" <<  "frame2 size : " << frame2.size() << "\n";
                                    qDebug() << "\n" <<  "frame2 pixelFormat : " << frame2.pixelFormat() << "\n";
                                    qDebug() << "\n" <<  "frame2 mappedBytes_0 : " << frame2.mappedBytes(0) << "\n";
                                    qDebug() << "\n" <<  "frame2 mappedBytes_1 : " << frame2.mappedBytes(1) << "\n";
                                    qDebug() << "\n" <<  "frame2 mappedBytes_2 : " << frame2.mappedBytes(2) << "\n";
                                    qDebug() << "\n" <<  "frame2 handleType : " << frame2.handleType() << "\n";
                                    qDebug() << "\n" <<  "frame: " << frame << "\n";
                                    qDebug() << "\n" <<  "frame2: " << frame2 << "\n";
                                    

                                    qDebug() << "\n" << "before conversion\n";
                                    frame2.toImage();
                                    qDebug() << "\n" << "after conversion\n";

                                    }

                                    the printout says that its valid, readable, it mapped, map mode is 1, plane count is 2, size is 1980X1080, pixel format is Format_NV12, mapped bytes for 0 is 2073600, mapped bytes for 1 is 1036800, mapped bytes for 2 is 0, no handle.

                                    JonBJ 1 Reply Last reply
                                    0
                                    • J John1123

                                      Yeah I did that and mine looks like it should work. After looking some more though whenever I debug I get this error I do the frame.toImage().
                                      Exception at 0x7ffa5092469e, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)

                                      I saw online that this happens when it tries to access an invalid address but I don't see how this happens for me. This is how I have my imageAvailable

                                      void VideoCapture::imageAvailable(int id, const QVideoFrame &frame){
                                      QVideoFrame frame2(frame);
                                      frame2.map(QVideoFrame::ReadOnly);
                                      if (frame2.isValid())
                                      {
                                      qDebug() << "\n" << "frame2 is valid!\n";
                                      }
                                      else
                                      qDebug() << "\n" << "frame2 is NOT valid!\n";

                                      if (frame2.isReadable())
                                      {
                                          qDebug() << "\n" <<  "frame2 is readable!\n";
                                      }
                                      else
                                          qDebug() << "\n" <<  "frame2 is NOT readable!\n";
                                      
                                      if (frame2.isMapped())
                                      {
                                          qDebug() << "\n" <<  "frame2 is mapped!\n";
                                      }
                                      else
                                          qDebug() << "\n" <<  "frame2 is NOT mapped!\n";
                                      qDebug() << "\n" <<  "frame2 map mode : " << frame2.mapMode() << "\n";
                                      qDebug() << "\n" <<  "frame2 plane count : " << frame2.planeCount() << "\n";
                                      qDebug() << "\n" <<  "frame2 size : " << frame2.size() << "\n";
                                      qDebug() << "\n" <<  "frame2 pixelFormat : " << frame2.pixelFormat() << "\n";
                                      qDebug() << "\n" <<  "frame2 mappedBytes_0 : " << frame2.mappedBytes(0) << "\n";
                                      qDebug() << "\n" <<  "frame2 mappedBytes_1 : " << frame2.mappedBytes(1) << "\n";
                                      qDebug() << "\n" <<  "frame2 mappedBytes_2 : " << frame2.mappedBytes(2) << "\n";
                                      qDebug() << "\n" <<  "frame2 handleType : " << frame2.handleType() << "\n";
                                      qDebug() << "\n" <<  "frame: " << frame << "\n";
                                      qDebug() << "\n" <<  "frame2: " << frame2 << "\n";
                                      

                                      qDebug() << "\n" << "before conversion\n";
                                      frame2.toImage();
                                      qDebug() << "\n" << "after conversion\n";

                                      }

                                      the printout says that its valid, readable, it mapped, map mode is 1, plane count is 2, size is 1980X1080, pixel format is Format_NV12, mapped bytes for 0 is 2073600, mapped bytes for 1 is 1036800, mapped bytes for 2 is 0, no handle.

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by
                                      #24

                                      @John1123 said in Help capturing an image:

                                      Exception at 0x7ffa5092469e, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)

                                      This is a "first chance" exception. So far as I understand it, that is an MSVC-ism and is to be ignored as not relevant. Do you have any other problem/diagnostic other than a first chance exception?

                                      1 Reply Last reply
                                      0
                                      • J Offline
                                        J Offline
                                        John1123
                                        wrote on last edited by
                                        #25

                                        Hi Jon, I don't have any other problem. When I build I don't get anything and when I run with the debugger on, that's the only issue that I have

                                        JonBJ 1 Reply Last reply
                                        0
                                        • J John1123

                                          Hi Jon, I don't have any other problem. When I build I don't get anything and when I run with the debugger on, that's the only issue that I have

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by
                                          #26

                                          @John1123 Then (assuming nothing actually goes wrong) ignore it!

                                          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