【发布时间】:2016-08-15 01:34:09
【问题描述】:
我正在开发一个应用程序:
- 读取 7 个模型文件并训练 PPF 3D 检测器;
- 读取场景文件并尝试与检测器匹配;
- 将结果存储在文件中(视觉检索)。
我一直在关注OpenCV tutorial ,但有几件事我连看documentation都看不懂:
- detector.match() 将模型在场景中的 pose 存储在 结果中。但据我了解,pose是模型的位置和方向,但是我怎么知道是哪个模型呢?
- 当我打印第一个结果的姿势时,它给了我一个带有浮点值的 4x4 表格。我在哪里可以找到它们的含义?
- 仍然在进行姿势打印,它给了我 模型索引,起初我认为这是我用来训练检测器的模型的编号。问题是:我使用 7 个模型来训练检测器,第一个结果给了我 “Pose to Model Index 12”。所以我认为这是 Drost(2012) 上的模型描述索引。但是如果真的是模型描述索引,我怎么知道这个索引属于哪个模型呢?
- 根据教程,使用 transformPCPose 并将其写入 PLY 文件会给出匹配的视觉结果,但 documentation 说它返回一个 4x4 姿势矩阵,但我是仍在打印它,它给了我一个超过 16 个顶点的奇怪图像,所以我不明白教程在做什么。我怎样才能像教程一样在文件上写视觉结果?
我还读到 ICP 用于纠正任何姿势错误,但使用不带 ICP 的 PPF 可以得到可接受的结果。无论如何,我尝试使用 ICP,但它总是给我“Bad argument error”。
我使用的代码如下:
void computer_vision_3d(string in_path)
{
Mat files_clouds[NUM_OF_FILES]; // > Stores the point cloud of all objects
Mat scene_cloud; // > Stores the scene point cloud
ppf_match_3d::PPF3DDetector
detector(RELATIVE_SAMPLING_STEP, RELATIVE_DISTANCE_STEP); // > Matches the model with the scene
vector<Pose3DPtr> results; // > Stores the results of the processing
// ! Phase 1 - Train Model
scene_cloud = loadPLYSimple(DEFAULT_SCENE_PATH.c_str(), PARAM_NORMALS);
for(int i = 0; i < NUM_OF_FILES; i++)
{
// . Init Point Cloud
string file_path = DEFAULT_OBJECT_PATH + to_string(i) + ".ply";
files_clouds[i] = loadPLYSimple(file_path.c_str(), PARAM_NORMALS);
// . Train Model
detector.trainModel(files_clouds[i]);
}
// ! Phase 2 - Detect from scene
detector.match( scene_cloud, results,
RELATIVE_SCENE_SAMPLE_STEP, RELATIVE_SCENE_DISTANCE);
// ! Phase 3 - Results
if(results.size() > 0)
{
Pose3DPtr result = results[0];
result->printPose();
// ! Transforms the point cloud to the model pose
for(int i = 0; i < NUM_OF_FILES; i++)
{
Mat pct = transformPCPose(files_clouds[i], result->pose);
string f_name = "match" + to_string(i) + ".ply";
writePLY(pct, f_name.c_str());
}
}
}
其中一个模型、场景和结果:
图 1 - 七个模型之一。
图 2 - 场景。
图 3 - 奇怪的结果。
【问题讨论】:
标签: c++ opencv 3d computer-vision mesh