【问题标题】:Normalizing Image Descriptor OpenCV Java规范化图像描述符 OpenCV Java
【发布时间】:2016-02-11 16:51:27
【问题描述】:

您好,我将在 OpenCV Java 中实现 Opencv BOW 算法。我试图将大部分代码转换为java。但是我被困在这里,因为我不明白这里到底发生了什么。

void BOWImgDescriptorExtractor::compute( InputArray keypointDescriptors, OutputArray _imgDescriptor, std::vector<std::vector<int> >* pointIdxsOfClusters )
{
int clusterCount = descriptorSize(); // = vocabulary.rows

// Match keypoint descriptors to cluster center (to vocabulary)
std::vector<DMatch> matches;
dmatcher->match( keypointDescriptors, matches );

// Compute image descriptor
if( pointIdxsOfClusters )
{
    pointIdxsOfClusters->clear();
    pointIdxsOfClusters->resize(clusterCount);
}

_imgDescriptor.create(1, clusterCount, descriptorType());
_imgDescriptor.setTo(Scalar::all(0));

Mat imgDescriptor = _imgDescriptor.getMat();

float *dptr = imgDescriptor.ptr<float>();
for( size_t i = 0; i < matches.size(); i++ )
{
    int queryIdx = matches[i].queryIdx;
    int trainIdx = matches[i].trainIdx; // cluster index
    CV_Assert( queryIdx == (int)i );

    dptr[trainIdx] = dptr[trainIdx] + 1.f;
    if( pointIdxsOfClusters )
        (*pointIdxsOfClusters)[trainIdx].push_back( queryIdx );
}

// Normalize image descriptor.
imgDescriptor /= keypointDescriptors.size().height;
}     

在最后一行它说,规范化描述符。我想知道如何在 java 中实现该部分。任何帮助,将不胜感激。

【问题讨论】:

  • 它只是将imgDescriptor中的每个元素除以关键点的数量
  • 谢谢miki,我试试看

标签: java c++ opencv image-processing sift


【解决方案1】:

我试过像你一样做,但对我来说效果不佳,所以我用弓形训练器功能构建了 opencv2.9,效果很好,而且我有 96℅ 的精度

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-06
    • 1970-01-01
    • 2013-09-03
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 2018-06-28
    相关资源
    最近更新 更多