Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Opencv and drawing roi on mat
x3rv1th last edited by
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;
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!