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. Camera example problem
Forum Updated to NodeBB v4.3 + New Features

Camera example problem

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.7k 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.
  • Q Offline
    Q Offline
    Quadlers
    wrote on last edited by
    #1

    Hi everyone !

    In the past few weeks i have attempted to modify the "camera" example in QT. My aim is to create a function which is activated when a button is clicked and it is used to take a series of photos in sequential order. Each photo must be divided by a precise interval of time. In order to do this i inserted the imageCapture->capture( "destination ") comand in a for cycle, the problem however is that the function only saves one photo (obviously each photo has a different name). Could anyone explain why, and how to save multiple pictures using a single function.

    this is an example of the code (added to camera.cpp) :

    @
    void Camera::on_pushButton_clicked()
    {
    for(int i=0;i<5;i++)
    {

        camera->searchAndLock();
    
      imageCapture->capture("destination\\Img"+QString::number(i)+".png");
    
        camera->unlock();
    
     // configureImageSettings(); if I add this function , taht it opens an an outside window,  the camera takes multiple images, but i have to close the windows every time...but i don't konw why it work in this way
    
     }
    

    }
    @

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

      Hi and welcome to devnet,

      From a quick look at the QCameraImageCapture class, the capture call is generally asynchronous so you might be currently asking to capture to "quickly". You should maybe wait until imageSaved has been emitted before trying to capture again.

      Hope it helps

      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
      • Q Offline
        Q Offline
        Quadlers
        wrote on last edited by
        #3

        Hi thank you very much !

        I tried again, but without results.. this time I read this :

        It's permissible to call capture() while the camera status is QCamera::ActiveStatus regardless of isReadyForCapture property value.

        So i checked my camera status..and it is all the time set to QCamera::UnavailableStatus..I thought it was the reason of my problem...

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

          You should also check QCamera's errorString value

          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
          • Q Offline
            Q Offline
            Quadlers
            wrote on last edited by
            #5

            I tryed in a different way and it works..finally :D Thank you very much !!!
            this is the code :

            @void Camera::on_pushButton_clicked()
            {

            int foto=8;//number of pictures
            int Nf=0;//cnt

            QImage Im;

            while(true){

                 if(Nf==foto)break;
            
            
            
                 camera->searchAndLock();
            
               
                 Im=ui->viewfinder->grab().toImage();
                 Im.save("destination\\Img"+QString::number(Nf)+".png");
            
                 camera->unlock();
            
               Nf++;
            

            delay();// personal function
            }

             Nf=0;
            

            }@

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

              While working, I'm not sure you are getting the full-scale image

              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

              • Login

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