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. Opencv and drawing roi on mat
Qt 6.11 is out! See what's new in the release blog

Opencv and drawing roi on mat

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.9k 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.
  • X Offline
    X Offline
    x3rv1th
    wrote on last edited by
    #1

    Hi...

    I try to draw a ROI (region of interest) on Mat with QMouseEvent and display it on QLabel.

    Got slot like this :
    @
    void mDisplay::draw_ROI(int& r1,int& r2,QPoint& position, cv::Mat& matsROI)
    {

    cv::Mat matfROI;
    matsROI.copyTo(matfROI);
    
    cv::Rect rectang = cv::Rect(r1,r2,position.x()-r1,position.y()-r2);
    cv::rectangle(matfROI,rectang,cv::Scalar(0,255,0),1,8,0);
    
    this->ShowMat(matfROI);
    
    matfROI.release();
    

    }

    @

    When mouseMoveEvent is triggered it emits signal with position of left button click (int& r1,int& r2) which works perfect,actual cursor position (QPoint& position) and matrix with picture (cv::Mat& matsRoi).All of that works great.
    The only problem is,that when I move cursor over QLabel, rectangle is drawn on same image which results in many rectangles.
    Shouldn't matfROI be copied again on every mouse move?

    I also declared int test = 0 just under declaration of matsROI and added to this slot
    @
    int c = test;

    c+=5;

    qDebug()<<c<<endl;
    @

    and it always shows 5 as expected,so why mat is not copied on each mouse move?

    PS. Tried to place this piece of code directly in mouseMoveEvent,but got same issue.

    Thanks in advance!

    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