如何在OpenCV中持续处理大数据

时间:2014-12-26 04:59:35

标签: c++ opencv vector mat

嘿,伙计们!我正在尝试在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的大小为480x640

有三个步骤:

  1. 检查x_imagePoints的坐标是否在以下范围内:col_bound(640)和row_bound(480)
  2. 检查framex_silhouette的相同位置是否都是255
  3. 将255应用于从步骤2到framex_reconstruction
  4. 的位置

    程序总是以不同的状态失败,例如当i == 1900566

    是否有人知道如何在OpenCV中连续处理大数据而不出错?

1 个答案:

答案 0 :(得分:0)

您有图像480(行)x 640(cols),但您正尝试从Mat.at<uchar>(colNumber, rowNumber)获取Mat值。在某些时候,Mat::at()会抛出错误,因为您将尝试获取超出Mat范围的值。