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. I want to crop a selected a rectangle area in live video feed and save those area or image in my local drive
Forum Updated to NodeBB v4.3 + New Features

I want to crop a selected a rectangle area in live video feed and save those area or image in my local drive

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 2 Posters 8.2k 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.
  • R robotsandi

    @mrjj Plese help me.

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #11

    @robotsandi
    well i dont know for sure.
    I think you have to use a
    http://doc.qt.io/qt-5/qcameraimagecapture.html#details
    to get an image.
    But why not just copy from what ever is on screen ?
    Do you also need image first?

    R 1 Reply Last reply
    0
    • mrjjM mrjj

      @robotsandi
      well i dont know for sure.
      I think you have to use a
      http://doc.qt.io/qt-5/qcameraimagecapture.html#details
      to get an image.
      But why not just copy from what ever is on screen ?
      Do you also need image first?

      R Offline
      R Offline
      robotsandi
      wrote on last edited by
      #12

      @mrjj
      mCamera->setCaptureMode(QCameraImageCapture::CaptureToBuffer);
      how to stope image to use this code

      mrjjM 1 Reply Last reply
      0
      • R robotsandi

        @mrjj
        mCamera->setCaptureMode(QCameraImageCapture::CaptureToBuffer);
        how to stope image to use this code

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #13

        Hi
        I think you just connect image capture to it
        imageCapture = new QCameraImageCapture(camera);
        and hook up to
        http://doc.qt.io/qt-5/qcameraimagecapture.html#imageCaptured
        to get signal and image when its ready

        R 1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #14

          Hi
          maybe this sample is good start ?
          http://doc.qt.io/qt-5/qtmultimedia-multimediawidgets-camera-example.html

          It can grab photo.

          1 Reply Last reply
          1
          • mrjjM mrjj

            Hi
            I think you just connect image capture to it
            imageCapture = new QCameraImageCapture(camera);
            and hook up to
            http://doc.qt.io/qt-5/qcameraimagecapture.html#imageCaptured
            to get signal and image when its ready

            R Offline
            R Offline
            robotsandi
            wrote on last edited by
            #15

            @mrjj
            Hi
            I have 4 coordinate (x1, y1, x2, y2)
            (x1, y1) is for press mouse button or (x2, y2) for release mouse button
            how can i fine height and weight.
            please, can you explain me:

            mrjjM 1 Reply Last reply
            0
            • R robotsandi

              @mrjj
              Hi
              I have 4 coordinate (x1, y1, x2, y2)
              (x1, y1) is for press mouse button or (x2, y2) for release mouse button
              how can i fine height and weight.
              please, can you explain me:

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #16

              @robotsandi
              Well you can just cheat
              QRect area( x1,y1,x2,y2 ) ;
              ( or as QPoint if you have that QRect area( p1, p2 ) )
              then you can just ask it

              area.width()
              area.height()

              else its
              int w= x2 - x1;
              int h=y2-y1;

              R 1 Reply Last reply
              0
              • mrjjM mrjj

                @robotsandi
                Well you can just cheat
                QRect area( x1,y1,x2,y2 ) ;
                ( or as QPoint if you have that QRect area( p1, p2 ) )
                then you can just ask it

                area.width()
                area.height()

                else its
                int w= x2 - x1;
                int h=y2-y1;

                R Offline
                R Offline
                robotsandi
                wrote on last edited by
                #17

                @mrjj
                How to save image
                int width = x2-x1;
                int height = y2-y1;
                QPixmap original("mCameraImageCapture");
                //QPixmap cropped = original.copy(rect);
                QPixmap cropped = original.copy(x1, y1, width, height);

                R 1 Reply Last reply
                0
                • R robotsandi

                  @mrjj
                  How to save image
                  int width = x2-x1;
                  int height = y2-y1;
                  QPixmap original("mCameraImageCapture");
                  //QPixmap cropped = original.copy(rect);
                  QPixmap cropped = original.copy(x1, y1, width, height);

                  R Offline
                  R Offline
                  robotsandi
                  wrote on last edited by
                  #18

                  @robotsandi
                  mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
                  QImageEncoderSettings imageEncoderSettings;
                  imageEncoderSettings.setCodec("imag/jpeg");
                  imageEncoderSettings.setResolution(1600,1200);
                  mCameraImageCapture->setEncodingSettings(imageEncoderSettings);

                  mrjjM 1 Reply Last reply
                  0
                  • R robotsandi

                    @robotsandi
                    mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
                    QImageEncoderSettings imageEncoderSettings;
                    imageEncoderSettings.setCodec("imag/jpeg");
                    imageEncoderSettings.setResolution(1600,1200);
                    mCameraImageCapture->setEncodingSettings(imageEncoderSettings);

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #19

                    .setCodec("imag/jpeg");

                    Is that correct?
                    Seems to miss an e

                    R 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      .setCodec("imag/jpeg");

                      Is that correct?
                      Seems to miss an e

                      R Offline
                      R Offline
                      robotsandi
                      wrote on last edited by
                      #20

                      @mrjj
                      yes this is correct

                      R 1 Reply Last reply
                      0
                      • R robotsandi

                        @mrjj
                        yes this is correct

                        R Offline
                        R Offline
                        robotsandi
                        wrote on last edited by
                        #21

                        @robotsandi
                        Is that correct
                        mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
                        to mCameraImage Capture is store image in buffer??

                        R 1 Reply Last reply
                        0
                        • R robotsandi

                          @robotsandi
                          Is that correct
                          mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
                          to mCameraImage Capture is store image in buffer??

                          R Offline
                          R Offline
                          robotsandi
                          wrote on last edited by
                          #22

                          @robotsandi
                          QPixmap original("mCameraImageCapture");
                          QPixmap cropped = original.copy(x1, y1, width, height);
                          cropped.save(filename);
                          is pic is not save

                          1 Reply Last reply
                          0
                          • mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #23

                            Yes it think its ok.
                            But not used in sample so might not be needed.
                            They just setup
                            imageCapture = new QCameraImageCapture(camera);
                            and hook up signal
                            connect(imageCapture, &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage);
                            and then do

                            void Camera::processCapturedImage(int requestId, const QImage& img)
                            {
                                Q_UNUSED(requestId);
                                QImage scaledImage = img.scaled(ui->viewfinder->size(),
                                                                Qt::KeepAspectRatio,
                                                                Qt::SmoothTransformation);
                            
                                ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage));
                            
                                // Display captured image for 4 seconds.
                                displayCapturedImage();
                                QTimer::singleShot(4000, this, &Camera::displayViewfinder);
                            }
                            
                            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