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

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 9.6k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    something with
    http://doc.qt.io/qt-5/qrubberband.html
    and maybe
    https://doc-snapshots.qt.io/qt5-dev/qpixmap.html#copy

    1 Reply Last reply
    0
    • R Offline
      R Offline
      robotsandi
      wrote on last edited by
      #3

      You have any example

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

        Hi
        The docs for rubberband shows how to use it.

        copy just returns copy
        so its just
        QPixmap area=orgpix->copy ( rect from rubberband );
        you can see here
        https://stackoverflow.com/questions/7010611/how-can-i-crop-an-image-in-qt

        for the video part , this might help
        http://omg-it.works/how-to-grab-video-frames-directly-from-qcamera/#acceptLicense

        1 Reply Last reply
        0
        • R Offline
          R Offline
          robotsandi
          wrote on last edited by
          #5

          Hi
          QRect rect(10, 20, 30, 40);
          QPixmap original('image.png');
          QPixmap cropped = original.copy(rect);
          the following code is working on image how i can put video in place of image

          mrjjM 1 Reply Last reply
          1
          • R robotsandi

            Hi
            QRect rect(10, 20, 30, 40);
            QPixmap original('image.png');
            QPixmap cropped = original.copy(rect);
            the following code is working on image how i can put video in place of image

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

            @robotsandi
            Is it from a camera?

            1 Reply Last reply
            0
            • R Offline
              R Offline
              robotsandi
              wrote on last edited by
              #7

              i am also able to stop the camera and can i store that image in buffer to use those image.

              mrjjM 1 Reply Last reply
              0
              • R robotsandi

                i am also able to stop the camera and can i store that image in buffer to use those image.

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

                @robotsandi
                Ok if you already can grab images, you simply load it with full path from where you store it
                or simply display it in QLabel ( as pixmap) and use rubberband to grab the area. ( or fixed in code if only needing that)
                Or if you can just stop the video and it still displays last image, then directly on that.

                R 1 Reply Last reply
                0
                • mrjjM mrjj

                  @robotsandi
                  Ok if you already can grab images, you simply load it with full path from where you store it
                  or simply display it in QLabel ( as pixmap) and use rubberband to grab the area. ( or fixed in code if only needing that)
                  Or if you can just stop the video and it still displays last image, then directly on that.

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

                  @mrjj
                  yes, i just stop the video and it still displays the last image,
                  but how can i directly it

                  void MainWindow::on_pushButton_clicked()
                  {
                  mCamera->setViewfinder(mCameraViewfinder);
                  mLayout->addWidget(mCameraViewfinder);
                  mLayout->setMargin(0);
                  ui->scrollArea->setLayout(mLayout);
                  mCamera->start();
                  }

                  void MainWindow::on_pushButton_2_clicked()
                  {
                  mCamera->stop();
                  }

                  R 1 Reply Last reply
                  0
                  • R robotsandi

                    @mrjj
                    yes, i just stop the video and it still displays the last image,
                    but how can i directly it

                    void MainWindow::on_pushButton_clicked()
                    {
                    mCamera->setViewfinder(mCameraViewfinder);
                    mLayout->addWidget(mCameraViewfinder);
                    mLayout->setMargin(0);
                    ui->scrollArea->setLayout(mLayout);
                    mCamera->start();
                    }

                    void MainWindow::on_pushButton_2_clicked()
                    {
                    mCamera->stop();
                    }

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

                    @mrjj Plese help me.

                    mrjjM 1 Reply Last reply
                    0
                    • 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

                                          • Login

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