怎么在MacOS中安装Tclip扩展-创新互联

本篇文章为大家展示了怎么在MacOS中安装Tclip扩展,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

10年积累的成都做网站、成都网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计制作后付款的网站建设流程,更有怀仁免费网站建设让你可以放心的选择与我们合作。

安装opencv


根据github上的说明,在CentOS上安装没有问题,但在我的MacOS上就挂了。

首先遇到的问题就是,opencv安装不过去。还好,上github下载新的opencv-2.4.11 安装成功。

下载地址:https://github.com/Itseez/opencv/releases

使用当前新版本 OpenCV 2.4.11

安装依赖

在安装opencv之前,先安装一些依赖包:

复制代码 代码如下:


brew install gtk+  pkgconfig libpng zlib libjpeg libtiff cmake


提示: brew的安装使用请参考 http://brew.sh/

安装opencv

开始安装 opencv:

复制代码 代码如下:


tar zxf opencv-2.4.11.tar.gz
cd opencv-2.4.11
cmake CMakeLists.txt
make && make install


安装php tclip

先下载:https://github.com/exinnet/tclip/archive/master.zip

然后继续:

复制代码 代码如下:


unzip tclip-master.zip
cd tclip-master/php_ext
phpize
./configure


如果不出意外,到这一步,应该就挂掉了,提示:

复制代码 代码如下:


checking for opencv.pc file in default path... found in /usr/lib/pkgconfig
found in /usr/local/lib/pkgconfig
configure: error: no result from pkg-config opencv --libs --cflags opencv


在 Tclip 作者的页面上 /tupian/20230522/ config.m4 中的 判断语句test ${i:${#i}-3} = “.so”,改为 test ${i:${#i}-6} = ".dylib”,并尝试将46行的.so 也改称 .dylib
依然提示no result的错误~

再翻翻config.m4的代码和执行 pkg-config opencv --libs --cflags opencv的输出结果:

复制代码 代码如下:


-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab


感觉怎么对不上,于是跑到Linux安装成功的服务器执行了一下,输出结果如下:

复制代码 代码如下:


-I/usr/local/include/opencv -I/usr/local/include /usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so


再看他的判断代码:

复制代码 代码如下:


OPENCV_FLAGS="`pkg-config opencv --libs --cflags opencv`"
for i in $OPENCV_FLAGS;do
if test ${i:0:2} = "-I" ;then
PHP_ADD_INCLUDE(${i:2})
elif test ${i:${#i}-3} = ".so" ;then
dir_name=`dirname $i`
file_name=${i/$dir_name/}
file_name=${file_name/\/lib/}
file_name=${file_name/.so/}
PHP_ADD_LIBRARY_WITH_PATH($file_name,$dir_name,TCLIP_SHARED_LIBADD)
else
AC_MSG_ERROR([no result from pkg-config opencv --libs --cflags opencv])
fi
done


我立刻就明白了,Linux上输出的都是具体的.so路径,MacOS上都是相对的路径,而config.m4中是根据具体路径和扩展名判断的,明白了问题,解决就简单了。

将 pkg-config opencv --libs --cflags opencv 的执行结果修改为具体的路径,并替换到config.m4中:

复制代码 代码如下:


OPENCV_FLAGS="-I/usr/local/include/opencv -I/usr/local/include /usr/local/lib/libopencv_calib3d.dylib /usr/local/lib/libopencv_contrib.dylib /usr/local/lib/libopencv_core.dylib /usr/local/lib/libopencv_features2d.dylib /usr/local/lib/libopencv_flann.dylib /usr/local/lib/libopencv_gpu.dylib /usr/local/lib/libopencv_highgui.dylib /usr/local/lib/libopencv_imgproc.dylib /usr/local/lib/libopencv_legacy.dylib /usr/local/lib/libopencv_ml.dylib /usr/local/lib/libopencv_nonfree.dylib /usr/local/lib/libopencv_objdetect.dylib /usr/local/lib/libopencv_photo.dylib /usr/local/lib/libopencv_stitching.dylib /usr/local/lib/libopencv_ts.dylib /usr/local/lib/libopencv_video.dylib /usr/local/lib/libopencv_videostab.dylib"


再继续执行:

复制代码 代码如下:


phpize
./configure
make
make install


上述内容就是怎么在MacOS中安装Tclip扩展,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。


标题名称:怎么在MacOS中安装Tclip扩展-创新互联
转载来源:http://myzitong.com/article/esdgo.html