本文整理汇总了C++中VectorXf::cwise方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorXf::cwise方法的具体用法?C++ VectorXf::cwise怎么用?C++ VectorXf::cwise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorXf
的用法示例。
在下文中一共展示了VectorXf::cwise方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: projected
void D3DCloudProjector::projectCloud(int id, const sensor_msgs::PointCloud& data, const std::vector<int>& interest_region_indices) {
MatrixXf& oriented = orienter_->oriented_clouds_[id];
// -- Get a copy of the projected points.
MatrixXf projected(oriented.rows(), 2);
int c=0;
for(int i=0; i<3; ++i) {
if(i == axis_of_projection_)
continue;
projected.col(c) = oriented.col(i);
++c;
}
// -- Transform into pixel units. projected is currently in meters, centered at 0.
//projected *= pixels_per_meter_;
for(int i=0; i<projected.rows(); ++i) {
projected(i, 0) *= pixels_per_meter_;
projected(i, 1) *= pixels_per_meter_;
}
// -- Find min and max of u and v. TODO: noise sensitivity?
// u is the col number in the image plane, v is the row number.
float min_v = FLT_MAX;
float min_u = FLT_MAX;
float max_v = -FLT_MAX;
float max_u = -FLT_MAX;
for(int i=0; i<projected.rows(); ++i) {
float u = projected(i, 0);
float v = projected(i, 1);
if(u < min_u)
min_u = u;
if(u > max_u)
max_u = u;
if(v < min_v)
min_v = v;
if(v > max_v)
max_v = v;
}
// -- Translate to coordinate system where (0,0) is the upper right of the image.
for(int i=0; i<projected.rows(); ++i) {
projected(i, 0) -= min_u;
projected(i, 1) = max_v - projected(i, 1);
}
// -- Get the max depth.
float max_depth = -FLT_MAX;
float min_depth = FLT_MAX;
for(int i=0; i<oriented.rows(); ++i) {
if(oriented(i, axis_of_projection_) > max_depth)
max_depth = oriented(i, axis_of_projection_);
if(oriented(i, axis_of_projection_) < min_depth)
min_depth = oriented(i, axis_of_projection_);
}
// -- Compute the normalized depths. Depths are between 0 and 1, with 1 meaning closest and 0 meaning furthest.
VectorXf depths = oriented.col(axis_of_projection_);
if(axis_of_projection_ == 1)
depths = -depths;
depths = depths.cwise() - depths.minCoeff();
depths = depths / depths.maxCoeff();
// -- Fill the IplImages.
assert(sizeof(float) == 4);
CvSize size = cvSize(ceil(max_u - min_u), ceil(max_v - min_v));
IplImage* acc = cvCreateImage(size, IPL_DEPTH_32F, 1);
IplImage* intensity = cvCreateImage(size, IPL_DEPTH_32F, 1);
IplImage* depth = cvCreateImage(size, IPL_DEPTH_32F, 1);
cvSetZero(acc);
cvSetZero(depth);
cvSetZero(intensity);
assert(projected.rows() == (int)interest_region_indices.size());
for(int i=0; i<projected.rows(); ++i) {
int row = floor(projected(i, 1));
int col = floor(projected(i, 0));
// Update accumulator.
assert(interest_region_indices[i] < (int)data.channels[0].values.size() && (int)interest_region_indices[i] >= 0);
((float*)(acc->imageData + row * acc->widthStep))[col]++;
// Add to intensity values.
float val = (float)data.channels[0].values[interest_region_indices[i]] / 255.0 * (3.0 / 4.0) + 0.25;
assert(val <= 1.0 && val >= 0.0);
((float*)(intensity->imageData + row * intensity->widthStep))[col] += val;
// Add to depth values.
((float*)(depth->imageData + row * depth->widthStep))[col] += depths(i); //
}
// -- Normalize by the number of points falling in each pixel.
for(int v=0; v<acc->height; ++v) {
float* intensity_ptr = (float*)(intensity->imageData + v * intensity->widthStep);
float* depth_ptr = (float*)(depth->imageData + v * depth->widthStep);
float* acc_ptr = (float*)(acc->imageData + v * acc->widthStep);
for(int u=0; u<acc->width; ++u) {
if(*acc_ptr == 0) {
*intensity_ptr = 0;
//.........这里部分代码省略.........