SURF和SIFT算法在OpenCV 3.0 Java中不起作用 [英] SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java

查看:1280
本文介绍了SURF和SIFT算法在OpenCV 3.0 Java中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java中使用OpenCV 3.0(最新版本),但是当我使用SURF算法或SIFT算法时它不起作用并抛出Exception,其中说: OpenCV错误:错误的参数(指定的功能)不支持探测器类型。)在cv :: javaFeatureDetector :: create

I am using OpenCV 3.0 (the latest version) in Java, but when I use SURF algorithm or SIFT algorithm it doesn't work and throws Exception which says: OpenCV Error: Bad argument (Specified feature detector type is not supported.) in cv::javaFeatureDetector::create

我用google搜索了,但给出了这种答案问题并没有解决我的问题。如果有人知道这个问题,请告诉我。

I have googled, but the answers which was given to this kind of questions did not solve my problem. If anyone knows about this problem please let me know.

提前致谢!

更新:以下第三行代码抛出异常。

Update: The code below in third line throws exception.

        Mat img_object = Imgcodecs.imread("data/img_object.jpg");
        Mat img_scene = Imgcodecs.imread("data/img_scene.jpg");

        FeatureDetector detector = FeatureDetector.create(FeatureDetector.SURF);
        MatOfKeyPoint keypoints_object = new MatOfKeyPoint();
        MatOfKeyPoint keypoints_scene = new MatOfKeyPoint();

        detector.detect(img_object, keypoints_object);
        detector.detect(img_scene, keypoints_scene);


推荐答案

如果从源代码编译OpenCV,则可以修复通过自己编辑opencv / modules / features2d / misc / java / src / cpp / features2d_manual.hpp来删除绑定。

If you compile OpenCV from source, you can fix the missing bindings by editing opencv/modules/features2d/misc/java/src/cpp/features2d_manual.hpp yourself.

我通过进行以下更改修复了它:

I fixed it by making the following changes:

(line 6)
#ifdef HAVE_OPENCV_FEATURES2D
#include "opencv2/features2d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "features2d_converters.hpp"

...(line 121)
    case SIFT:
    fd = xfeatures2d::SIFT::create();
    break;
    case SURF:
    fd = xfeatures2d::SURF::create();
    break;

...(line 353)
    case SIFT:
        de = xfeatures2d::SIFT::create();
        break;
    case SURF:
        de = xfeatures2d::SURF::create();
        break;

唯一的要求是你和你的资源一起构建opencv_contrib可选模块(你可以下载git项目来自 https://github.com/Itseez/opencv_contrib ,并在opencv的ccmake设置上设置其本地路径。

The only requirement is that you build opencv_contrib optional module along with your sources (you can download the git project from https://github.com/Itseez/opencv_contrib and just set its local path on opencv's ccmake settings.

哦,请记住,SIFT和SURF是非自由软件^^;

Oh, and keep in mind that SIFT and SURF are non-free software ^^;

这篇关于SURF和SIFT算法在OpenCV 3.0 Java中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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