This page has information on how to install and use GoCV on Ubuntu, as well as other Linux distros.
You can use
make to install OpenCV 3.4.1 with the handy
Makefile included with this repo. If you already have installed OpenCV, you do not need to do so again. The installation performed by the
Makefile is minimal, so it may remove OpenCV options such as Python or Java wrappers if you have already installed OpenCV some other way.
Install the GoCV package:
go get -u -d gocv.io/x/gocv
Change directories into the newly installed package directory:
Now you can run the needed installation steps listed below.
First, you need to update the system, and install any required packages:
Next, download the OpenCV 3.4.1 and OpenCV Contrib source code:
Build and install everything. This will take quite a while:
After the installation is complete, you can remove the extra files and folders:
In order to build/run Go code that uses this package, you will need to specify the location for the include and lib files in your GoCV installation.
One time per session, you must run the script:
Now you should be able to build or run any of the examples:
go run ./cmd/version/main.go
The version program should output the following:
gocv version: 0.11.0 opencv lib version: 3.4.1
You might want to copy the
env.sh script into your own projects, to make it easier to setup these vars when building your own code.
If you are not modifying gocv source, compile gocv to a static library, to significantly decrease your build times (
env.sh must have been executed as described above):
go install gocv.io/x/gocv