static int match_mask(const char *mask, const char *string) { if (mask == NULL) return 0; if (string == NULL) return 0; if ((mask[0] == '*') && (mask[1] == '\0')) return 1; /* instant match */ while (*mask != '\0') { if (*mask == '*') { mask++; switch (match_multi(&mask, &string)) { case +1: return 1; case -1: return 0; } } else if (*string == '\0') { return 0; } else if ((*mask == '?') || (*mask == *string)) { mask++; string++; } else { return 0; } } if (*string == '\0') return 1; else return 0; }
bool match( token_stream * ts ) { ts_ = ts; //rule_t base = match_list( std::bind(std::ptr_fn(&bla::expression), this), token(4) } ); rule_t base = match_list( { match_multi( match_statement() ), std::bind(std::mem_fn(&bla::end_of_input), this ) }); //std::cout << typeid(base).name() << "\n"; std::cout << "base: " << sizeof( base ) << "\n"; node m = base( ts ); std::cout << "match: " << (!m.is_null()) << "\n"; print_node( m ); return (!m.is_null()); }
int main(int argc, char* argv[]) { srand(time(NULL)); bool time_on = false; bool multi_on = false; if (argc > 1) for(int i = 1; i < argc; i++){ if(strcmp(argv[i], "time") == 0) time_on = true; if(strcmp(argv[i], "multi") == 0) multi_on = true; if(strcmp(argv[i], "-h") == 0){ cout << "time: Measure time." << endl; cout << "multi: Multi target." << endl; return 0; } } clock_t start, end; if (1){ mySIFT haha[2]; // haha[0] = mySIFT(1.414, 1.414, 3);//sigma k // haha[1] = mySIFT(1.414, 1.414, 3);//sigma k haha[0] = mySIFT(1.414, 1.414, 1);//sigma k haha[1] = mySIFT(1.414, 1.414, 1);//sigma k string targetFile = "target.jpg"; string targetFile2 = "target2.jpg"; Mat target = imread(targetFile, CV_LOAD_IMAGE_GRAYSCALE); Mat target2 = imread(targetFile2, CV_LOAD_IMAGE_GRAYSCALE); computeSift(haha[0], target, imread(targetFile),time_on); return 0; computeSift(haha[1], target2, imread(targetFile),time_on); // haha.filterKeyPoints_Hessian(target, imread(targetFile)); //haha.drawKeyPoints(targetFile); VideoCapture cap(0); while (1){ clock_t s; s = clock(); Mat img_scene; cap >> img_scene; imwrite("test.jpg", img_scene); clock_t start, end; mySIFT hoho(1.414, 1.414, 1);//sigma k //hoho.LoadImage(imageName2); Mat imgScene; cvtColor(img_scene, imgScene, CV_BGR2GRAY); computeSift(hoho, imgScene, img_scene, time_on); //start = clock(); if(multi_on) match_multi(haha[0], haha[1], hoho, targetFile, targetFile2, img_scene); else{ // dumpKeyPoints(haha[0], hoho); match(haha[0], hoho, targetFile, img_scene, s); } //end = clock(); //cout << "Match : " << (double)(end - s) / CLOCKS_PER_SEC << "\n"; } }