当前位置:网站首页>Using OpenCV in go
Using OpenCV in go
2022-06-13 01:36:00 【Python's path to becoming a God】
stay go Use in opencv It's still a bit of a hassle , If you are using mac or linux not so bad , stay windows It's more painful .
GoCV The package provides opencv 4.5.4 Support for , The official one click installation script .
about linux and mac System , Just follow the official tutorial , There won't be too many problems . The official installation guide is here :
https://gocv.io/getting-started/linux/
https://gocv.io/getting-started/macos/
about windows The steps are relatively complicated , It passes through MinGW To compile the , First install MinGW as well as CMake , Direct safety MSYS2 It's fine too , But it's better to be with GoCV The official use is consistent , loading MinGW 7.3.0, Because you can see that the directory has been written dead in its compilation script , If they are inconsistent, it will be more troublesome to change them by yourself . The official installation guide is here :https://gocv.io/getting-started/windows/
In general, the steps can be described in the official documents , If something goes wrong, the environment is generally not well equipped , It's better to MinGW Under the mingw64\bin The catalog is added to PATH In the environment variables . compile opencv You can change it when you need it GOPATH Next \src\gocv.io\x\gocv Inside win_build_opencv.cmd file , because GitHub Network instability often leads to download failure , You can comment out the two deletion sentences marked in the figure , In case you download files again and again and delete them .

compiled opencv It's a dynamic library . I tried to change the compilation option to compile into a static library , But this is go When compiling the program, you will be prompted that opencv Related libraries , I didn't go into details , Because it's urgent , Just use the dynamic library version directly .
GoCV There's something embarrassing about this bag , Because it links to dynamic libraries , So if you want to package your own program for others , You have to put all the opencv Dynamic libraries are put together with the programs we write , You can't use one less .
stay go It's written inside opencv It's still very comfortable , be relative to c++ go Your grammar is much more flexible .
The following is an example of reading pictures and displaying pictures :
package main
import (
"gocv.io/x/gocv"
)
func main() {
img := gocv.IMRead("avatar.jpg", gocv.IMReadColor)
window := gocv.NewWindow("Hello")
window.IMShow(img)
window.WaitKey(0)
}
After running, a window will pop up to show the picture .

relatively , Function to display pictures (imshow) It's not like c++ It can be written everywhere in , stay GoCV You can only define one first window Then from window call IMShow display picture . and ,window Can only be opened in the main thread , If you open a collaboration program to display, the program will hang up directly .
Apart from this little inconvenience ,GoCV It's still great to use .
Welcome to my WeChat official account. Notes on Jiangda
边栏推荐
- Leetcode question brushing 07 double pointer
- 使用Pygame创建一个简单游戏界面
- ES6解构赋值
- D template instance does not match declaration
- [WSL2]限制WSL2可访问的硬件资源(CPU/内存)
- Golang learning essay
- 详细受众特征详细解释
- How to turn on the hotspot for the mobile phone after the computer is connected to the network cable
- Leetcode question brushing 03 stack
- MySQL performance optimization
猜你喜欢

Minimum score of one question per day
![[projet cs144 de Stanford Computing Network] lab1: Stream reassembler](/img/7b/fad18b68a6ee30d1dec4dad6273b98.png)
[projet cs144 de Stanford Computing Network] lab1: Stream reassembler

csdn涨薪技术之Jmeter接口测试数据库断言的实现与设计

Use koa to mock data and set cross domain issues

Method of cleaning C disk

MySQL download and installation

Machine learning basic SVM (support vector machine)

Page optimization - Notes

Temporary objects and compilation optimization

Record the VMware installation process of VMware Tools and some problems encountered
随机推荐
Golang context (context summary)
D template instance does not match declaration
Run Presto under docker to access redis and Bi presentation
QT color extraction
707. design linked list
Logical operation bit operation
How to solve the problem of database?
Transaction characteristics and isolation levels
Leetcode-18- sum of four numbers (medium)
Implementation and design of JMeter interface test database assertion for CSDN salary increase technology
[soft test] software designer knowledge points sorting (to be updated)
A problem discovery and attempted solution to the strange stop of server script
Vector|hdu-4841 round table questions
The storage structure of a tree can adopt the parent representation, that is, the parent pointer array representation. Try to give the corresponding class definition. Each tree node contains two membe
Exercise 5.14 input n strings, arrange them in alphabetical order and output them.
About retrieving ignored files in cornerstone
Leetcode-78- subset (medium)
Project training (XVII) -- personal work summary
4K sea bottom and water surface fabrication method and ocean bump displacement texture Download
如何通过受众群体定位解决实际问题?