我在网上搜索,没有找到我的问题的任何好的答案。所以这是我的问题:我使用OpenCV,有一个叫做replaceInvalidDisparties
的函数,我必须搜索像素,检查实际值是否为inf
,OpenCv
中有一个名为cvIsInf(double value)
的标准函数来检查值是否为inf
,但不知何故,我总是得到分割错误。
using namespace cv;
cv::Mat replaceInvalidDisparities(const cv::Mat &original_disp)
{
cv::Mat output = orignal_disp.clone();
//access pixel
for(int i = 0; i< output.rows; i++)
{
for(int j=0; j<output.cols; j++)
{
//now here i want to check if the actual pixel is inf
cvIsInf(output.at<double>(i,j));
}
}
}
但不知何故,它总是给我一个分割错误。有人知道问题出在哪里吗?
发布于 2018-03-15 23:28:46
首先,确保返回一个值。不返回值是一种未定义的行为:Is a return statement mandatory for C++ functions that do not return void?。
函数的其余部分似乎不是分段错误的原因,我建议更改
cv::Mat output = orignal_disp.clone();
至
cv::Mat output(100, 100, CV_64F);
只是为了确保你的矩阵不是病态的。(我准备发表评论;没有足够的声誉。)
https://stackoverflow.com/questions/49273797
复制相似问题