OpenCV错误:错误标志

OpenCV Error: Bad flag

本文关键字:错误 标志 OpenCV      更新时间:2023-10-16

我正在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()..中)。任何想法为什么会发生这种情况?

问候。

您的函数返回None。所以你想展示"无"。