Exemple #1
0
double matrix_test_unit_fix(int a1, int a2)
{
	CMatrixFixed<T, DIM, DIM> C;

	const long N = 1000000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		C.resize(DIM, DIM);
		C.setIdentity();
	}
	return tictac.Tac() / N;
}
Exemple #2
0
double matrix_test_unit_dyn(int a1, int a2)
{
	CMatrixDynamic<T> C(a1, a1);

	const long N = 1000000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		C.resize(a1, a1);
		C.setIdentity();
	}
	return tictac.Tac() / N;
}
Exemple #3
0
double grid_test_3(int a1, int a2)
{
	COccupancyGridMap2D		gridMap(-20,20,-20,20, 0.05);
	const long N = 1000000;
	float	p=0.57f;

	CTicTac tictac;
	for (long i=0;i<N;i++)
	{
		gridMap.updateCell( 0, 0, p );
	}
	return tictac.Tac()/N;
}
Exemple #4
0
double matrix_test_det_fix(int a1, int a2)
{
	CMatrixFixedNumeric<T,DIM1,DIM1>	A;
	randomGenerator.drawGaussian1DMatrix(A,T(0),T(1));

	const long N = 10000;
	CTicTac	 tictac;
	for (long i=0;i<N;i++)
	{
		A.det();
	}
	return tictac.Tac()/N;
}
Exemple #5
0
double random_test_3(int a1, int a2)
{
	CRandomGenerator rg;

	// test 3: drawGaussian1D_normalized
	// ----------------------------------------
	const long N = 10000000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		rg.drawGaussian1D_normalized();
	}
	return tictac.Tac() / N;
}
Exemple #6
0
double random_test_4(int a1, int a2)
{
	CRandomGenerator rg;

	// test 4: drawGaussian1D
	// ----------------------------------------
	const long N = 10000000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		rg.drawGaussian1D(5.0, 3.0);
	}
	return tictac.Tac() / N;
}
Exemple #7
0
double random_test_5(int a1, int a2)
{
	CRandomGenerator rg;

	// test 5: system rand()
	// ----------------------------------------
	const long N = 10000000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		rand();
	}
	return tictac.Tac() / N;
}
Exemple #8
0
// ------------------------------------------------------
//				Benchmark Random Generators
// ------------------------------------------------------
double random_test_1(int a1, int a2)
{
	CRandomGenerator rg;

	// test 1: draw uint32
	// ----------------------------------------
	const long N = 100000000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		rg.drawUniform32bit();
	}
	return tictac.Tac() / N;
}
Exemple #9
0
double matrix_test_loadFromArray(int N, int a2)
{
	EIGEN_ALIGN16 double nums[4*4] = {
	 0,1,2,3,
	 4,5,6,7,
	 8,9,10,11,
	 12,13,14,15 };

	CMatrixFixedNumeric<double,4,4> M;

	CTicTac	 tictac;
	M.loadFromArray(nums);
	return tictac.Tac();
}
Exemple #10
0
double random_test_2(int a1, int a2)
{
	CRandomGenerator rg;

	// test 2: drawUniform
	// ----------------------------------------
	const long N = 100000000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		rg.drawUniform(0, 1);
	}
	return tictac.Tac() / N;
}
Exemple #11
0
double matrix_test_inv_dyn(int a1, int a2)
{
	CMatrixTemplateNumeric<T>	A(DIM1,DIM1);
	CMatrixTemplateNumeric<T>	A2(DIM1,DIM1);
	randomGenerator.drawGaussian1DMatrix(A,T(0),T(1));

	const long N = 1000;
	CTicTac	 tictac;
	for (long i=0;i<N;i++)
	{
		A.inv(A2);
	}
	return tictac.Tac()/N;
}
Exemple #12
0
// ------------------------------------------------------
//						MAIN
// ------------------------------------------------------
int main(int argc, char **argv)
{
	try
	{
		if (argc<2)
		{
			cerr << "Usage: test-compress <input_file> [compression level 1-9]" << endl;
			return -1;
		}

		vector_byte	buf;

		if (!mrpt::system::loadBinaryFile( buf, argv[1]))
		{
			cerr << "Error loading file: " << argv[1] << endl;
			return -1;
		}

		string	gzfile = format("%s.gz",argv[1]);
		int		compress_level = 9;
		if (argc>=3)
		{
			compress_level = atoi( argv[2] );
		}
		CTicTac	tictac;

		tictac.Tic();

		if (!mrpt::compress::zip::compress_gz_file( gzfile, buf, compress_level))
		{
			cerr << "Error writing compressing file: " << gzfile << endl;
			return -1;
		}

		double t = tictac.Tac();
		cout << format("Compressed %s (compress level=%i) in %.04f seconds.",gzfile.c_str(),compress_level,t) << endl;

		return 0;
	} catch (std::exception &e)
	{
		std::cout << "MRPT exception caught: " << e.what() << std::endl;
		return -1;
	}
	catch (...)
	{
		printf("Untyped exception!!");
		return -1;
	}
}
Exemple #13
0
// ------------------------------------------------------
//				Benchmark Misc. Math
// ------------------------------------------------------
double math_test_round(int a1, int a2)
{
	const long N = 100000000;
	CTicTac	 tictac;

	int a;
	double b = 2.3;
	for (long i=0;i<N;i++)
	{
		a=mrpt::math::round(b);
	}
	double T = tictac.Tac()/N;
	dummy_do_nothing_with_string( mrpt::format("%i",a) );
	return T;
}
Exemple #14
0
// ------------------------------------------------------
//				TestCapture
// ------------------------------------------------------
void TestExtractFeaturesTile()
{
	CDisplayWindow		wind1,wind2;
	CFeatureExtraction	fExt;
	CFeatureList		featsHarris;
	CImage				img;

	string the_img = myDataDir+string("test_image.jpg");

	if (!img.loadFromFile(the_img ))
	{
		cerr << "Cannot load " << the_img  << endl;
		return;
	}
	cout << "Loaded test image: " << the_img << endl;

	CTicTac	tictac;

	cout << "Extracting Harris features (tiled)... [f_harris_tiled.txt]";

	fExt.options.featsType = featHarris;
	fExt.options.harrisOptions.tile_image = true;

	tictac.Tic();
	fExt.detectFeatures( img, featsHarris );
	cout << format("  %.03fms",tictac.Tac()*1000) << endl;

	cout << "Detected " << featsHarris.size() << " features in " << endl;
	featsHarris.saveToTextFile("f_harris_tiled.txt");
	wind1.setWindowTitle("Harris detected features (Tiled image)");
	wind1.showTiledImageAndPoints( img, featsHarris );

	cout << "Extracting Harris features... [f_harris.txt]";

	fExt.options.harrisOptions.tile_image = false;

	tictac.Tic();
	fExt.detectFeatures( img, featsHarris );
	cout << format("  %.03fms",tictac.Tac()*1000) << endl;

	featsHarris.saveToTextFile("f_harris.txt");
	wind2.setWindowTitle("Harris detected features");
	wind2.showTiledImageAndPoints( img, featsHarris );

	mrpt::system::pause();

	return;
}
Exemple #15
0
double grid_test_2(int a1, int a2)
{
	COccupancyGridMap2D		gridMap(-20,20,-20,20, 0.05f);
	// test 2: setcell
	// ----------------------------------------
	const long N = 10000000;

	float	p=0.8f;

	CTicTac	 tictac;
	for (long i=0;i<N;i++)
	{
		gridMap.setCell( 0, 0, p );
	}
	return tictac.Tac()/N;
}
Exemple #16
0
// ------------------------------------------------------
//				TestImageFFT
// ------------------------------------------------------
void TestImageFFT()
{
	CTicTac			tictac;
	CImage		IM1,IM2;
	CMatrix			imgCorr;

	IM1.loadFromFile(myDataDir+string("fft2_test_image_patch.jpg"), 0 );		// "Patch"
	IM2.loadFromFile(myDataDir+string("fft2_test_image.jpg"), 0 );		// Ref. image

	printf("Computing images correlation...");
	tictac.Tic();
	IM2.cross_correlation_FFT(IM1,imgCorr);
	printf(" Done,%.06fms\n",tictac.Tac()*1000.0f);

	imgCorr.saveToTextFile("_out_dft2_image_test.txt");
}
Exemple #17
0
// ------------------------------------------------------
//				BenchmarkGridmaps
// ------------------------------------------------------
double grid_test_1(int a1, int a2)
{
	COccupancyGridMap2D		gridMap(-20,20,-20,20, 0.05f);

	// test 1: getcell
	// ----------------------------------------
	const long N = 10000000;
	float	p=0;

	CTicTac	 tictac;
	for (long i=0;i<N;i++)
	{
		p += gridMap.getCell( 0, 0 );
	}
	return tictac.Tac()/N;
}
Exemple #18
0
double matrix_test_loadWithEigenMap(int N, int a2)
{
	EIGEN_ALIGN16 double nums[4*4] = {
	 0,1,2,3,
	 4,5,6,7,
	 8,9,10,11,
	 12,13,14,15 };

	CMatrixFixedNumeric<double,4,4> M;

	CTicTac	 tictac;
	M = Eigen::Map<CMatrixFixedNumeric<double,4,4>::Base,Eigen::Aligned >(nums);
	const double t= tictac.Tac();
	dummy_do_nothing_with_string(mrpt::format("%e",M(0,0)));
	return t;
}
Exemple #19
0
void matching(data_st *data)
{
	CTicTac	tictac;
	TMatchingOptions opt;
	opt.useXRestriction=false;
	if(data->matching_type==epipolar_match)
	{
		opt.useEpipolarRestriction=true;
		opt.parallelOpticalAxis=false;
		opt.epipolar_TH=2.0;
		opt.maxEDSD_TH=0.18;
		opt.EDSD_RATIO=0.6;
		opt.F.loadFromTextFile("FM_Harris2ways.txt");
	}
	else
	{
		opt.useEpipolarRestriction=false;
		opt.maxEDSD_TH=0.18;
		opt.EDSD_RATIO=0.6;
	}
	cout<<"\nCalculating matches...\n";

	//opt.F=data->FM_Harris2ways;
	opt.matching_method=TMatchingOptions::mmDescriptorSURF;
	tictac.Tic();
	mrpt::vision::utils::matchFeatures2(data->featsHarris, data->featsHarris2, data->Harris_matched, opt);
	cout << "Detected " << data->Harris_matched.size() << " Harris matches in " << endl;
	cout << format("  %.03fms",tictac.Tac()*1000) << endl;
	data->Harris_matched.saveToTextFile("Harris_matches.txt");

//Calculate matches in the inverse way

	//opt.F=(~opt.F);
	//opt.F=(~data->FM_Harris2ways);
	tictac.Tic();
	mrpt::vision::utils::matchFeatures2(data->featsHarris2, data->featsHarris, data->Harris_matched_inv, opt);
	cout << "Detected " << data->Harris_matched_inv.size() << " Harris matches 'INV' in " << endl;
	cout << format("  %.03fms",tictac.Tac()*1000) << endl;
	data->Harris_matched_inv.saveToTextFile("Harris_matches_inv.txt");

// Only matches found in both ways are kept in a new file (Detect matches in only one way and delete it)
	data->Harris_matched2ways = comp2Matched_lists(data->Harris_matched, data->Harris_matched_inv);
	cout << data->Harris_matched2ways.size() << " Harris matches in both ways\n" << endl;

	data->matching_done=true;
	cout<<"\nMatching finished\n";
}
Exemple #20
0
// ------------------------------------------------------
//				TestMatrixs
// ------------------------------------------------------
void TestMatrixs()
{
	CMatrixFloat		m,l;
	CTicTac		tictac;
	double		t;

	m.setSize(4,4);
	m(0,0)= 4;
	m(0,1)=-2;
	m(0,2)=-1;
	m(0,3)= 0;
	m(1,0)= -2;
	m(1,1)= 4;
	m(1,2)= 0;
	m(1,3)= -1;
	m(2,0)= -1;
	m(2,1)= 0;
	m(2,2)= 4;
	m(2,3)= -2;
	m(3,0)= 0;
	m(3,1)= -1;
	m(3,2)= -2;
	m(3,3)= 4;

	cout << "Matrix:\n" << m << endl;

	// I/O test through a text file:
	m.saveToTextFile("matrix1.txt");
	tictac.Tic();
	l.loadFromTextFile(myDataDir+string("matrix1.txt"));
	t=tictac.Tac();
	cout << "Read (text file) in " << 1e6*t << "us:\n" << l << endl;

	m.laplacian(l);

	cout << "Laplacian:\n" << l << endl;

	CMatrixFloat		Z,D;
	m.eigenVectors(Z,D);

	cout << "Eigenvectors: M = Z * D * Z':\n Z=\n" << Z << endl;
	cout << "D=\n" << D << endl;

	cout << "Z * D * Z'=\n" << Z * D * (~Z) << endl;

}
Exemple #21
0
double matrix_test_mult_dyn(int a1, int a2)
{
	CMatrixDynamic<T> A(DIM1, DIM2);
	CMatrixDynamic<T> B(DIM2, DIM3);
	CMatrixDynamic<T> C(DIM1, DIM3);

	getRandomGenerator().drawGaussian1DMatrix(A, T(0), T(1));
	getRandomGenerator().drawGaussian1DMatrix(B, T(0), T(1));

	const long N = 10000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		C.matProductOf_AB(A, B);
	}
	return tictac.Tac() / N;
}
Exemple #22
0
double matrix_test_mult_fix(int a1, int a2)
{
	CMatrixFixedNumeric<T,DIM1,DIM2>	A;
	CMatrixFixedNumeric<T,DIM2,DIM3>	B;
	CMatrixFixedNumeric<T,DIM1,DIM3>	C;

	randomGenerator.drawGaussian1DMatrix(A,T(0),T(1));
	randomGenerator.drawGaussian1DMatrix(B,T(0),T(1));

	const long N = 10000;
	CTicTac	 tictac;
	for (long i=0;i<N;i++)
	{
		C.multiply(A,B);
	}
	return tictac.Tac()/N;
}
Exemple #23
0
double matrix_test_mult_fix(int a1, int a2)
{
	CMatrixFixed<T, DIM1, DIM2> A;
	CMatrixFixed<T, DIM2, DIM3> B;
	CMatrixFixed<T, DIM1, DIM3> C;

	getRandomGenerator().drawGaussian1DMatrix(A, T(0), T(1));
	getRandomGenerator().drawGaussian1DMatrix(B, T(0), T(1));

	const long N = 10000;
	CTicTac tictac;
	for (long i = 0; i < N; i++)
	{
		C.matProductOf_AB(A, B);
	}
	return tictac.Tac() / N;
}
Exemple #24
0
double poses_test_compose2D2(int a1, int a2)
{
	const long N = 500000;
	CTicTac	 tictac;

	CPose2D a(1.0,2.0,DEG2RAD(10));
	CPose2D b(8.0,-5.0,DEG2RAD(-40));

	CPose2D p;
	for (long i=0;i<N;i++)
	{
		p.composeFrom(a,b);
	}
	double T = tictac.Tac()/N;
	dummy_do_nothing_with_string( mrpt::format("%f",p.x()) );
	return T;
}
Exemple #25
0
double matrix_test_mult_dyn(int a1, int a2)
{
	CMatrixTemplateNumeric<T>	A(DIM1,DIM2);
	CMatrixTemplateNumeric<T>	B(DIM2,DIM3);
	CMatrixTemplateNumeric<T>	C(DIM1,DIM3);

	randomGenerator.drawGaussian1DMatrix(A,T(0),T(1));
	randomGenerator.drawGaussian1DMatrix(B,T(0),T(1));

	const long N = 10000;
	CTicTac	 tictac;
	for (long i=0;i<N;i++)
	{
		C.multiply(A,B);
	}
	return tictac.Tac()/N;
}
Exemple #26
0
double poses_test_compose3DQuat2(int a1, int a2)
{
	const long N = 100000;
	CTicTac	 tictac;

	CPose3DQuat  a(CPose3D(1.0,2.0,3.0,DEG2RAD(10),DEG2RAD(50),DEG2RAD(-30)));
	CPose3DQuat  b(CPose3D(8.0,-5.0,-1.0,DEG2RAD(-40),DEG2RAD(10),DEG2RAD(-45)));

	CPose3DQuat p;
	for (long i=0;i<N;i++)
	{
		p.composeFrom(a,b);
	}
	double T = tictac.Tac()/N;
	dummy_do_nothing_with_string( mrpt::format("%f",p.x()) );
	return T;
}
Exemple #27
0
double poses_test_convert_quat_ypr(int a1, int a2)
{
	const long N = 1000000;
	CTicTac	 tictac;

	CPose3DQuat a(CPose3D(1.0,2.0,3.0,DEG2RAD(10),DEG2RAD(50),DEG2RAD(-30)));

	double x;
	for (long i=0;i<N;i++)
	{
		CPose3D p(a);
		x=p.x();
	}
	double T = tictac.Tac()/N;
	dummy_do_nothing_with_string( mrpt::format("%f",x) );
	return T;
}
Exemple #28
0
double poses_test_compose3Dpoint(int a1, int a2)
{
	const long N = 500000;
	CTicTac	 tictac;

	CPose3D   a(1.0,2.0,3.0,DEG2RAD(10),DEG2RAD(50),DEG2RAD(-30));
	CPoint3D  b(8.0,-5.0,-1.0);

	CPoint3D p;
	for (long i=0;i<N;i++)
	{
		p = a+b;
	}
	double T = tictac.Tac()/N;
	dummy_do_nothing_with_string( mrpt::format("%f",p.x()) );
	return T;
}
Exemple #29
0
double poses_test_compose3Dpoint2(int a1, int a2)
{
	const long N = 500000;
	CTicTac	 tictac;

	CPose3D   a(1.0,2.0,3.0,DEG2RAD(10),DEG2RAD(50),DEG2RAD(-30));
	CPoint3D  b(8.0,-5.0,-1.0);

	double x,y,z;
	for (long i=0;i<N;i++)
	{
		a.composePoint(b.x(),b.y(),b.z(),x,y,z);
	}
	double T = tictac.Tac()/N;
	dummy_do_nothing_with_string( mrpt::format("%f",x) );
	return T;
}
/*---------------------------------------------------------------
					getAsImageFiltered
  ---------------------------------------------------------------*/
void  COccupancyGridMap2D::getAsImageFiltered(
	utils::CImage	&img,
	bool verticalFlip,
	bool forceRGB ) const
{
	getAsImage(img,verticalFlip,forceRGB);

	// Do filtering to improve the noisy peaks in grids:
	// ----------------------------------------------------
#if 0
	CTicTac  t;
#endif
	if (insertionOptions.CFD_features_gaussian_size!=0) 	img.filterGaussianInPlace( round( insertionOptions.CFD_features_gaussian_size ) );
	if (insertionOptions.CFD_features_median_size!=0) 		img.filterMedianInPlace( round( insertionOptions.CFD_features_median_size ) );
#if 0
	cout << "[COccupancyGridMap2D::getAsImageFiltered] Filtered in: " << t.Tac()*1000 << " ms" << endl;
#endif
}