Commit c037eb95 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #42 from lluisgomez/master

Adds The exhaustive search algorithm and updates the previous groupining algorithm; Add xml files with default classifier models;
parents f6b14349 70a2bca2
......@@ -41,8 +41,8 @@
//
//M*/
#ifndef __OPENCV_OBJDETECT_ERFILTER_HPP__
#define __OPENCV_OBJDETECT_ERFILTER_HPP__
#ifndef __OPENCV_TEXT_ERFILTER_HPP__
#define __OPENCV_TEXT_ERFILTER_HPP__
#include "opencv2/core.hpp"
#include <vector>
......@@ -52,7 +52,7 @@
namespace cv
{
namespace text
{
{
/*!
Extremal Region Stat structure
......@@ -217,8 +217,8 @@ CV_EXPORTS Ptr<ERFilter::Callback> loadClassifierNM2(const std::string& filename
// computeNMChannels operation modes
enum { ERFILTER_NM_RGBLGrad = 0,
ERFILTER_NM_IHSGrad = 1
enum { ERFILTER_NM_RGBLGrad,
ERFILTER_NM_IHSGrad
};
/*!
......@@ -239,6 +239,12 @@ enum { ERFILTER_NM_RGBLGrad = 0,
CV_EXPORTS void computeNMChannels(InputArray _src, OutputArrayOfArrays _channels, int _mode = ERFILTER_NM_RGBLGrad);
// erGrouping operation modes
enum { ERGROUPING_ORIENTATION_HORIZ,
ERGROUPING_ORIENTATION_ANY
};
/*!
Find groups of Extremal Regions that are organized as text blocks. This function implements
the grouping algorithm described in:
......@@ -260,10 +266,14 @@ CV_EXPORTS void computeNMChannels(InputArray _src, OutputArrayOfArrays _channels
\param minProbability The minimum probability for accepting a group
\param groups The output of the algorithm are stored in this parameter as list of rectangles.
*/
CV_EXPORTS void erGrouping(InputArrayOfArrays src, std::vector<std::vector<ERStat> > &regions,
const std::string& filename, float minProbablity,
std::vector<Rect > &groups);
CV_EXPORTS void erGrouping(InputArray img, InputArrayOfArrays channels,
std::vector<std::vector<ERStat> > &regions,
std::vector<std::vector<Vec2i> > &groups,
std::vector<Rect> &groups_rects,
int method = ERGROUPING_ORIENTATION_HORIZ,
const std::string& filename = std::string(),
float minProbablity = 0.5);
}
}
#endif // _OPENCV_ERFILTER_HPP_
#endif // _OPENCV_TEXT_ERFILTER_HPP_
......@@ -32,6 +32,7 @@ int main(int argc, const char * argv[])
if (argc < 2) show_help_and_exit(argv[0]);
namedWindow("grouping",WINDOW_NORMAL);
Mat src = imread(argv[1]);
// Extract channels to be processed individually
......@@ -59,11 +60,13 @@ int main(int argc, const char * argv[])
// Detect character groups
cout << "Grouping extracted ERs ... ";
vector<Rect> groups;
erGrouping(channels, regions, "trained_classifier_erGrouping.xml", 0.5, groups);
vector< vector<Vec2i> > region_groups;
vector<Rect> groups_boxes;
erGrouping(src, channels, regions, region_groups, groups_boxes, ERGROUPING_ORIENTATION_HORIZ);
//erGrouping(src, channels, regions, region_groups, groups_boxes, ERGROUPING_ORIENTATION_ANY, "./trained_classifier_erGrouping.xml", 0.5);
// draw groups
groups_draw(src, groups);
groups_draw(src, groups_boxes);
imshow("grouping",src);
cout << "Done!" << endl << endl;
......@@ -75,9 +78,9 @@ int main(int argc, const char * argv[])
er_filter1.release();
er_filter2.release();
regions.clear();
if (!groups.empty())
if (!groups_boxes.empty())
{
groups.clear();
groups_boxes.clear();
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment