MacOS Install PHP Graphics clipping extended tclip_php tips

Source: Internet
Author: User
Tags install php

Tclip is used for image cropping with the following characteristics:

Can carry on face recognition. There are faces in the picture that will automatically be considered as an important area of the face area and will not be cropped out.
Automatically identify other important areas. If a human face is not recognized in the picture, the heavy area is calculated based on the feature distribution.
All in all, you automatically recognize important areas in your picture, and you keep important areas when you crop the pictures.
Source Address: Https://github.com/exinnet/tclip

Install OpenCV

According to the instructions on the GitHub, there is no problem installing on the CentOS, but I'm hanging up on my macos.

The first problem encountered is that the OPENCV installation is not over. Fortunately, on GitHub download the latest opencv-2.4.11 installation was successful.

Download Address: https://github.com/Itseez/opencv/releases

Use the current latest version OpenCV 2.4.11

Installation dependencies

Before installing OPENCV, install some dependent packages:

Copy Code code as follows:

Brew Install GTK + pkgconfig libpng zlib libjpeg libtiff cmake

Hint: Brew installation use please refer to http://brew.sh/

Install OpenCV

Start Installation OpenCV:

Copy Code code as follows:

Tar zxf opencv-2.4.11.tar.gz
CD opencv-2.4.11
CMake CMakeLists.txt
Make && make install

Install PHP Tclip

Download First: Https://github.com/exinnet/tclip/archive/master.zip

Then continue:

Copy Code code as follows:

Unzip Tclip-master.zip
CD Tclip-master/php_ext
Phpize
./configure

If there is no accident, to this step, should be hung up, hint:

Copy Code code as follows:

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

On the page of the Tclip author http://www.bo56.com/tclip%E4%BA%BA%E8%84%B8%E8%AF%86%E5%88%AB%E5%9B%BE%E7%89%87%E8%A3%81%E5%89%AA/

In the comments, some netizens have encountered similar problems and proposed the following changes:

Change the judgment statement in CONFIG.M4 ${i:${#i}-3} = ". So" to test ${i:${#i}-6} = ". Dylib" and try to rename the 46 line. So. dylib
Still prompt no result of the error ~

Then flip the CONFIG.M4 code and perform the output of Pkg-config OpenCV--libs--cflags OpenCV:

Copy Code code as follows:

-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

Feel how not to, so ran to the Linux installation of the successful server executed a bit, the output results are as follows:

Copy Code code as follows:

-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

And look at his judgment code:

Copy Code code as follows:

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

I immediately understand, Linux output is specific. So path, MacOS are relative path, and CONFIG.M4 is based on specific path and extension of the judge, understand the problem, the solution is simple.

Modify the execution result of the Pkg-config OpenCV--libs--cflags OpenCV to a specific path and replace it with CONFIG.M4:

Copy Code code as follows:

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 "

Continue to execute:

Copy Code code as follows:

Phpize
./configure
Make
Make install

Successful installation completed.

The above mentioned is the entire content of this article, I hope you can enjoy.

Please take a moment to share the article with your friends or leave a comment. We will sincerely thank you for your support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.