运行以下代码时:
for(int i = 0; i < result.size(); ++i) {
for(int j = 0; j < result[i].size(); ++j) {
if(anchor_map->at<float>(i, j) > 0) {
}
}
}
当result.size()1200和result [i] .size()的大小超过1600时,会锁定i和j的范围,因为anchor_map.size()是[1600 x 1200 ]
问题在于,每次在i = 1197时,j = 1436,它都会因访问冲突而被切断,而anchor_map在开始时设置为零,右边的像素是锚点所在的位置。
在Windows 7 64位上的Visual Studio 12中生成
答案 0 :(得分:1)
试试这个:
using namespace cv;
void main (void)
{
Mat anchor_map(1200,1600,CV_8UC1);
for(int i = 0; i < anchor_map.rows; ++i) {
for(int j = 0; j < anchor_map.cols; ++j) {
if(anchor_map.at<unsigned char>(i, j) > 0) {
}
}
}
getchar();
}