OpenCV错误:坏标志

时间:2014-11-08 13:02:17

标签: c++ opencv

我在opencv中使用某些方法但仍然遇到以下错误:

OpenCV Error: Bad flag(parameter or structure field) (unrecognized or unsupported array)

以下是代码:

void RafiTextLineExtractor::eraseMargins(){


    Mat img = _image.clone();
    threshold(img, img, 100, 200, CV_THRESH_BINARY_INV);

    BinaryComponentExtractor bn;
    bn.setImage(&DImage(img));
    vector<ConnectedComponent*> components;

    bn.extract(components);

    namedWindow("components",CV_WINDOW_NORMAL);
    imshow("components", img);

}

void  BinaryComponentExtractor::extract(vector<ConnectedComponent*>& components){
    vector<vector<Point>> contours;
    vector<Vec4i> hierarchy;
    Mat mat = _image->getMat().clone();
    cv::findContours(mat, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_NONE, Point(0, 0) );
    collectComponents(contours, hierarchy, components);
} 

void setImage(DImage* img) { _image = img; } 

此外,当我调试项目时,它似乎没有传递图像(在bn.setImage() ..)任何想法为什么会发生这种情况?

问候。

1 个答案:

答案 0 :(得分:0)

你的函数返回None。因此,您尝试显示无。