本文整理汇总了C++中vcl_vector::front方法的典型用法代码示例。如果您正苦于以下问题:C++ vcl_vector::front方法的具体用法?C++ vcl_vector::front怎么用?C++ vcl_vector::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcl_vector
的用法示例。
在下文中一共展示了vcl_vector::front方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_data
void vnl_flann::set_data(const vcl_vector<vnl_vector<double> > & data)
{
assert(data.size() > 0);
const int dim = (int)data.front().size();
// wrap dataset
vnl_matrix<double> data_mat((int)data.size(), (int)data.front().size());
for (int i = 0; i<data.size(); i++) {
assert(data[i].size() == dim);
data_mat.set_row(i, data[i]);
}
Matrix<double> dataset(data_mat.data_block(), (int)data.size(), dim);
index_ = Index<L2<double> > (dataset, flann::KDTreeIndexParams(4));
index_.buildIndex();
dim_ = dim;
}
示例2: load
void vnl_flann::load(const char *index_file, const vcl_vector<vnl_vector<double> > & data)
{
assert(index_file);
const int dim = (int)data.front().size();
// wrap dataset
vnl_matrix<double> data_mat((int)data.size(), (int)data.front().size());
for (int i = 0; i<data.size(); i++) {
assert(data[i].size() == dim);
data_mat.set_row(i, data[i]);
}
Matrix<double> dataset(data_mat.data_block(), (int)data.size(), dim);
SavedIndexParams index_params((std::string(index_file)));
index_ = flann::Index<flann::L2<double>>(dataset, index_params, flann::L2<double>());
dim_ = dim;
}
示例3: search
void vnl_flann::search(const vcl_vector<vnl_vector<double> > & query_data,
vcl_vector<vcl_vector<int> > & indices,
vcl_vector<vcl_vector<double> > & dists,
int knn,
int num_search_leaf) const
{
const int dim = (int)query_data.front().size();
assert(dim == dim_);
// wrap query data
vnl_matrix<double> query_data_mat((int)query_data.size(), (int)query_data.front().size(), dim);
for (int i = 0; i<query_data.size(); i++) {
query_data_mat.set_row(i, query_data[i]);
}
Matrix<double> query_data_wrap(query_data_mat.data_block(), (int)query_data.size(), dim);
index_.knnSearch(query_data_wrap, indices, dists, knn, flann::SearchParams(num_search_leaf));
}
示例4: lineEllipseIntersection
int VglPlus::lineEllipseIntersection(const vgl_line_2d<double> & line, const vgl_ellipse_2d<double> & ellipse,
vgl_point_2d<double> & pt1, vgl_point_2d<double> & pt2, bool isMajorAxis)
{
vgl_polygon<double> poly = ellipse.polygon();
assert(poly.num_sheets() == 1);
int num = 0;
// printf("sheet number is %u\n", poly.num_sheets());
const vcl_vector< vgl_point_2d< double > > sheet = poly[0];
assert( sheet.size() > 1 );
for ( unsigned int v = 0; v < sheet.size() - 1; v++ )
{
vgl_line_segment_2d< double > edge( sheet[v], sheet[v+1] );
vgl_point_2d<double> p;
bool isIntersection = vgl_intersection(line, edge, &p);
if (isIntersection) {
if (num == 0) {
pt1 = p;
num++;
}
else if(num == 1)
{
pt2 = p;
num++;
}
}
if (num == 2) {
break;
}
}
// last line segment
if(num != 2)
{
vgl_line_segment_2d< double > edge( sheet.back(), sheet.front());
vgl_point_2d<double> p;
bool isIntersection = vgl_intersection(line, edge, &p);
if (isIntersection) {
if (num == 0) {
pt1 = p;
num++;
}
else if(num == 1)
{
pt2 = p;
num++;
}
}
}
double disDif = 20;
if (num == 2 && isMajorAxis) {
double dis = vgl_distance(pt1, pt2);
// distance of two points should be as the similar length of minor or major axis
double dis1 = vgl_distance(ellipse.major_diameter().point1(), ellipse.major_diameter().point2());
double dis2 = vgl_distance(ellipse.minor_diameter().point1(), ellipse.minor_diameter().point2());
if (fabs(dis - dis1) >= disDif && fabs(dis - dis2) >= disDif) {
num = 0;
}
}
return num;
}