mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-20 21:40:49 +08:00
removes hardcoded filename for ERFilter used in feedback loop by adding a dummy classifier
This commit is contained in:
@@ -32,6 +32,7 @@ int main(int argc, const char * argv[])
|
|||||||
|
|
||||||
if (argc < 2) show_help_and_exit(argv[0]);
|
if (argc < 2) show_help_and_exit(argv[0]);
|
||||||
|
|
||||||
|
namedWindow("grouping",WINDOW_NORMAL);
|
||||||
Mat src = imread(argv[1]);
|
Mat src = imread(argv[1]);
|
||||||
|
|
||||||
// Extract channels to be processed individually
|
// Extract channels to be processed individually
|
||||||
@@ -59,16 +60,13 @@ int main(int argc, const char * argv[])
|
|||||||
|
|
||||||
// Detect character groups
|
// Detect character groups
|
||||||
cout << "Grouping extracted ERs ... ";
|
cout << "Grouping extracted ERs ... ";
|
||||||
cout << "image size "<< src.cols << "x" << src.rows << endl;
|
|
||||||
vector< vector<Vec2i> > region_groups;
|
vector< vector<Vec2i> > region_groups;
|
||||||
vector<Rect> groups_boxes;
|
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_HORIZ);
|
||||||
//erGrouping(src, channels, regions, region_groups, groups_boxes, ERGROUPING_ORIENTATION_ANY, "./trained_classifier_erGrouping.xml", 0.5);
|
//erGrouping(src, channels, regions, region_groups, groups_boxes, ERGROUPING_ORIENTATION_ANY, "./trained_classifier_erGrouping.xml", 0.5);
|
||||||
|
|
||||||
// draw groups
|
// draw groups
|
||||||
cout << "image size "<< src.cols << "x" << src.rows << endl;
|
|
||||||
groups_draw(src, groups_boxes);
|
groups_draw(src, groups_boxes);
|
||||||
cout << "image size "<< src.cols << "x" << src.rows << endl;
|
|
||||||
imshow("grouping",src);
|
imshow("grouping",src);
|
||||||
|
|
||||||
cout << "Done!" << endl << endl;
|
cout << "Done!" << endl << endl;
|
||||||
|
@@ -1160,6 +1160,26 @@ Ptr<ERFilter::Callback> loadClassifierNM2(const string& filename)
|
|||||||
return makePtr<ERClassifierNM2>(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 -------------------------------*/
|
/* -------------------------------- 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
|
//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++)
|
for (int i=0; i<(int)valid_sequences.size(); i++)
|
||||||
{
|
{
|
||||||
vector<Point> bbox_points;
|
vector<Point> bbox_points;
|
||||||
|
Reference in New Issue
Block a user