void CHaarWavelets::load(FileNode& node) { wavelet_pairs_.clear(); node["n-tests"] >> n_tests_; node["symm-percent"] >> symm_ratio_; FileNode rect_pairs_node = node["rect-pairs"]; for(FileNodeIterator pair_node_it = rect_pairs_node.begin(); pair_node_it != rect_pairs_node.end(); ++pair_node_it) { FileNode testpair_node = (*pair_node_it); FileNode rect1_node = testpair_node["Rect1"]; FileNode rect2_node = testpair_node["Rect2"]; Rect rect1, rect2; rect1_node["rect"] >> rect1; rect2_node["rect"] >> rect2; float chind1, chind2; rect1_node["chind"] >> chind1; rect2_node["chind"] >> chind2; TestRect testrect1(rect1, chind1); TestRect testrect2(rect2, chind2); //cout << "TestRect: 1: Rect: " << testrect1.rect_ << ", chind: " << testrect1.ch_indicator_ << endl; //cout << "TestRect: 2: Rect: " << testrect2.rect_ << ", chind: " << testrect2.ch_indicator_ << endl; wavelet_pairs_.push_back(TestPair(testrect1, testrect2)); } }
void CHaarWavelets::initWavelets() { // generate test-boxes (relative coordinates within the image patch) wavelet_pairs_.clear(); for(int i = 0; i < n_tests_; ++i) { Rect rect1; rect1.width = randRange<int>(min_rect_sz_, max_rect_sz_); rect1.height = randRange<int>(min_rect_sz_, max_rect_sz_); rect1.x = randRange<int>(0, _PATCH_WINDOW_SIZE_-rect1.width-1); rect1.y = randRange<int>(0, _PATCH_WINDOW_SIZE_-rect1.height-1); Rect rect2(0,0,0,0); if(symm_ratio_ > randRange<float>(0,1)) // should the pairs be symmetric? { // Percentage of the types of the symmetric arranged pairs: // Horizontal-symmetric, Vertical-symmetric, Center-symmetric const float percent_h_sym = 0.3; const float percent_v_sym = 0.3; // the rest is center-symmetric float sym_type = randRange<float>(0,1); rect2.height = rect1.height; rect2.width = rect1.width; if(sym_type < percent_h_sym) // h-symmetric { rect2.x = _PATCH_WINDOW_SIZE_ - rect1.x - rect1.width; // see notes for derivation rect2.y = rect1.y; } else if(sym_type < percent_h_sym+percent_v_sym) // v-symmetric { rect2.x = rect1.x; rect2.y = _PATCH_WINDOW_SIZE_ - rect1.y - rect1.height; } else // c-symmetric { rect2.x = _PATCH_WINDOW_SIZE_ - rect1.x - rect1.width; rect2.y = _PATCH_WINDOW_SIZE_ - rect1.y - rect1.height; } } else { rect2.width = randRange<int>(min_rect_sz_, max_rect_sz_); rect2.height = randRange<int>(min_rect_sz_, max_rect_sz_); rect2.x = randRange<int>(0, _PATCH_WINDOW_SIZE_-rect2.width-1); rect2.y = randRange<int>(0, _PATCH_WINDOW_SIZE_-rect2.height-1); } float ch_indicator1 = randRange<float>(0,1); float ch_indicator2 = ch_indicator1; // use the same channel for the second rect. // randRange<float>(0,1); TestRect testrect1(rect1, ch_indicator1); TestRect testrect2(rect2, ch_indicator2); wavelet_pairs_.push_back(TestPair(testrect1, testrect2)); } }
void DRINK::generateAllPairs() { for (int i = 0; i < numPoints; ++i){ for (int j = 0; j < numPoints; ++j) { if (j != i) { allPairsVec.push_back(TestPair(i, j)); } } } }
operator std::pair<int, int>() const { return pair; }
//---------------------------------------------------------------------------------------------------- void TestCase::registerTest (std::string&& name, TestFunction&& function) { tests.push_back (TestPair (name, function)); }
void DRINK::generateRandomPairs() { for (int i = 0; i < numPairs; ++i) { pairs.push_back(TestPair(rand() % (numPoints), rand() % (numPoints))); } }