comparison src/MatchFeatureFeeder.cpp @ 74:b9aa663a607b refactors

Pull out feature extractor calls from Matcher, remove MatchFeeder, have only the feeder-from-features and use that in MatchVampPlugin
author Chris Cannam
date Wed, 19 Nov 2014 11:59:03 +0000
parents c3c50d5e05b7
children 0042b4d42167
comparison
equal deleted inserted replaced
73:7e3c1bc0984a 74:b9aa663a607b
17 #include "MatchFeatureFeeder.h" 17 #include "MatchFeatureFeeder.h"
18 18
19 using std::vector; 19 using std::vector;
20 20
21 MatchFeatureFeeder::MatchFeatureFeeder(Matcher *m1, Matcher *m2) : 21 MatchFeatureFeeder::MatchFeatureFeeder(Matcher *m1, Matcher *m2) :
22 pm1(m1), pm2(m2) 22 m_pm1(m1), m_pm2(m2)
23 { 23 {
24 finder = new Finder(m1); 24 m_finder = new Finder(m1);
25 } 25 }
26 26
27 MatchFeatureFeeder::~MatchFeatureFeeder() 27 MatchFeatureFeeder::~MatchFeatureFeeder()
28 { 28 {
29 delete finder; 29 delete m_finder;
30 } 30 }
31 31
32 void 32 void
33 MatchFeatureFeeder::feed(vector<double> f1, vector<double> f2) 33 MatchFeatureFeeder::feed(vector<double> f1, vector<double> f2)
34 { 34 {
37 // that it has at least one feature in each queue. It loops, 37 // that it has at least one feature in each queue. It loops,
38 // processing up to one feature per matcher, until a queue is 38 // processing up to one feature per matcher, until a queue is
39 // empty. Then it returns, to be called again with more data. 39 // empty. Then it returns, to be called again with more data.
40 40
41 if (!f1.empty()) { 41 if (!f1.empty()) {
42 q1.push(f1); 42 m_q1.push(f1);
43 } 43 }
44 44
45 if (!f2.empty()) { 45 if (!f2.empty()) {
46 q2.push(f2); 46 m_q2.push(f2);
47 } 47 }
48 48
49 while (!q1.empty() && !q2.empty()) { 49 while (!m_q1.empty() && !m_q2.empty()) {
50 feedBlock(); 50 feedBlock();
51 } 51 }
52 } 52 }
53 53
54 void 54 void
55 MatchFeatureFeeder::finish() 55 MatchFeatureFeeder::finish()
56 { 56 {
57 while (!q1.empty() || !q2.empty()) { 57 while (!m_q1.empty() || !m_q2.empty()) {
58 feedBlock(); 58 feedBlock();
59 } 59 }
60 } 60 }
61 61
62 void 62 void
63 MatchFeatureFeeder::feedBlock() 63 MatchFeatureFeeder::feedBlock()
64 { 64 {
65 if (q1.empty()) { // ended 65 if (m_q1.empty()) { // ended
66 feed2(); 66 feed2();
67 } else if (q2.empty()) { // ended 67 } else if (m_q2.empty()) { // ended
68 feed1(); 68 feed1();
69 } else if (pm1->m_frameCount < pm1->m_blockSize) { // fill initial block 69 } else if (m_pm1->m_frameCount < m_pm1->m_blockSize) { // fill initial block
70 feed1(); 70 feed1();
71 feed2(); 71 feed2();
72 } else if (pm1->m_runCount >= pm1->m_params.maxRunCount) { // slope constraints 72 } else if (m_pm1->m_runCount >= m_pm1->m_params.maxRunCount) { // slope constraints
73 feed2(); 73 feed2();
74 } else if (pm2->m_runCount >= pm2->m_params.maxRunCount) { 74 } else if (m_pm2->m_runCount >= m_pm2->m_params.maxRunCount) {
75 feed1(); 75 feed1();
76 } else { 76 } else {
77 switch (finder->getExpandDirection 77 switch (m_finder->getExpandDirection
78 (pm1->m_frameCount-1, pm2->m_frameCount-1)) { 78 (m_pm1->m_frameCount-1, m_pm2->m_frameCount-1)) {
79 case Matcher::AdvanceThis: 79 case Matcher::AdvanceThis:
80 feed1(); 80 feed1();
81 break; 81 break;
82 case Matcher::AdvanceOther: 82 case Matcher::AdvanceOther:
83 feed2(); 83 feed2();
85 case Matcher::AdvanceBoth: 85 case Matcher::AdvanceBoth:
86 feed1(); 86 feed1();
87 feed2(); 87 feed2();
88 break; 88 break;
89 case Matcher::AdvanceNone: 89 case Matcher::AdvanceNone:
90 cerr << "finder says AdvanceNone!" << endl; 90 cerr << "m_finder says AdvanceNone!" << endl;
91 break; 91 break;
92 } 92 }
93 } 93 }
94 } 94 }
95 95
96 void 96 void
97 MatchFeatureFeeder::feed1() 97 MatchFeatureFeeder::feed1()
98 { 98 {
99 pm1->consumeFeatureVector(q1.front()); 99 m_pm1->consumeFeatureVector(m_q1.front());
100 q1.pop(); 100 m_q1.pop();
101 } 101 }
102 102
103 void 103 void
104 MatchFeatureFeeder::feed2() 104 MatchFeatureFeeder::feed2()
105 { 105 {
106 pm2->consumeFeatureVector(q2.front()); 106 m_pm2->consumeFeatureVector(m_q2.front());
107 q2.pop(); 107 m_q2.pop();
108 } 108 }
109 109