aihot  2017-04-27 09:27:31  OpenCV |   查看评论   
int random = rng.uniform(0, 9);  
  •   
  •                  row = i + c_yoff[random];  
  •                  if (row < 0)   
  •                      row = 0;  
  •                  if (row >= _image.rows)  
  •                      row = _image.rows - 1;  
  •   
  •                  col = j + c_xoff[random];  
  •                  if (col < 0)   
  •                      col = 0;  
  •                  if (col >= _image.cols)  
  •                      col = _image.cols - 1;  
  •   
  •                  m_samples[k].at<uchar>(i, j) = _image.at<uchar>(row, col);  
  •              }  
  •         }  
  •     }  
  • }  
  •   
  • /**************** Test a new frame and update model ********************/  
  • void ViBe_BGS::testAndUpdate(const Mat _image)  
  • {  
  •     RNG rng;  
  •   
  •     for(int i = 0; i < _image.rows; i++)  
  •     {  
  •         for(int j = 0; j < _image.cols; j++)  
  •         {  
  •             int matches(0), count(0);  
  •             float dist;  
  •   
  •             while(matches < MIN_MATCHES && count < NUM_SAMPLES)  
  •             {  
  •                 dist = abs(m_samples[count].at<uchar>(i, j) - _image.at<uchar>(i, j));  
  •                 if (dist < RADIUS)  
  •                     matches++;  
  •                 count++;  
  •             }  
  •   
  •             if (matches >= MIN_MATCHES)  
  •             {  
  •                 // It is a background pixel  
  •                 m_foregroundMatchCount.at<uchar>(i, j) = 0;  
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自运动检测(前景检测)之(一)ViBe

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