Commit bbca7b0c authored by lluis's avatar lluis

removes hardcoded filename for ERFilter used in feedback loop by adding a dummy classifier

parent 157e08f3
......@@ -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,16 +60,13 @@ int main(int argc, const char * argv[])
// Detect character groups
cout << "Grouping extracted ERs ... ";
cout << "image size "<< src.cols << "x" << src.rows << endl;
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
cout << "image size "<< src.cols << "x" << src.rows << endl;
groups_draw(src, groups_boxes);
cout << "image size "<< src.cols << "x" << src.rows << endl;
imshow("grouping",src);
cout << "Done!" << endl << endl;
......
......@@ -1160,6 +1160,26 @@ Ptr<ERFilter::Callback> loadClassifierNM2(const string& filename)
return makePtr<ERClassifierNM2>(filename);
}
// dummy classifier
class ERDummyClassifier : public ERFilter::Callback
{
public:
//Constructor
ERDummyClassifier() {}
// Destructor
~ERDummyClassifier() {}
// The classifier must return probability measure for the region.
double eval(const ERStat& s) {if (s.area ==0) return (double)0.0; return (double)1.0;}
};
/* Create a dummy classifier that accepts all regions */
Ptr<ERFilter::Callback> loadDummyClassifier();
Ptr<ERFilter::Callback> loadDummyClassifier()
{
return makePtr<ERDummyClassifier>();
}
/* ------------------------------------------------------------------------------------*/
/* -------------------------------- Compute Channels NM -------------------------------*/
......@@ -3858,7 +3878,7 @@ void erGroupingNM(InputArray _img, InputArrayOfArrays _src, vector< vector<ERSta
{
//Feedback loop of detected lines to region extraction ... tries to recover missmatches in the region decomposition step by extracting regions in the neighbourhood of a valid sequence and checking if they are consistent with its line estimates
Ptr<ERFilter> er_filter = createERFilterNM1(loadClassifierNM1("trained_classifierNM1.xml"),1,0.005f,0.3f,0.f,true,0.1f);
Ptr<ERFilter> er_filter = createERFilterNM1(loadDummyClassifier(),1,0.005f,0.3f,0.f,false);
for (int i=0; i<(int)valid_sequences.size(); i++)
{
vector<Point> bbox_points;
......
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