本文整理汇总了C++中vcl_vector::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ vcl_vector::resize方法的具体用法?C++ vcl_vector::resize怎么用?C++ vcl_vector::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcl_vector
的用法示例。
在下文中一共展示了vcl_vector::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPointVector
void VglPlus::loadPointVector(const char *fileName, vcl_string &imageName, vcl_vector<vgl_point_2d<double>> &wldPts, vcl_vector< vgl_point_2d<double> > &imgPts)
{
assert(wldPts.size() == 0);
assert(imgPts.size() == 0);
vsl_b_ifstream bfs_in(fileName);
assert(bfs_in.is().good() == true);
char strName[1024] = {NULL};
vsl_b_read(bfs_in, strName);
imageName = vcl_string(strName);
int num = 0;
vsl_b_read(bfs_in, num);
wldPts.resize(num);
imgPts.resize(num);
for (int i = 0; i<num; i++) {
vsl_b_read(bfs_in, wldPts[i]);
}
for (int i = 0; i<num; i++) {
vsl_b_read(bfs_in, imgPts[i]);
}
bfs_in.close();
}
示例2: detect_lines
void CvxLSD::detect_lines(const vil_image_view<vxl_byte> & image, vcl_vector<LSDLineSegment> & line_segments)
{
assert(image.nplanes() == 3 || image.nplanes() == 1);
vil_image_view<vxl_byte> grayImage;
if (image.nplanes() == 3) {
vil_convert_planes_to_grey(image, grayImage);
}
else
{
grayImage = image;
}
double * imageData = NULL;
double * out = NULL;
int width = grayImage.ni();
int height = grayImage.nj();
int n = 0;
imageData = (double *) malloc( width * height * sizeof(double) );
assert(imageData);
for(int j=0; j<height; j++)
{
for(int i=0; i<width; i++)
{
imageData[i + j * width] = grayImage(i, j);
}
}
/* LSD call */
out = lsd(&n, imageData, width, height);
/* print output */
// printf("%d line segments found:\n",n);
line_segments.resize(n);
for(int i=0; i<n; i++)
{
double x1 = out[7*i + 0];
double y1 = out[7*i + 1];
double x2 = out[7*i + 2];
double y2 = out[7*i + 3];
double line_width = out[7*i + 4];
double p = out[7*i + 5];
double tmp = out[7*i + 6];
line_segments[i].seg_ = vgl_line_segment_2d<double>(vgl_point_2d<double>(x1, y1), vgl_point_2d<double>(x2, y2));
line_segments[i].width_ = line_width;
line_segments[i].angle_precision_ = p;
line_segments[i].NFA_ = tmp;
}
free( (void *) imageData );
free( (void *) out );
}
示例3: homography_RANSAC
bool RrelPlus::homography_RANSAC(vcl_vector< vgl_point_2d< double > > const& first,
vcl_vector< vgl_point_2d< double > > const& second,
vcl_vector< bool > & inlier,
vgl_h_matrix_2d< double > & H,
const homography_ransac_parameter & param) // pixel
{
assert(first.size() >= 4);
assert(first.size() == second.size());
assert(inlier.size() == 0);
double error_threshold = param.error_tolerance;
bool isOk = vgl_homography_ransac(first, second, H, param);
if(!isOk)
{
return false;
}
inlier.resize(first.size());
for (int i = 0; i<first.size(); i++) {
const vgl_homg_point_2d<double> p1 = (vgl_homg_point_2d<double>)first[i];
const vgl_homg_point_2d<double> p2 = (vgl_homg_point_2d<double>)second[i];
vgl_homg_point_2d<double> proj_p1 = H(p1);
double x = proj_p1.x()/proj_p1.w();
double y = proj_p1.y()/proj_p1.w();
double dx = x - p2.x();
double dy = y - p2.y();
double dis_2 = dx * dx + dy * dy;
if (dis_2 <= error_threshold * error_threshold) {
inlier[i] = true;
}
else
{
inlier[i] = false;
}
}
return true;
}