【发布时间】: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
分为三个步骤:
- 检查x_imagePoints的坐标是否在col_bound(640)和row_bound(480)范围内
- 检查framex_silhouette的相同位置是否都是255
- 将 255 应用于从步骤 2 到 framex_reconstruction 的位置
程序总是在不同的状态下失败,比如 i == 1900566
有没有人知道如何在 OpenCV 中连续处理大数据而不会出错?
【问题讨论】:
-
'z' 索引是做什么用的?为什么你从不初始化 'i' ?
-
@berak,我重新编辑了代码以获得清晰的解释。 'x','y','z'索引用于解释大体素