2014-12-26 50 views
0

嘿,夥計們!我試圖在OpenCV中連續處理大數據。這裏是我的代碼:如何在OpenCV中連續處理大數據

vector<Point2f> up_imagePoints; 
vector<Point2f> left_imagePoints; 
vector<Point2f> right_imagePoints; 

Mat frame1_silhouette; 
Mat frame2_silhouette; 
Mat frame3_silhouette; 

Mat frame1_reconstruction; 
Mat frame2_reconstruction; 
Mat frame3_reconstruction; 

for (int i = 0; i < 16777216; ++i){ 
     //check point range 
     if (up_imagePoints[i].x >= col_bound || up_imagePoints[i].y >= row_bound) { 
      coor_test = 1;} 
     else if (left_imagePoints[i].x >= col_bound || left_imagePoints[i].y >= row_bound) { 
      coor_test = 1;} 
     else if (right_imagePoints[i].x >= col_bound || right_imagePoints[i].y >= row_bound) { 
      coor_test = 1;} 
     //check silhouette 
     if (coor_test == 0) { 
      if (frame1_silhouette.at<uchar>((cvFloor(up_imagePoints[i].x)),(cvFloor(up_imagePoints[i].y))) == 255) 
       value_test = 1; 
      else if (frame2_silhouette.at<uchar>((cvFloor(left_imagePoints[i].x)),(cvFloor(left_imagePoints[i].y))) == 255) 
       value_test = 1; 
      else if (frame3_silhouette.at<uchar>((cvFloor(right_imagePoints[i].x)),(cvFloor(right_imagePoints[i].y))) == 255) 
       value_test = 1; 

      if (value_test == 0) { 
       frame1_reconstruction.at<uchar>((cvFloor(up_imagePoints[i].x)),(cvFloor(up_imagePoints[i].y))) = 255; 
       frame2_reconstruction.at<uchar>((cvFloor(left_imagePoints[i].x)),(cvFloor(left_imagePoints[i].y))) = 255; 
       frame3_reconstruction.at<uchar>((cvFloor(right_imagePoints[i].x)),(cvFloor(right_imagePoints[i].y))) = 255;} 
      } 

     value_test = 0; 
     coor_test = 0; 
     cout<<"round "<<i<<endl; 
     } 

的up_iamgePoints,left_imagePoints的大小和right_imagePoints是1x16777216。它們包含圖像的座標。 framex_silhouette和framex_reconstruction的尺寸480×640

有三個步驟:

  1. 檢查x_imagePoints的座標是否在該範圍內:col_bound(640)和row_bound(480)
  2. 檢查是否相同的位置framex_silhouette的都是255
  3. 應用255從步驟2中的位置,以framex_reconstruction

該程序總是在故障不同的狀態,就像當我==什麼時候知道如何在OpenCV中連續處理大數據而沒有錯誤?

+0

'z'索引用於什麼?爲什麼你永遠不會初始化'我'? – berak

+0

@berak,我已經重新編寫了明確的解釋代碼。 'x','y','z'索引用於解釋一個大體素 – oilpig

回答

0

您有圖像480(行)x 640(cols),但您嘗試從Mat.at<uchar>(colNumber, rowNumber)獲取Mat值。在某個點Mat::at()將拋出一個錯誤,因爲您將嘗試獲得超出Mat範圍的值。

+0

我在此之前檢查了座標的範圍。如果座標位於Mat邊界之外,則coor_test將變爲1. – oilpig

+0

但您正在錯誤地檢查它們:您正在使用的ROWS座標是您正在驗證的COLUMNS邊界,以及您正在使用的COLUMNS您正在爲ROWS邊界進行驗證。要從Mat獲得值,您必須使用ROWS,COLS座標系。這就是你在不同的地方得到錯誤的原因,因爲許多這種顛倒的座標在Mat界限中是正確的。 – Amadeusz