【问题标题】:How to process big data continuously in OpenCV如何在 OpenCV 中连续处理大数据
【发布时间】:2014-12-26 04:59:34
【问题描述】:

嘿,伙计们!我正在尝试在 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 的位置

程序总是在不同的状态下失败,比如 i == 1900566

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

【问题讨论】:

  • 'z' 索引是做什么用的?为什么你从不初始化 'i' ?
  • @berak,我重新编辑了代码以获得清晰的解释。 'x','y','z'索引用于解释大体素

标签: c++ opencv vector mat


【解决方案1】:

您有 480(行)x 640(列)的图像,但您正试图从 Mat.at&lt;uchar&gt;(colNumber, rowNumber) 获取 Mat 值。在某些时候Mat::at() 会抛出一个错误,因为你会尝试获取一个超出Mat 界限的值。

【讨论】:

  • 我在此之前检查了坐标范围。如果坐标在 Mat 边界之外,则 coor_test 将变为 1。
  • 但是您检查它们不正确:您用作 ROWS 的坐标您正在验证 COLUMNS 界限,而这些您用作 COLUMNS 您正在验证 ROWS 界限。要从 Mat 中获取值,您必须使用 ROWS,COLS 坐标系。这样一来,您就会在不同的地方遇到错误,因为许多反向坐标在 Mat 范围内都是正确的。
猜你喜欢
  • 2017-10-03
  • 2018-01-19
  • 2013-03-15
  • 2010-11-29
  • 2020-06-01
  • 2016-05-13
  • 2020-11-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多