探索flutter框架开发的app在移动应用市场的潜力与挑战
1015
2022-10-01
gocv(go mod)安装opencv4.5.2 !!!-Win10环境
环境
golang 1.16.2MinGW-W64 8.1.0cmake 3.20.4open-cv 4.5.2open-cv_opencv_contrib
安装
MinGW-W64(无坑)
-: MinGW-W64- 如下图
安装CMake(无坑)
-:Cmake-
安装OpenCV4.5.2
若安装到 c:/opencv 参考官网即可:官网使用 gopath,若使用go mod需要进入go path下的 pkg\mod\gocv.io\x\gocv@v0.27.0 目录执行 使用 go mod -文件不会-到 gopath/src 目录
-gocv
go get -u -d gocv.io/x/gocv
选择4.5.2 zip - opencv-:在该创建目录下创建build目录
使用win10命令行(管理员)
进入刚才建立的D:\develop\go-opencv\build (一定是build目录) 执行以下几条命令:(下面的几条命令失败后从此重新开始执行)
cmake D:\develop\go-opencv\opencv-4.5.2 -G "MinGW Makefiles" -BD:\develop\go-opencv\build -DENABLE_CXX11=ON -DOPENCV_EXTRA_MODULES_PATH=D:\develop\go-opencv\opencv_contrib-4.5.2\modules -DBUILD_SHARED_LIBS=ON -DWITH_IPP=OFF -DWITH_MSMF=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_DOCS=OFF -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_saliency=OFF -DBUILD_opencv_wechat_qrcode=OFF -DCPU_DISPATCH= -DOPENCV_GENERATE_PKGCONFIG=ON -DWITH_OPENCL_D3D11_NV=OFF -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int64_t -Wno-dev
mingw32-make -j%NUMBER_OF_PROCESSORS%
mingw32-make install
配置环境变量(必须) D:\develop\go-opencv\build\install\x64\mingw\bin
等待以上成功后关闭命令窗口进入测试
测试
使用管理员执行命令行 执行以下命令
set CGO_CXXFLAGS=--std=c++11set CGO_CPPFLAGS=-ID:\develop\go-opencv\build\install\includeset CGO_LDFLAGS=-LD:\develop\go-opencv\build\install\x64\mingw\lib -lopencv_core452 -lopencv_face452 -lopencv_videoio452 -lopencv_imgproc452 -lopencv_highgui452 -lopencv_imgcodecs452 -lopencv_objdetect452 -lopencv_features2d452 -lopencv_video452 -lopencv_dnn452 -lopencv_xfeatures2d452 -lopencv_plot452 -lopencv_tracking452 -lopencv_img_hash452 -lopencv_calib3d452
进入go path 下 pkg\mod\gocv.io\x\gocv@v0.27.0 执行:
go run -tags customenv cmd\version\main.go
若以上命令后续抛出错误使用:
go run cmd\version\main.go
显示:
为方便后续代码的使用
将以下临时变量添加作为永久环境变量,将=号左边作为变量名,右边作为变量值添加到环境变量中
set CGO_CXXFLAGS=--std=c++11set CGO_CPPFLAGS=-ID:\develop\go-opencv\build\install\includeset CGO_LDFLAGS=-LD:\develop\go-opencv\build\install\x64\mingw\lib -lopencv_core452 -lopencv_face452 -lopencv_videoio452 -lopencv_imgproc452 -lopencv_highgui452 -lopencv_imgcodecs452 -lopencv_objdetect452 -lopencv_features2d452 -lopencv_video452 -lopencv_dnn452 -lopencv_xfeatures2d452 -lopencv_plot452 -lopencv_tracking452 -lopencv_img_hash452 -lopencv_calib3d452
惊天大坑
把python的环境变量注释掉!!!!否则无法使用!!!
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~