int main( ){ printf("Initing all data...\n"); left = malloc( sizeof(uint32_t) * FLT_CNT ); if( !left ){ fprintf(stderr, "no mem!"); exit(1); } right = malloc( sizeof(uint32_t) * FLT_CNT ); if( !right ){ fprintf(stderr, "no mem!"); exit(1); } keys = malloc( sizeof(uint32_t) * KEYS_CNT ); if( !keys ){ fprintf(stderr, "no mem!"); exit(1); } int i; srand(time(NULL)); fill_left(); qsort( left, FLT_CNT, sizeof(uint32_t), compare ); fill_right(); fill_keys(); volatile int r1; volatile int r2; uint32_t k; printf("Data is inited.\nStarting test...\n"); struct timespec tstart={0,0}, tend={0,0}; clock_gettime(CLOCK_MONOTONIC, &tstart); for( i = 0; i < KEYS_CNT; i++ ){ k = keys[i]; r1 = fast_test_key( k ); //r2 = slow_test_key( k ); //printf(">>> %u %d %d\n", k, r1, r2); //assert( (r1 == r2) ); } clock_gettime(CLOCK_MONOTONIC, &tend); printf("Test took about %.5f seconds\n", ((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) - ((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec)); return 0; }
void fill_in_stick(cv::Mat & Disp_map,cv::Mat & Occ_map){ int width = Disp_map.cols; int height = Disp_map.rows; cv::Mat fill_left(height,width,CV_8UC1,cv::Scalar::all(0)); cv::Mat fill_right(height,width,CV_8UC1,cv::Scalar::all(0)); Disp_map.copyTo(fill_left); Disp_map.copyTo(fill_right); cv::Mat cur_fill(height,1,CV_8UC1,cv::Scalar::all(Disp_K)); for(int i=0;i<width;i++){ for(int j=0;j<height;j++){ if(Occ_map.data[j*width+i]==255) fill_left.data[j*width+i] = cur_fill.data[j]; else cur_fill.data[j] = fill_left.data[j*width+i]; } } cur_fill.setTo(cv::Scalar::all(Disp_K)); for(int i=width-1;i>-1;i--){ for(int j=0;j<height;j++){ if(Occ_map.data[j*width+i]==255) fill_right.data[j*width+i] = cur_fill.data[j]; else cur_fill.data[j] = fill_right.data[j*width+i]; } } cv::Mat disp_view(height,width,CV_8UC1,cv::Scalar::all(0)); for(int i=0;i<width;i++){ for(int j=0;j<height;j++){ Disp_map.data[j*width+i] = min(fill_left.data[j*width+i],fill_right.data[j*width+i]); disp_view.data[j*width+i] = scale_K * Disp_map.data[j*width+i]; } } cv::namedWindow("disp",0); cv::imshow("disp",disp_view); cv::waitKey(); }
std::string to_string_fill_right(const std::string::value_type& filler, std::size_t min_size, const T& x) { return fill_right(filler, min_size, std::to_string(x)); }