OpenCV断言失败CV_IS_MASK_ARR(掩码)

时间:2013-01-15 20:52:48

标签: ios image-processing opencv morphing

我正在使用示例iOS项目中的一些常规OpenCV函数,并在调用cvFindFundamentalMAT函数时收到以下错误:

OpenCV Error: Assertion failed (CV_IS_MASK_ARR(mask) && CV_IS_MAT_CONT(mask->type) 
&& (mask->rows == 1 || mask->cols == 1) && mask->rows*mask->cols == count) in 
cvFindFundamentalMat 

此功能似乎发生错误:

int calcFundamental(){

if(allPoints.size() != points_count) return -1;

// preparo la matrice delle corrispodenze

points1 = cvCreateMat(2,allPoints.size()/2,CV_32F);
points2 = cvCreateMat(2,allPoints.size()/2,CV_32F);
int count = std::max(points1->cols,points1->rows);
CvMat* status = cvCreateMat(1,count,CV_32F);
std::cout << "status->rows: " << status->rows <<"status->cols: " << status->cols << "count: "<< count << std::endl;
for(int j = 0; j < allPoints.size(); j++){

    if(j%2==0){
        std::cout << allPoints.at(j).x << ' ' << allPoints.at(j).y << std::endl;
        cvSetReal2D(points1,0,j-(int)round(j/2),allPoints.at(j).x);
        cvSetReal2D(points1,1,j-(int)round(j/2),allPoints.at(j).y);
    }else{
        std::cout << allPoints.at(j).x << ' ' << allPoints.at(j).y << std::endl;
        cvSetReal2D(points2,0,j-(int)round(j/2)-1,allPoints.at(j).x);
        cvSetReal2D(points2,1,j-(int)round(j/2)-1,allPoints.at(j).y);
    }
}

fundMat = cvCreateMat(3,3,CV_32F);
int num = 0;
num = cvFindFundamentalMat(points1,points2,fundMat,CV_FM_8POINT,1.0,0.9999,status);

return num;

}

任何方向都会受到高度赞赏。

1 个答案:

答案 0 :(得分:2)

CvMat* status = cvCreateMat(1,count,CV_32F);更改为CvMat* status = cvCreateMat(1,count,CV_8UC1);