重用BOWImgDescriptorExtractor的描述符 [英] Re-using descriptors with BOWImgDescriptorExtractor

查看:1198
本文介绍了重用BOWImgDescriptorExtractor的描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码用于通过其SIFT特征描述符对一组图像进行聚类。

I have the following code which is intended to cluster a set of images via their SIFT feature descriptors.

cv::BOWKMeansTrainer trainer = cv::BOWKMeansTrainer(n_clusters);

for (Image* image : get_images()) {
    trainer.add(image->get_descriptors());
}

cv::Mat vocabulary = trainer.cluster();
cv::BOWImgDescriptorExtractor extractor(Image::get_extractor(), Image::get_matcher());
extractor.setVocabulary(vocabulary);

for (Image* image : get_images()) {
    cv::Mat bow_descriptor;
    extractor.compute(image->get_data(), image->get_key_points(), bow_descriptor);

    // Determine which cluster the image matches best, via bow_descriptor..
}

我的问题是,我已经计算了图像的描述符,在我调用 BowImgDescriptorExtractor :: compute 的点,因此它将是理想的如果我可以提供这些而不是 BowImgDescriptorExtractor :: compute 重新计算它们。正如你所看到的,我能够提供关键点,但不能找到一种方法来提供描述符。

The problem I have, is that I have already computed the descriptors for the images at the point I call BowImgDescriptorExtractor::compute, and so it would be ideal if I could provide these rather than BowImgDescriptorExtractor::compute re-calculating them. As you can see, I am able to provide the key-points, but not able to find a way to provide the descriptors.

有什么办法让我重新使用我已经在这里创建的描述符?

Is there any way for me to re-use the descriptors I have already created here?

推荐答案

我已经诉诸于写我自己的版本 BOWImgDescriptorExtractor ,它允许我直接传递描述符,而不必重新计算它们。

I have resorted to writing my own version of BOWImgDescriptorExtractor, which allows me to directly pass in the descriptors rather than having to re-compute them.

我只是重复使用现有的源代码,但改变了方法签名,允许我传入描述符,而不是图像数据和关键点,当然也删除了方法体中不必要的计算。

I simply re-used the existing source code, but changed the method signature to allow me to pass in the descriptors, rather than the image data and key points, and also of course removed the unnecessary calculations in the method body.

注意:我目前运行的版本2.4.9的OpenCV,但似乎在3.0.0版本(尚未发布),他们有重载 compute 解决此问题。

Note: I'm currently running version 2.4.9 of OpenCV, but it appears that in version 3.0.0 (which is not yet released), they have overloaded compute to address this issue.

这篇关于重用BOWImgDescriptorExtractor的描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆