void Conveyor::onImage(const cv::Mat &mono) { Timer timer; timer.start(); double min, max; cv::minMaxLoc(mono, &min, &max); //if(min < min_) min_ = min; min_ += (min - min_) * 0.02; //if(max > max_) max_ = max; max_ += (max - max_) * 0.02; Frame8 nf(mono, 10, min_, max_, invmed_); if(jacobi_.empty()) initJacobi(nf.levels_.size()); for(auto j = jacobi_.begin(); j != jacobi_.end(); j++) { if(j == jacobi_.begin()) (*j)->set(nf.levels_[0], 1); else (*j)->shrink((j - 1)->get()); } cv::Mat pose = cv::Mat::zeros(2, 3, CV_64F); double weight = 0; for(auto f = history_.begin(); f != history_.end(); f++) { cv::Mat t; double w = solve(*f, nf, t); /*cv::Mat tr = f->pose_(cv::Rect(0, 0, 2, 2)); cv::Mat to = t(cv::Rect(2, 0, 1, 2)); ps += tr * t(cv::Rect(2, 0, 1, 2)); tr *= t(cv::Rect(0, 0, 2, 2)); t =*/ weight += w; pose += t; } pose /= weight; nf.pose_ = pose; if(pushHistory) { if(history_.size() > 0) history_.pop_back(); history_.push_front(nf); } double time = timer.end(); std::cout << "time = " << time << std::endl; }
int main( int argc, char* argv[] ){ setbuf(stdout, NULL); // set buffer to null, so prints ALWAYS print (for debug purposes mainly) bool verify = false; bool printtime = true; // Command line parsing char c; while ((c = getopt (argc, argv, "nc:s:p:T:t:w:hv")) != -1){ switch( c ) { case 'n': // print time printtime = false; break; case 'c': // cores cores = parseInt( optarg ); if( cores <= 0 ){ fprintf(stderr, "cores must be greater than 0: %d\n", cores); exit( 0 ); } break; case 'p': // problem size problemSize = parseInt( optarg ); if( problemSize <= 0 ){ fprintf(stderr, "problemSize must be greater than 0: %d\n", problemSize); exit( 0 ); } break; case 'T': // T (time steps) T = parseInt( optarg ); if( T <= 0 ){ fprintf(stderr, "T must be greater than 0: %d\n", T); exit( 0 ); } break; case 't': // timeBand timeBand = parseInt( optarg ); if( timeBand <= 0 ){ fprintf(stderr, "t must be greater than 0: %d\n", T); exit( 0 ); } break; case 'w': // width width_max = parseInt( optarg ); if( width_max <= 0 ){ fprintf(stderr, "w must be greater than 0: %d\n", T); exit( 0 ); } break; case 'h': // help printf("usage: %s\n-n \t dont print time \n-p <problem size> \t problem size in elements \n-T <time steps>\t number of time steps\n-c <cores>\tnumber of threads\n-w <tile width>\t the width of the tile\n-t <tile height>\t the number of timesteps in a tile\n-h\tthis dialogue\n-v\tverify output\n", argv[0]); exit(0); case 'v': // verify; verify = true; break; case '?': if (optopt == 'p') fprintf (stderr, "Option -%c requires positive int argument: problem size.\n", optopt); else if (optopt == 'T') fprintf (stderr, "Option -%c requires positive int argument: T.\n", optopt); else if (optopt == 's') fprintf (stderr, "Option -%c requires int argument: subset_s.\n", optopt); else if (optopt == 'c') fprintf (stderr, "Option -%c requires int argument: number of cores.\n", optopt); else if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); exit(0); default: exit(0); } } initJacobi(); initTrapezoid(); initSpace(); double time = test_1(); if( printtime ){ printf( "Time: %f\n", time ); } if( verify ){ verifyResult( true ); } }