OpenCV 3.0.0 MSER Binary Mask

前端 未结 1 2053
小蘑菇
小蘑菇 2021-01-05 00:42

I am trying to use MSER algorithm in OpenCV 3.0.0 beta to extract text regions from an image. At the end I need a binary mask with the detected MSER regions, but the algorit

相关标签:
1条回答
  • 2021-01-05 01:08

    I found the solution! Just loop over all the points and draw them!

    void mserExtractor (const Mat& image, Mat& mserOutMask){
        Ptr<MSER> mserExtractor  = MSER::create();
    
        vector<vector<cv::Point>> mserContours;
        vector<KeyPoint> mserKeypoint;
        vector<cv::Rect> mserBbox;
        mserExtractor->detectRegions(image, mserContours,  mserBbox);
    
        for (vector<cv::Point> v : mserContours){
            for (cv::Point p : v){
                mserOutMask.at<uchar>(p.y, p.x) = 255;
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题