1

I'm pretty new in Golang and i have some problems to install gocv. I don't know weather it is impotent to know, but I use Manjaro Linux on version 5.19.3, the current go- version is 1.14.2 and last but not least gccgo on version 10.1.0 (amd64).
I installed gocv as described on https://gocv.io/getting-started/linux/

go get -u -d gocv.io/x/gocv
cd $GOPATH/pkg/mod/gocv.io/
make install

If it works correctly, following message should be desplayed:

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.

I tried to find a solution on in the internet, but I don't even understand the problem. I hope someone can help me. best regards Felix

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Horst
  • 11
  • 3
  • I don't think arch is supported by the Makefile see https://github.com/hybridgroup/gocv/blob/release/Makefile#L25 Canyou show the full output ? and not just only the compiler complaints. (can it use english ?). That being said you can manually setup the dependencies then build gocv. If the environment variables are correctly configured this should work out of the box. Alternatively if you dont need the GUI you might run it over docker. Also, check for issue report on the github repo, that might help. https://github.com/hybridgroup/gocv/issues?q=is%3Aissue+arch+is%3Aclosed –  Aug 04 '20 at 07:29
  • have you figured out that gocv is a wrapper around the C library opencv ? That it is required to install those. That the Makefile does not support Arch package manager ? Thus you must install them by yourself at first. –  Aug 05 '20 at 18:26
  • you can also make use of the pre configured docker image available at https://github.com/denismakogon/gocv-alpine –  Aug 05 '20 at 18:27

1 Answers1

0

SIFT (Scale-Invariant Feature Transform) algorithm is a patented algorithm that requires user to import a non-free header file if you need to use it as below :

#include <opencv2/nonfree/nonfree.hpp>

However, the patent is already expired as of now. (OpenCV 4.4.0) So this package is moved to main repository of opencv (check release highlightes https://opencv.org/opencv-4-4-0/)

As a result,the gocv repository which using SIFT has been updated to get this algorithm from the opencv main repository as below, (in gocv v0.24.0 change log: https://github.com/hybridgroup/gocv/commit/04b71cbb6d82e8c396ccbbf0d65b446a80a0e8fa)

typedef cv::Ptr<cv::SIFT>* SIFT;

This is the line of code updated which causes you failed to build.(You will only get this error if you are not using opencv 4.4.0, you may check the MakeFile that you are using)

To solve this problem, you may try get/update the gocv repository again now as they have updated all MakeFile to use opencv 4.4.0 already. Or you may just manually update your MakeFile to change the opencv version to 4.4.0

Tam Tam Tam
  • 176
  • 1
  • 7