1 #include "MouseSelect.h"2 3 MouseSelectParams *g_mousep;4 MouseSelect::MouseSelect() {}5 6 MouseSelect::~MouseSelect() {}7 8 void MouseSelect::select_rect(Mat &frame)9 {10 obj_selected = 0;11 while(0 ==obj_selected)12 {13 obj_selected =get_rects(frame);14 if (obj_selected == 0)15 {16 cout<n;111 if (n ==MAX_OBJECTS)112 {113 return;114 }115 prev_pt.x =x;116 prev_pt.y =y;117 //cout<mode)125 {126 n = g_mousep->n;127 if (n ==MAX_OBJECTS)128 {129 return;130 }131 cur_pt.x =x;132 cur_pt.y =y;133 g_mousep->pts.push_back(cur_pt);134 int radius = 3;135 circle(*g_mousep->image,cur_pt,radius,CV_RGB(255,0,0));136 imshow(g_mousep->win_name,*g_mousep->image);137 pressed = false;138 g_mousep->n++;139 }140 /*2 == mode for selecting rectangles*/141 else if (2 == g_mousep->mode)142 {143 n = g_mousep->n;144 if (n ==MAX_OBJECTS)145 {146 return;147 }148 cur_pt.x =x;149 cur_pt.y =y;150 g_mousep->pts.push_back(prev_pt);151 g_mousep->pts.push_back(cur_pt);152 //cout<image,prev_pt,cur_pt,CV_RGB(0,0,255));154 imshow(g_mousep->win_name,*g_mousep->image);155 pressed = false;156 g_mousep->n++;157 }158 else if (3 == g_mousep->mode)159 {160 n = g_mousep->n;161 162 }163 }164 else if (event == CV_EVENT_MOUSEMOVE && pressed &&CV_EVENT_FLAG_LBUTTON)165 {166 if (2 == g_mousep->mode)167 {168 n = g_mousep->n;169 if (n ==MAX_OBJECTS)170 {171 return;172 }173 cur_pt.x =x;174 cur_pt.y =y;175 Mat tmp = (*g_mousep->image).clone();176 //cout<win_name,tmp);179 }180 }181 }
opencv 手选roi区域_【OpenCV】选择ROI区域 – 一点心青
最新推荐文章于 2023-04-10 14:29:05 发布