天宫鹤

解决OpenCV 4描述符匹配器(cv::DescriptorMatcher)create函数的参数类型问题

1.在OpenCV 4.6.0中函数签名如下:

static Ptr<DescriptorMatcher> cv::DescriptorMatcher::create(const String & descriptorMatcherType)

static Ptr<DescriptorMatcher> cv::DescriptorMatcher::create(const DescriptorMatcher::MatcherType & matcherType)

2.在OpenCV 3.3.0中函数签名如下:

static Ptr<DescriptorMatcher> cv::DescriptorMatcher::create(const String & descriptorMatcherType)

static Ptr<DescriptorMatcher> cv::DescriptorMatcher::create(int matcherType)

3.将int转换为枚举类型,以便通过组合框选择类型

    //! 在OpenCV3.3.0中
    descMather = DescriptorMatcher::create(ui->matcherCombo->currentIndex() + 1);
    //! 在OpenCV4.6.中
    int matcherType = ui->matcherCombo->currentIndex() + 1;
    descMather = DescriptorMatcher::create(static_cast<DescriptorMatcher::MatcherType>(matcherType));
   或者(使用C语言中的强制类型转换):
    descMather = DescriptorMatcher::create((DescriptorMatcher::MatcherType)matcherType);
    descMather->match(descriptor1, descriptor2, matches);

 

posted on 2022-11-06 17:31  GoGrid  阅读(566)  评论(0编辑  收藏  举报

导航