opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.39k stars 5.76k forks source link

OpenCV Errors: Assertion failed in the text detection example #368

Open futurely opened 9 years ago

futurely commented 9 years ago

Exception 1: OpenCV Error: Assertion failed (image.getMat().type() == CV_8UC3) in erGrouping, file ....../opencv_contrib/modules/text/src/erfilter.cpp, line 4081

Exception 2: OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file ....../opencv-3.0.0/modules/core/src/matrix.cpp, line 495

And the running time vary from dozens of milliseconds to several seconds for different images.

The source code is as follows.

    clock_t begin = clock();

// Extract channels to be processed individually
    computeNMChannels(src, channels);

    int cn = (int) channels.size();
    // Append negative channels to detect ER- (bright regions over dark background)
    for (int c = 0; c < cn - 1; c++) {
      channels.push_back(255 - channels[c]);
    }

    regions.resize(channels.size());
    // Apply the default cascade classifier to each independent channel (could be done in parallel)
//    cout << "Extracting Class Specific Extremal Regions from "
//        << (int) channels.size() << " channels ..." << endl;
//    cout << "    (...) this may take a while (...)" << endl << endl;
    for (int c = 0; c < (int) channels.size(); c++) {
      er_filter1->run(channels[c], regions[c]);
      er_filter2->run(channels[c], regions[c]);
    }

    // Detect character groups
//    cout << "Grouping extracted ERs ... ";
    erGrouping(src, channels, regions, region_groups, groups_boxes,
               ERGROUPING_ORIENTATION_HORIZ);

    clock_t end = clock();

@lluisgomez

StevenPuttemans commented 9 years ago

Are you sure that the channels matrices are of the correct type and format? It seems that there isnt correct data in the matrices.