Пример #1
0
// Created on 2008-07-10
// Test for what's happen when the extrapolated motion patterns are recognized by mimesis
// also for RSJ conf. 2008
int test_extra_recognition(void)
{
	tl_message ("start");
	JHMM        *hmm1 = NULL, *hmm2 = NULL, *hmm3 = NULL, *synthesis_hmm = NULL;
	Behavior    *beh = NULL;
	JHMM        *hmm_vec[3];
	double      weight[3];
	int         i;

	hmm1      = new JHMM;
	hmm2      = new JHMM;
	hmm3      = new JHMM;
	hmm1->Load("./.tmp/punch/punch.hmm");
	hmm2->Load("./.tmp/squat/squat.hmm");
	hmm3->Load("./.tmp/kick/kick.hmm");
	hmm_vec[0] = hmm1;
	hmm_vec[1] = hmm2;
	hmm_vec[2] = hmm3;

	WorkSpace *work = NULL;
	work = new WorkSpace();
	if (script_file[0]==0) { print_usage(); exit(0); }
	work->LoadMotionDB (script_file);
	work->SetHTKUnitsFromMotionDB ();
	work->BeforeRecognize();
	work->DistanceLoad ("../../script/symbol_data/tmp_distance_vector");
	work->SpaceLoad    ("../../script/symbol_data/tmp_dim.spc");

	vector<double>	tmp_dis, new_dis, hellinger, tmp_cord;
	vector<double>	likelihood;

	tl_message ("# of motion db is : %d\n", work->GetNumOfMotionDB() );

	cout << "c_1, c_2, ";
	for (i=0; i<(int)(work->GetNumOfMotionDB()); i++)
		cout << "old_KLdistance[" << i << "] ,";
	for (i=0; i<(int)(work->GetNumOfMotionDB()); i++)
		cout << "new_KLdivergence[" << i << "] ,";
	for (i=0; i<(int)(work->GetNumOfMotionDB()); i++)
		cout << "Hellinger Distance[" << i << "] ,";
	for (i=0; i<(int)(work->GetPsymbolSpace()->GetDimension() ); i++)
		cout << "x[" << i << "] , ";
	cout << endl;

	for (int i=-10; i<20; i++)
		{
			synthesis_hmm = new JHMM;
			weight[0] = i * 0.1;
			weight[1] = 1 - weight[0];
			synthesis_hmm->InterpolationAny (hmm_vec, weight, 2);
			beh = synthesis_hmm->GenerateBehavior(100, 30);

			work->CalcHellingerDistanceOfOnlineBehavior(beh, hellinger);
			tl_message ("step hoge %d.0", i);
			for (int j=0; j<(int)(hellinger.size()); j++)
				cout << hellinger[j] << " , ";
			cout << endl;
			tl_message ("step hoge %d.1", i);
      
			work->CalcLikelihoodVector        (beh, likelihood);
			tl_message ("step hoge %d.2", i);
			work->CalcDistanceOfInputBehavior (beh, tmp_dis);
			tl_message ("step hoge %d.3", i);
			work->CalcDistanceOfOnlineBehavior(beh, new_dis);
			tl_message ("step hoge %d.4", i);

			work->GetPsymbolSpace()->CoordinateFromDistanceData(tmp_dis, tmp_cord);
			tl_message ("step hoge %d.5", i);
			cout << weight[0] << " , " << weight[1] << " , ";
			for (int j=0; j<(int)(tmp_dis.size()); j++)
				cout << tmp_dis[j] << " , ";
			for (int j=0; j<(int)(new_dis.size()); j++)
				cout << new_dis[j] << " , ";
			for (int j=0; j<(int)(hellinger.size()); j++)
				cout << hellinger[j] << " , ";
			for (int j=0; j<(int)(tmp_cord.size()); j++)
				cout << tmp_cord[j] << " , ";
			cout << endl;

			delete synthesis_hmm;
		}

	delete beh;
	delete hmm1;
	delete hmm2;
	delete hmm3;
	delete synthesis_hmm;
	return TRUE;
}