OpenCV断言失败CV_IS_MASK_ARR(掩码)



我在一个示例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;

}

请指教。

change CvMat* status = cvCreateMat(1,count,CV_32F); to CvMat* status = cvCreateMat(1,count,CV_8UC1);

相关内容

  • 没有找到相关文章

最新更新