MacOS Install php picture clipping extension tclip_php tutorial

Source: Internet
Author: User

MacOS Install php picture clipping extension Tclip


Tclip is an avatar auto-recognition, PHP picture clipping project. He can automatically identify important areas in the picture and retain important areas when the picture is cropped. Let's take a look at how to install on MacOS.

Tclip is used for picture cropping, with the following features:

Human face recognition is possible. The face in the image will automatically be treated as an important area of the face area and will not be cropped off.
Identify other important areas automatically. If a face is not recognized in the picture, the heavy area is calculated based on the feature distribution.
In summary, important areas in the picture are automatically recognized, and important areas are preserved when the picture is cropped.
Source Address: Https://github.com/exinnet/tclip

Installing OPENCV

According to the instructions on GitHub, installing on CentOS is no problem, but it hangs on my macos.

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

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

Use current latest version OpenCV 2.4.11

Installation dependencies

Before you install OPENCV, install some dependent packages:

The code is as follows:


Brew Install GTK + pkgconfig libpng zlib libjpeg libtiff cmake

Tip: For the installation of Brew, refer to http://brew.sh/

Installing OPENCV

To start installing OPENCV:

The code is 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:

The code is as follows:


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

If there is no accident, to this step, should be hung off, prompt:

The code is 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 Tclip author's page, 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/#download

Comments, there are netizens have encountered similar problems, proposed amendments to:

Change the judgment statement in CONFIG.M4 test ${i:${#i}-3} = ". So" to test ${i:${#i}-6} = ". Dylib" and try to rename the 46-row. So. dylib
Error that still indicates no result ~

Then turn over the CONFIG.M4 code and execute the output of Pkg-config OpenCV--libs--cflags OpenCV:

The code is 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 to do not, so ran to the Linux installation successful server executed a bit, the output is as follows:

The code is 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

Then look at his judgment code:

The code is 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";
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 understood that the output on Linux is specific. So path, MacOS is relative to the path, and CONFIG.M4 in accordance with the specific path and extension of the judgment, 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:

The code is 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 "

To continue execution:

The code is as follows:


Phpize
./configure
Make
Make install

Smooth installation completed.

The above mentioned is the whole content of this article, I hope you can like.

http://www.bkjia.com/PHPjc/973926.html www.bkjia.com true http://www.bkjia.com/PHPjc/973926.html techarticle MacOS Install php picture clipping extension Tclip Tclip is an avatar auto-recognition, PHP picture clipping project. He can automatically identify important areas in the picture and retain the weight when the picture is cropped ...

  • 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.