search
HomeBackend DevelopmentPHP TutorialMacOS Install PHP image cropping extension Tclip_PHP tutorial

MacOS Install PHP image cropping extension Tclip

Tclip is an automatic avatar recognition, PHP image cropping project. It can automatically identify important areas in the picture and retain the important areas when cropping the picture. Let’s take a look at how to install it on MacOS.

Tclip is used for image cropping and has the following features:

Can perform face recognition. If there is a face in the picture, the face area will automatically be regarded as an important area and will not be cropped.
Automatically identify other important areas. If no face is recognized in the image, the heavy area is calculated based on the feature distribution.
In summary, important areas in an image are automatically identified and retained when cropping the image.
Source code address: https://github.com/exinnet/tclip

Install opencv

According to the instructions on github, there is no problem installing on CentOS, but it hangs on my MacOS.

The first problem encountered is that opencv cannot be installed. Fortunately, I downloaded the latest opencv-2.4.11 from github and installed it successfully.

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

Use the latest version of OpenCV 2.4.11

Install dependencies

Before installing opencv, install some dependency packages:

The code is as follows:


brew install gtk pkgconfig libpng zlib libjpeg libtiff cmake

Tips: For the installation and use of brew, please refer to http://brew.sh/

Install opencv

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 nothing else happens, you should be dead at this point. Tip:

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 face recognition image cropping/#download

In the comments, some netizens also encountered similar problems and suggested the following modifications:

Change the judgment statement test ${i:${#i}-3} = “.so” in config.m4 to test ${i:${#i}-6} = “.dylib” , and try to rename the 46-line .so to .dylib
Still prompting no result error~

Look through the code of config.m4 and execute pkg-config opencv --libs --cflags. The output of 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

I felt something was wrong, so I ran to the server where Linux was successfully installed and executed it. The output was 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

Look at his judgment code again:

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" ;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 understood that the output on Linux are all specific .so paths, and on MacOS they are all relative paths, while config.m4 is judged based on the specific path and extension. Once I understand the problem, I can solve it. Simple.

Modify the execution result of pkg-config opencv --libs --cflags opencv to the specific path and replace it in 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"

Continue execution:

The code is as follows:


phpize
./configure
make
make install

The installation was successfully completed.

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/973926.htmlTechArticleMacOS Install the PHP image cropping extension Tclip Tclip is an avatar automatic recognition, PHP image cropping project. It can automatically identify important areas in the picture and retain the important areas when cropping the picture...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
docker命令在哪里输入docker命令在哪里输入Apr 02, 2024 pm 10:09 PM

Docker 命令在终端窗口中输入,如 Linux 和 macOS 上的“终端”或 Windows 上的“命令提示符”。步骤包括:1. 打开终端窗口;2. 输入 Docker 命令(如 docker run);3. 按 Enter 执行命令。提示:可以使用 docker --help 获取帮助,某些命令需要 root 权限。

vscode怎么运行代码jsvscode怎么运行代码jsApr 03, 2024 am 01:51 AM

在 Visual Studio Code 中运行 JavaScript 代码有以下三种方法:运行选定代码块。使用调试器。使用命令行导航到脚本所在目录并运行 node filename.js。

macos是什么意思macos是什么意思Apr 02, 2024 pm 04:48 PM

macOS 是 Apple 专为 Mac 电脑设计的操作系统,由 Darwin、Aqua、Finder、Dock 等组件组成。它以其用户友好性、稳定性和强大的功能而著称,提供无缝集成和强大的安全功能,使其成为 Mac 用户的理想选择。

为什么python下载后不见了为什么python下载后不见了Apr 02, 2024 pm 06:51 PM

Python 下载后消失可能是由于:1. 安装路径不正确;2. 未添加到环境变量;3. 未正式安装;4. 防病毒软件干扰;5. 文件损坏;6. 下载不完整。

vscode是什么语言开发的vscode是什么语言开发的Apr 03, 2024 am 01:57 AM

VS Code 主要由以下语言开发:TypeScript:核心组件JavaScript:补充功能Electron:跨平台 GUIC++:性能相关功能支持多种其他语言(如 Python、Java、C#)

详解MAC中如何下载配置PHPMyAdmin详解MAC中如何下载配置PHPMyAdminFeb 01, 2023 am 11:01 AM

本篇文章给大家带来了关于PHPMyAdmin的相关知识,其中主要介绍了如何在MAC下配置PHPMyAdmin,下面一起来看一下,希望对大家有帮助。

访问网站出现nginx怎么解决访问网站出现nginx怎么解决Apr 02, 2024 pm 08:39 PM

访问网站出现 nginx,原因可能是:服务器维护、服务器繁忙、浏览器缓存、DNS 问题、防火墙阻止、网站错误配置、网络连接问题或网站已关闭。尝试以下解决方案:等待维护结束、非高峰时段访问、清除浏览器缓存、刷新 DNS 缓存、禁用防火墙或防病毒软件、联系网站管理员、检查网络连接或使用搜索引擎或 Web 存档查找其他网站副本。如果问题仍然存在,请与网站管理员联系。

vscode怎么转中文vscode怎么转中文Apr 03, 2024 am 02:39 AM

在 Visual Studio Code 中将界面切换为中文的方法:打开设置菜单(Ctrl + , 或 Command + ,)搜索“语言”设置将“显示语言”更改为“简体中文”或“繁体中文”重新启动 VSCode界面将切换为中文

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft