【问题标题】:Using FLANN with separate *double arrays将 FLANN 与单独的 *double 数组一起使用
【发布时间】:2013-03-19 10:24:36
【问题描述】:

我正在编写一段代码来执行与 128 维描述符的特征匹配。

图像的所有描述符都存储在 std::vector 中,其中 InterestPoint 包含一个成员 *double desc,即描述符向量。

现在我想在 Flann 矩阵中使用这个结构,以便稍后进行近似最近邻特征匹配,我将其初始化如下:

std::vector<InterestPoint> ip1;
//processing for building vector containing interest points
flann::Matrix<double> input(new double[ip1.size()*128], ip1.size(),  128);

我现在如何用来自 ip1 向量的每个元素的 *double desc 成员填充这个 flann::Matrix?这是我尝试过的:

for(size_t i = 0; i < ip1.size(); i++)
{
    for(size_t j = 0; j < 128; j++)
    {
        input[i][j] = ip1[i].ivec[j];
    }
}

已编译但没有成功。 flann 提供了一种访问 flann::Matrix 每一行的方法,使用运算符 [],因此 Matrix 类是行主要的。

提前致谢,

【问题讨论】:

  • 你能澄清一下“没有成功”是什么意思吗?您是否尝试过单步执行循环以检查您正在访问的索引处的 ip1 和输入值是否有效?
  • 我按照你说的做了,确实,将我的指针放在 Flann 中没有问题,问题是我的指针由于某种原因在我的函数中无效叫。无论如何感谢您的宝贵时间!

标签: c++ feature-detection approximate-nn-searching


【解决方案1】:

我不确定“InterestPoint”中的内容。 但我认为这个示例代码会有所帮助。

struct MyPoint
{
    MyPoint (double x, double y, double z) {this->x=x; this->y=y; this->z=z;}
    double x,y,z;
};

std::vector<MyPoint> points;
points.push_back(MyPoint(0, 0, 0));
points.push_back(MyPoint(1, 1, 1));
points.push_back(MyPoint(-1, -1, -1));
flann::Matrix<double> points_mat = flann::Matrix<double>(&points[0].x, points.size(), 3);

【讨论】:

  • 这个答案可能会受益于更多关于正在发生的事情的评论。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-04-15
  • 2013-11-24
  • 2015-08-18
  • 2017-12-31
  • 2020-12-03
  • 1970-01-01
  • 2014-11-12
相关资源
最近更新 更多