6/12/2015

OpenCV MSER example (opencv 300 )

MSER example




...
#include < iostream>  
#include < opencv2\opencv.hpp>  
#include < opencv2\highgui.hpp>  
#include < opencv2\imgcodecs.hpp>  
#include < opencv2\core.hpp>
#include < opencv2\imgproc.hpp>
#include < opencv2\text.hpp>
#include < opencv2/features2d.hpp>


#ifdef _DEBUG             
#pragma comment(lib, "opencv_core300d.lib")     
#pragma comment(lib, "opencv_highgui300d.lib")  
#pragma comment(lib, "opencv_imgcodecs300d.lib")
#pragma comment(lib, "opencv_text300d.lib")
#pragma comment(lib, "opencv_features2d300d.lib")
#pragma comment(lib, "opencv_imgproc300d.lib")

#else     
#pragma comment(lib, "opencv_core300.lib")     
#pragma comment(lib, "opencv_highgui300.lib")  
#pragma comment(lib, "opencv_imgcodecs300.lib")  
#pragma comment(lib, "opencv_text300.lib")
#pragma comment(lib, "opencv_features2d300.lib")
#pragma comment(lib, "opencv_imgproc300d.lib")
#endif      

using namespace std;
using namespace cv;
void main()
{

 Mat inImg = imread("M:\\____videoSample____\\SceneText\\SceneText01.jpg");

 Mat textImg;
 cvtColor(inImg, textImg, CV_BGR2GRAY);
 //Extract MSER
 
 vector< vector< Point> > contours;
 vector< Rect> bboxes;
 Ptr< MSER> mser = MSER::create(21, (int)(0.00002*textImg.cols*textImg.rows), (int)(0.05*textImg.cols*textImg.rows), 1, 0.7); 
 mser->detectRegions(textImg, contours, bboxes); 

 for (int i = 0; i < bboxes.size(); i++)
 {
  rectangle(inImg, bboxes[i], CV_RGB(0, 255, 0));
 }


 namedWindow("t");
 imshow("t", inImg);
 waitKey(0);

}


No comments:

Post a Comment