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. QT + OPENCV Label Pixmap
Forum Updated to NodeBB v4.3 + New Features

QT + OPENCV Label Pixmap

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.3k 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.
  • S Offline
    S Offline
    Stevendragoes
    wrote on 24 Feb 2020, 09:03 last edited by
    #1

    Hello all again. I have a webcamera which gives in input and i used OpenCV to draw the frames and show in one label (Did the conversions and etc). I want to filter Blue colors from the webcam and display in another Label. However, pixmap overrides whenever i try to move. I use it in a slot to update every QTimer Count.
    Heres the code.

    onlinecam >> onlineframes;
            currframes = QString::number(currframe);
            cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV);
            cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask);
            cv::bitwise_and(onlineframes, onlineframes ,res, mask);
            cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB);
            //ui->textEdit->append("Current Frame: " + currframes);
            cv::cvtColor(onlineframes,  onlineframes, cv::COLOR_BGR2RGB);
            
            // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA);
            QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888);
            QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888);
            ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image));
            
            ui->image_display->setPixmap(QPixmap::fromImage(imdisplay));
    

    The resulting video looks like this.
    ac819eed-22ad-423f-992f-8a3d24af518f-image.png

    I stopped the video cam because I don't want to show my picture. and I have a blue pen and waved around the camera. However, the resulting filtered image just overrides the previous pixmap that is set. Any Idea how to solve it?

    P 1 Reply Last reply 24 Feb 2020, 14:00
    0
    • S Offline
      S Offline
      Stevendragoes
      wrote on 26 Feb 2020, 05:58 last edited by
      #6

      @Pl45m4 @mrdebug I have solved it by using setTo. Turns out it was an opencv issue

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrdebug
        wrote on 24 Feb 2020, 10:17 last edited by
        #2

        Sorry but it is not clear, maybe my english is not so fluent.
        Do you want to merge more images in one?

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        S 1 Reply Last reply 26 Feb 2020, 03:17
        0
        • S Stevendragoes
          24 Feb 2020, 09:03

          Hello all again. I have a webcamera which gives in input and i used OpenCV to draw the frames and show in one label (Did the conversions and etc). I want to filter Blue colors from the webcam and display in another Label. However, pixmap overrides whenever i try to move. I use it in a slot to update every QTimer Count.
          Heres the code.

          onlinecam >> onlineframes;
                  currframes = QString::number(currframe);
                  cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV);
                  cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask);
                  cv::bitwise_and(onlineframes, onlineframes ,res, mask);
                  cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB);
                  //ui->textEdit->append("Current Frame: " + currframes);
                  cv::cvtColor(onlineframes,  onlineframes, cv::COLOR_BGR2RGB);
                  
                  // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA);
                  QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888);
                  QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888);
                  ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image));
                  
                  ui->image_display->setPixmap(QPixmap::fromImage(imdisplay));
          

          The resulting video looks like this.
          ac819eed-22ad-423f-992f-8a3d24af518f-image.png

          I stopped the video cam because I don't want to show my picture. and I have a blue pen and waved around the camera. However, the resulting filtered image just overrides the previous pixmap that is set. Any Idea how to solve it?

          P Offline
          P Offline
          Pl45m4
          wrote on 24 Feb 2020, 14:00 last edited by Pl45m4
          #3

          @Stevendragoes

          So the problem is, that you get the blue parts from your previous frame in your current and next frame?!
          Try to clear your cv::Mat onlineframes before setting new data to pixmap.

                  // This might work or else try to fill with zeros if it doesnt work 
                  onlineframes.release();
                  
                  // then populate cv::Mat with current frame data
                  onlinecam >> onlineframes;
                 
                  currframes = QString::number(currframe);
                  cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV);
                  cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask);
                  cv::bitwise_and(onlineframes, onlineframes ,res, mask);
                  cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB);
                  //ui->textEdit->append("Current Frame: " + currframes);
                  cv::cvtColor(onlineframes,  onlineframes, cv::COLOR_BGR2RGB);
                  
                  // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA);
                  QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888);
                  QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888);
                  ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image));
          

          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          S 1 Reply Last reply 26 Feb 2020, 03:16
          0
          • P Pl45m4
            24 Feb 2020, 14:00

            @Stevendragoes

            So the problem is, that you get the blue parts from your previous frame in your current and next frame?!
            Try to clear your cv::Mat onlineframes before setting new data to pixmap.

                    // This might work or else try to fill with zeros if it doesnt work 
                    onlineframes.release();
                    
                    // then populate cv::Mat with current frame data
                    onlinecam >> onlineframes;
                   
                    currframes = QString::number(currframe);
                    cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV);
                    cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask);
                    cv::bitwise_and(onlineframes, onlineframes ,res, mask);
                    cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB);
                    //ui->textEdit->append("Current Frame: " + currframes);
                    cv::cvtColor(onlineframes,  onlineframes, cv::COLOR_BGR2RGB);
                    
                    // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA);
                    QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888);
                    QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888);
                    ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image));
            
            S Offline
            S Offline
            Stevendragoes
            wrote on 26 Feb 2020, 03:16 last edited by
            #4

            @Pl45m4 Hello, Yes i get the problem of the previous frame existing in my current frame. Maybe filling it with zeros will do the trick I am still trying to figure it out

            1 Reply Last reply
            0
            • M mrdebug
              24 Feb 2020, 10:17

              Sorry but it is not clear, maybe my english is not so fluent.
              Do you want to merge more images in one?

              S Offline
              S Offline
              Stevendragoes
              wrote on 26 Feb 2020, 03:17 last edited by
              #5

              @mrdebug No no. I have the problem of my previous frames exisiting in my current frame.
              Hence, I got these movement frames

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Stevendragoes
                wrote on 26 Feb 2020, 05:58 last edited by
                #6

                @Pl45m4 @mrdebug I have solved it by using setTo. Turns out it was an opencv issue

                1 Reply Last reply
                0

                1/6

                24 Feb 2020, 09:03

                • Login

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