首页 \ 问答 \ 在点云库(PCL)中设置ISSKeypoint3D的法线(Setting normals for ISSKeypoint3D in Point Cloud Library (PCL))

在点云库(PCL)中设置ISSKeypoint3D的法线(Setting normals for ISSKeypoint3D in Point Cloud Library (PCL))

我正在尝试在PCL中的点云上计算ISS3D关键点。 我想设置法线,因为我不确定ISS关键点估计是否以正确的方向翻转它们。 但是,当我尝试设置这样的法线时

typedef pcl::PointCloud<pcl::PointXYZRGB> > PointCloud;

PointCloud::Ptr detecISSKeypoints(PointCloud::Ptr cloud, pcl::PointCloud<pcl::PointNormal>::Ptr normals, float resolution) {
  pcl::PointCloud<pcl::PointXYZRGB>::Ptr keypoints(new pcl::PointCloud<pcl::PointXYZRGB>);
  pcl::ISSKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZRGB> detector;
  detector.setInputCloud(cloud);
  detector.setNormals(normals);
  pcl::search::KdTree<pcl::PointXYZRGB>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZRGB>);
  detector.setSearchMethod(kdtree);
  detector.setSalientRadius(6 * resolution);
  detector.setNonMaxRadius(6 * resolution);
  detector.setMinNeighbors(6);
  detector.setThreshold21(0.975);
  detector.setThreshold32(0.975);
  detector.setNumberOfThreads(4);
  detector.compute(*keypoints);
  return keypoints;
}

我得到一个错误, setNormals期待一个const PointCloudNConstPtr& 。 我试图将法线的指针转换为const pcl::PointCloud<pcl::PointNormal>::ConstPtr ,但是这不起作用。

我该如何设置法线?


I'm trying to compute ISS3D keypoints on a point cloud in PCL. I want to set the normals because I'm not sure if the ISS keypoint estimation flips them in the correct direction. However, when I try to set the normals like this

typedef pcl::PointCloud<pcl::PointXYZRGB> > PointCloud;

PointCloud::Ptr detecISSKeypoints(PointCloud::Ptr cloud, pcl::PointCloud<pcl::PointNormal>::Ptr normals, float resolution) {
  pcl::PointCloud<pcl::PointXYZRGB>::Ptr keypoints(new pcl::PointCloud<pcl::PointXYZRGB>);
  pcl::ISSKeypoint3D<pcl::PointXYZRGB, pcl::PointXYZRGB> detector;
  detector.setInputCloud(cloud);
  detector.setNormals(normals);
  pcl::search::KdTree<pcl::PointXYZRGB>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZRGB>);
  detector.setSearchMethod(kdtree);
  detector.setSalientRadius(6 * resolution);
  detector.setNonMaxRadius(6 * resolution);
  detector.setMinNeighbors(6);
  detector.setThreshold21(0.975);
  detector.setThreshold32(0.975);
  detector.setNumberOfThreads(4);
  detector.compute(*keypoints);
  return keypoints;
}

I get an error that setNormals is expecting a const PointCloudNConstPtr&. I tried to convert the pointer of the normals to const pcl::PointCloud<pcl::PointNormal>::ConstPtr, however this didn't work.

How can I set the normals?


原文:https://stackoverflow.com/questions/35893197
更新时间:2023-03-13 17:03

最满意答案

你希望sqlite替换. 按当前文件夹路径。 但它没有提供此功能。 您可以改为提供完整路径

import os
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
DB_PATH = SCRIPT_DIR +  '/data/sources.db'
...
con = sqlite3.connect(DB_PATH, detect_types = sqlite3.PARSE_DECLTYPES, timeout = 10)

如果文件/表之前不存在,您应该简单地执行一种数据库初始化来创建表。 但这只不过是CREATE TABLE语句

CREATE TABLE sources (...) VALUES ();

You expect sqlite to replace the . by the current folder path. But it doesn't provide this feature. You can instead provide the full path

import os
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
DB_PATH = SCRIPT_DIR +  '/data/sources.db'
...
con = sqlite3.connect(DB_PATH, detect_types = sqlite3.PARSE_DECLTYPES, timeout = 10)

If the file/table did not exist before, you should simply perfom a kind of database initilization to create the table. But this would be nothing more than the CREATE TABLE statement

CREATE TABLE sources (...) VALUES ();

相关问答

更多