本文整理汇总了C++中Environment::Capture方法的典型用法代码示例。如果您正苦于以下问题:C++ Environment::Capture方法的具体用法?C++ Environment::Capture怎么用?C++ Environment::Capture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::Capture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateTestData2
//.........这里部分代码省略.........
{
sprintf(fname, "%scamera%d.calib", g_filepath, i );
FILE *calibFile = fopen(fname,"w");
cam[i]->saveCamParams(calibFile);
fclose( calibFile );
fprintf(clist, "%s\n", fname);
}
fclose(clist);
std::vector<CvPoint3D64f> board_pos;
board_pos.clear();
//generate body position, set zero for now
CvPoint3D64f pos;
pos.x = 0;
pos.y = 0;
pos.z = 0;
board_pos.push_back(pos);
RigidBody* body = env->GetBody();
body->generate_random(50, -0.25, 0.25, -0.25, 0.25, -0.25, 0.25 );
CvRNG rng = cvRNG();
int index = 0; //index of board's position to save, is used to enumerate snapshots
for(size_t i = 0; i < board_pos.size(); i++ )
{
CvPoint3D64f point = board_pos[i];
body->SetPosition(point.x,point.y,point.z);
//generate random orientation of the board
unsigned int rn = cvRandInt(&rng);
//scale to 90 degrees
rn = rn%90;
double slant = (double)rn-45-90; //angle of slant of the bord relatively to its horizontal direction
rn = cvRandInt(&rng);
//scale to 360 degrees
rn = rn%360;
double azimuth = rn; //azimuth
//set slant and azimuth to 0
slant = azimuth = 0;
double sn = sin(azimuth*CV_PI/180);
double cs = cos(azimuth*CV_PI/180);
//generate rotation matrix
CvMat* mat_azimuth = cvCreateMat( 3, 3, CV_64FC1);
mat_azimuth->data.db[0] = cs;
mat_azimuth->data.db[1] = -sn;
mat_azimuth->data.db[2] = 0;
mat_azimuth->data.db[3] = sn;
mat_azimuth->data.db[4] = cs;
mat_azimuth->data.db[5] = 0;
mat_azimuth->data.db[6] = 0;
mat_azimuth->data.db[7] = 0;
mat_azimuth->data.db[8] = 1;
sn = sin(slant*CV_PI/180);
cs = cos(slant*CV_PI/180);
CvMat* mat_slant = cvCreateMat( 3, 3, CV_64FC1); //rotation around X axis
mat_slant->data.db[0] = 1;
mat_slant->data.db[1] = 0;
mat_slant->data.db[2] = 0;
mat_slant->data.db[3] = 0;
mat_slant->data.db[4] = cs;
mat_slant->data.db[5] = -sn;
mat_slant->data.db[6] = 0;
mat_slant->data.db[7] = sn;
mat_slant->data.db[8] = cs;
CvMat* rot = cvCreateMat( 3, 3, CV_64FC1); //rotation around X axis
//create complete rotation matrix
cvMatMul(mat_azimuth, mat_slant, rot);
//these are coordinates of board's axis in WCS
body->SetRotation(rot->data.db);
//project images onto all cameras
env->Capture();
//save 3d points of corners into the file
char fname[2048];
sprintf(fname, "%sPoints%d.3d", g_filepath, index );
body->Save(fname, true);
//save shots from camera
sprintf(fname, "%salldata.txt", g_filepath );
env->Save(fname);
}
//destroy everything
delete env;
return 0;
}