我是Golang的新手,在安装gocv时遇到了一些问题。我不知道这是否无能为力,但我在5.19.3版本上使用Manjaro Linux,当前的go- version是1.14.2,最后但并非最不重要的是gccgo在10.1.0版本(amd64)上。
我按照https://gocv.io/getting-started/linux/上的描述安装了gocv。
go get -u -d gocv.io/x/gocv
cd $GOPATH/pkg/mod/gocv.io/
make install如果工作正常,则会显示以下消息:
gocv version: 0.24.0
opencv lib version: 4.4.0# gocv.io/x/gocv
In file included from features2d.cpp:1:
features2d.h:22:21: error: 'SIFT' is not a member of 'cv'
22 | typedef cv::Ptr<cv::SIFT>* SIFT;
| ^~~~
features2d.h:22:21: error: 'SIFT' is not a member of 'cv'
features2d.h:22:25: error: template argument 1 is invalid
22 | typedef cv::Ptr<cv::SIFT>* SIFT;
| ^
features2d.cpp: In function 'int* SIFT_Create()':
features2d.cpp:434:28: error: 'SIFT' is not a member of 'cv'; did you mean 'SIFT'?
434 | return new cv::Ptr<cv::SIFT>(cv::SIFT::create());
| ^~~~
In file included from features2d.cpp:1:
features2d.h:22:28: note: 'SIFT' declared here
22 | typedef cv::Ptr<cv::SIFT>* SIFT;
| ^~~~
features2d.cpp:434:28: error: 'SIFT' is not a member of 'cv'; did you mean 'SIFT'?
434 | return new cv::Ptr<cv::SIFT>(cv::SIFT::create());
| ^~~~
In file included from features2d.cpp:1:
features2d.h:22:28: note: 'SIFT' declared here
22 | typedef cv::Ptr<cv::SIFT>* SIFT;
| ^~~~
features2d.cpp:434:32: error: template argument 1 is invalid
434 | return new cv::Ptr<cv::SIFT>(cv::SIFT::create());
| ^
features2d.cpp:434:38: error: 'cv::SIFT' has not been declared
434 | return new cv::Ptr<cv::SIFT>(cv::SIFT::create());
| ^~~~
features2d.cpp: In function 'KeyPoints SIFT_Detect(SIFT, Mat)':
features2d.cpp:443:9: error: base operand of '->' is not a pointer
443 | (*d)->detect(*src, detected);
| ^~
features2d.cpp: In function 'KeyPoints SIFT_DetectAndCompute(SIFT, Mat, Mat, Mat)':
features2d.cpp:460:9: error: base operand of '->' is not a pointer
460 | (*d)->detectAndCompute(*src, *mask, detected, *desc);
| ^~
Fehler: Prozess beendet mit Rückgabewert 2.我试着在互联网上找到解决方案,但我甚至不明白这个问题。我希望有人能帮助我。向Felix致以最好的问候
发布于 2020-08-27 12:29:29
SIFT (比例不变特征变换)算法是一种专利算法,如果您需要使用它,则需要用户导入一个非自由头文件,如下所示:
#include <opencv2/nonfree/nonfree.hpp>然而,到目前为止,该专利已经过期了。(OpenCV 4.4.0),因此这个包被移动到opencv的主存储库(查看发布高亮的https://opencv.org/opencv-4-4-0/)
因此,使用SIFT的gocv存储库已经更新,以便从opencv主存储库获得此算法,如下所示(在gocv v0.24.0更改日志中:https://github.com/hybridgroup/gocv/commit/04b71cbb6d82e8c396ccbbf0d65b446a80a0e8fa)
typedef cv::Ptr<cv::SIFT>* SIFT;这是导致你构建失败的更新代码行。(如果你不使用opencv 4.4.0,你会得到这个错误,你可以检查你正在使用的MakeFile )
要解决这个问题,您现在可以尝试再次获取/更新gocv存储库,因为他们已经更新了所有MakeFile以使用opencv 4.4.0。或者,您也可以手动更新您的MakeFile,将opencv版本更改为4.4.0
https://stackoverflow.com/questions/63237803
复制相似问题