本文整理汇总了C++中Pointcloud::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointcloud::clear方法的具体用法?C++ Pointcloud::clear怎么用?C++ Pointcloud::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pointcloud
的用法示例。
在下文中一共展示了Pointcloud::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QProgressDialog
void scan3d::reconstruct_model_simple(Pointcloud & pointcloud, CalibrationData const& calib,
cv::Mat const& pattern_image, cv::Mat const& min_max_image, cv::Mat const& color_image,
cv::Size const& projector_size, int threshold, double max_dist, QWidget * parent_widget)
{
if (!pattern_image.data || pattern_image.type()!=CV_32FC2)
{ //pattern not correctly decoded
std::cerr << "[reconstruct_model] ERROR invalid pattern_image\n";
return;
}
if (!min_max_image.data || min_max_image.type()!=CV_8UC2)
{ //pattern not correctly decoded
std::cerr << "[reconstruct_model] ERROR invalid min_max_image\n";
return;
}
if (color_image.data && color_image.type()!=CV_8UC3)
{ //not standard RGB image
std::cerr << "[reconstruct_model] ERROR invalid color_image\n";
return;
}
if (!calib.is_valid())
{ //invalid calibration
return;
}
//parameters
//const unsigned threshold = config.value("main/shadow_threshold", 70).toUInt();
//const double max_dist = config.value("main/max_dist_threshold", 40).toDouble();
//const bool remove_background = config.value("main/remove_background", true).toBool();
//const double plane_dist = config.value("main/plane_dist", 100.0).toDouble();
double plane_dist = 100.0;
/* background removal
cv::Point2i plane_coord[3];
plane_coord[0] = cv::Point2i(config.value("background_plane/x1").toUInt(), config.value("background_plane/y1").toUInt());
plane_coord[1] = cv::Point2i(config.value("background_plane/x2").toUInt(), config.value("background_plane/y2").toUInt());
plane_coord[2] = cv::Point2i(config.value("background_plane/x3").toUInt(), config.value("background_plane/y3").toUInt());
if (plane_coord[0].x<=0 || plane_coord[0].x>=pattern_local.cols
|| plane_coord[0].y<=0 || plane_coord[0].y>=pattern_local.rows)
{
plane_coord[0] = cv::Point2i(50, 50);
config.setValue("background_plane/x1", plane_coord[0].x);
config.setValue("background_plane/y1", plane_coord[0].y);
}
if (plane_coord[1].x<=0 || plane_coord[1].x>=pattern_local.cols
|| plane_coord[1].y<=0 || plane_coord[1].y>=pattern_local.rows)
{
plane_coord[1] = cv::Point2i(50, pattern_local.rows-50);
config.setValue("background_plane/x2", plane_coord[1].x);
config.setValue("background_plane/y2", plane_coord[1].y);
}
if (plane_coord[2].x<=0 || plane_coord[2].x>=pattern_local.cols
|| plane_coord[2].y<=0 || plane_coord[2].y>=pattern_local.rows)
{
plane_coord[2] = cv::Point2i(pattern_local.cols-50, 50);
config.setValue("background_plane/x3", plane_coord[2].x);
config.setValue("background_plane/y3", plane_coord[2].y);
}
*/
//init point cloud
int scale_factor = 1;
int out_cols = pattern_image.cols/scale_factor;
int out_rows = pattern_image.rows/scale_factor;
pointcloud.clear();
pointcloud.init_points(out_rows, out_cols);
pointcloud.init_color(out_rows, out_cols);
//progress
QProgressDialog * progress = NULL;
if (parent_widget)
{
progress = new QProgressDialog("Reconstruction in progress.", "Abort", 0, pattern_image.rows, parent_widget,
Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint);
progress->setWindowModality(Qt::WindowModal);
progress->setWindowTitle("Processing");
progress->setMinimumWidth(400);
}
//take 3 points in back plane
/*cv::Mat plane;
if (remove_background)
{
cv::Point3d p[3];
for (unsigned i=0; i<3;i++)
{
for (unsigned j=0;
j<10 && (
INVALID(pattern_local.at<cv::Vec2f>(plane_coord[i].y, plane_coord[i].x)[0])
|| INVALID(pattern_local.at<cv::Vec2f>(plane_coord[i].y, plane_coord[i].x)[1])); j++)
{
plane_coord[i].x += 1.f;
}
const cv::Vec2f & pattern = pattern_local.at<cv::Vec2f>(plane_coord[i].y, plane_coord[i].x);
const float col = pattern[0];
const float row = pattern[1];
if (projector_size.width<=static_cast<int>(col) || projector_size.height<=static_cast<int>(row))
{ //abort
//.........这里部分代码省略.........
示例2: INVALID
void scan3d::reconstruct_model_patch_center(Pointcloud & pointcloud, CalibrationData const& calib,
cv::Mat const& pattern_image, cv::Mat const& min_max_image, cv::Mat const& color_image,
cv::Size const& projector_size, int threshold, double max_dist, QWidget * parent_widget)
{
if (!pattern_image.data || pattern_image.type()!=CV_32FC2)
{ //pattern not correctly decoded
std::cerr << "[reconstruct_model] ERROR invalid pattern_image\n";
return;
}
if (!min_max_image.data || min_max_image.type()!=CV_8UC2)
{ //pattern not correctly decoded
std::cerr << "[reconstruct_model] ERROR invalid min_max_image\n";
return;
}
if (color_image.data && color_image.type()!=CV_8UC3)
{ //not standard RGB image
std::cerr << "[reconstruct_model] ERROR invalid color_image\n";
return;
}
if (!calib.is_valid())
{ //invalid calibration
return;
}
//parameters
//const unsigned threshold = config.value("main/shadow_threshold", 70).toUInt();
//const double max_dist = config.value("main/max_dist_threshold", 40).toDouble();
//const bool remove_background = config.value("main/remove_background", true).toBool();
//const double plane_dist = config.value("main/plane_dist", 100.0).toDouble();
double plane_dist = 100.0;
/* background removal
cv::Point2i plane_coord[3];
plane_coord[0] = cv::Point2i(config.value("background_plane/x1").toUInt(), config.value("background_plane/y1").toUInt());
plane_coord[1] = cv::Point2i(config.value("background_plane/x2").toUInt(), config.value("background_plane/y2").toUInt());
plane_coord[2] = cv::Point2i(config.value("background_plane/x3").toUInt(), config.value("background_plane/y3").toUInt());
if (plane_coord[0].x<=0 || plane_coord[0].x>=pattern_local.cols
|| plane_coord[0].y<=0 || plane_coord[0].y>=pattern_local.rows)
{
plane_coord[0] = cv::Point2i(50, 50);
config.setValue("background_plane/x1", plane_coord[0].x);
config.setValue("background_plane/y1", plane_coord[0].y);
}
if (plane_coord[1].x<=0 || plane_coord[1].x>=pattern_local.cols
|| plane_coord[1].y<=0 || plane_coord[1].y>=pattern_local.rows)
{
plane_coord[1] = cv::Point2i(50, pattern_local.rows-50);
config.setValue("background_plane/x2", plane_coord[1].x);
config.setValue("background_plane/y2", plane_coord[1].y);
}
if (plane_coord[2].x<=0 || plane_coord[2].x>=pattern_local.cols
|| plane_coord[2].y<=0 || plane_coord[2].y>=pattern_local.rows)
{
plane_coord[2] = cv::Point2i(pattern_local.cols-50, 50);
config.setValue("background_plane/x3", plane_coord[2].x);
config.setValue("background_plane/y3", plane_coord[2].y);
}
*/
//init point cloud
//初始化点云数据为NAN,大小是经过缩放的
int scale_factor_x = 1;
int scale_factor_y = (projector_size.width>projector_size.height ? 1 : 2); //XXX HACK: preserve regular aspect ratio XXX HACK
int out_cols = projector_size.width/scale_factor_x;
int out_rows = projector_size.height/scale_factor_y;
pointcloud.clear();
pointcloud.init_points(out_rows, out_cols);//NAN点:point初始化(pointcloud成员变量)
pointcloud.init_color(out_rows, out_cols);//白色图像:color初始化(pointcloud成员变量)
//progress
//take 3 points in back plane
/*cv::Mat plane;
if (remove_background)
{
cv::Point3d p[3];
for (unsigned i=0; i<3;i++)
{
for (unsigned j=0;
j<10 && (
INVALID(pattern_local.at<cv::Vec2f>(plane_coord[i].y, plane_coord[i].x)[0])
|| INVALID(pattern_local.at<cv::Vec2f>(plane_coord[i].y, plane_coord[i].x)[1])); j++)
{
plane_coord[i].x += 1.f;
}
const cv::Vec2f & pattern = pattern_local.at<cv::Vec2f>(plane_coord[i].y, plane_coord[i].x);
const float col = pattern[0];
const float row = pattern[1];
if (projector_size.width<=static_cast<int>(col) || projector_size.height<=static_cast<int>(row))
{ //abort
continue;
}
//shoot a ray through the image: u=\lambda*v + q
cv::Point3d u1 = camera.to_world_coord(plane_coord[i].x, plane_coord[i].y);
cv::Point3d v1 = camera.world_ray(plane_coord[i].x, plane_coord[i].y);
//.........这里部分代码省略.........