aihot  2017-04-27 09:49:19  OpenCV |   查看评论   
  
  •   FileStorage fs;  
  •   // 阅读选项
  •   read_options(argc, argv, capture, fs);  //分析命令行参数  
  •   // 初始摄像头
  •   if (!capture.isOpened())  
  •   {  
  •     cout << "capture device failed to open!" << endl;  
  •     return 1;  
  •   }  
  •   // 注册鼠标回调来绘制边框
  •   cvNamedWindow("TLD",CV_WINDOW_AUTOSIZE);  
  •   cvSetMouseCallback( "TLD", mouseHandler, NULL );  //用鼠标选中初始目标的bounding box  
  •   // TLD框架
  •   TLD tld;  
  •   //Read parameters file  
  •   tld.read(fs.getFirstTopLevelNode());  
  •   Mat frame;  
  •   Mat last_gray;  
  •   Mat first;  
  •   if (fromfile){  //如果指定为从文件读取  
  •       capture >> frame;   //读当前帧  
  •       cvtColor(frame, last_gray, CV_RGB2GRAY);  //转换为灰度图像  
  •       frame.copyTo(first);  //拷贝作为第一帧  
  •   }else{   //如果为读取摄像头,则设置获取的图像大小为320x240   
  •       capture.set(CV_CAP_PROP_FRAME_WIDTH,340);  //340??  
  •       capture.set(CV_CAP_PROP_FRAME_HEIGHT,240);  
  •   }  
  •   
  •   /// 初始化
  • GETBOUNDINGBOX:   //标号:获取bounding box  
  •   while(!gotBB)  
  •   {  
  •     if (!fromfile){  
  •       capture >> frame;  
  •     }  
  •     else  
  •       first.copyTo(frame);  
  •     cvtColor(frame, last_gray, CV_RGB2GRAY);  
  •     drawBox(frame,box);  //把bounding box 画出来  
  •     imshow("TLD", frame);  
  •  

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

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