gpt4 book ai didi

c++ - OpenCV 如何创建 DescriptorExtractor 对象

转载 作者:太空狗 更新时间:2023-10-29 20:23:25 26 4
gpt4 key购买 nike

我正在使用 OpenCV C++ 库,但我无法创建 DescriptorExtractor 对象。这是我所做的:

Mat img = imread("testOrb.jpg",CV_LOAD_IMAGE_UNCHANGED);
std::vector<KeyPoint> kp;
cv::Ptr<cv::ORB> detector = cv::ORB::create();
detector->detect( img, kp )
//this part works

DescriptorExtractor descriptorExtractor;
Mat descriptors;
descriptorExtractor.compute(img, kp, descriptors);
//when these 3 lines are added, an error is thrown

但是我有以下错误信息:

OpenCV Error: The function/feature is not implemented () in detectAndCompute, file ...

最佳答案

DescriptorExtractor 是一个抽象 类,因此您无法实例化它。它只是描述符提取器的通用接口(interface)。你可以这样做:

Ptr<DescriptorExtractor> descriptorExtractor = ORB::create();
Mat descriptors;
descriptorExtractor->compute(img, kp, descriptors);

请注意,还存在 FeatureDetector,这是检测关键点的通用接口(interface),因此您可以:

std::vector<KeyPoint> kp;
Ptr<FeatureDetector> detector = ORB::create();
detector->detect(img, kp);

关于c++ - OpenCV 如何创建 DescriptorExtractor 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33332055/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com