aihot  2017-04-27 09:49:19  OpenCV |   查看评论   
//istringstream对象可以绑定一行字符串,然后以空格为分隔符把该行分隔开来。  
  •   string x1,y1,x2,y2;  
  •     
  •   //istream& getline ( istream &is , string &str , char delim );   
  •   //将输入流is中读到的字符存入str中,直到遇到终结符delim才结束。  
  •   getline (linestream,x1, ',');  
  •   getline (linestream,y1, ',');  
  •   getline (linestream,x2, ',');  
  •   getline (linestream,y2, ',');  
  •     
  •   //atoi 功 能: 把字符串转换成整型数  
  •   int x = atoi(x1.c_str());// = (int)file["bb_x"];  
  •   int y = atoi(y1.c_str());// = (int)file["bb_y"];  
  •   int w = atoi(x2.c_str())-x;// = (int)file["bb_w"];  
  •   int h = atoi(y2.c_str())-y;// = (int)file["bb_h"];  
  •   box = Rect(x,y,w,h);  
  • }  
  •   
  • //bounding box mouse callback  
  • //鼠标的响应就是得到目标区域的范围,用鼠标选中bounding box。  
  • void mouseHandler(int event, int x, int y, int flags, void *param){  
  •   switch( event ){  
  •   case CV_EVENT_MOUSEMOVE:  
  •     if (drawing_box){  
  •         box.width = x-box.x;  
  •         box.height = y-box.y;  
  •     }  
  •     break;  
  •   case CV_EVENT_LBUTTONDOWN:  
  •     drawing_box = true;  
  •     box = Rect( x, y, 0, 0 );  
  •     break;  
  •   case CV_EVENT_LBUTTONUP:  
  •     drawing_box = false;  
  •     if( box.width < 0 ){  
  •         box.x += box.width;  
  •         box.width *= -1;  
  •     }  
  •     if
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自TLD(Tracking-Learning-Detection)学习与源码理解之(四)

    留言与评论(共有 0 条评论)
       
    验证码:
    [lianlun]1[/lianlun]