Git Product home page Git Product logo

tclip's Introduction

tclip

名字说明

T开头,代表是头像识别
clip,读[klip],译为裁剪。
Tclip,意为自动头像识别的图片裁剪项目。

概要

用于图片裁剪。有以下特点:
1.能进行人脸识别。图片中有人脸,将自动视为人脸区域为重要区域,将不会被裁剪掉。
2.自动识别其它重要区域。如果图片中未识别出人脸,则会根据特征分布计算出重区域。
总而言之,自动识别图片中的重要区域,并且在图片裁剪时保留重要区域。
3.可以加水印。

效果演示

###人物效果演示 原图
github

如果按照从中间截取为 400 * 225 大小大图片。效果如下:
github

使用tclip裁剪图片效果如下:
github
###景物效果演示 原图
github

如果按照从中间截取。效果如下:
github

使用tclip裁剪图片效果如下:
github

###水印效果 github

###在线演示 演示地址:http://demo.bo56.com/tclip

安装步骤:

###源码下载
opencv2 下载地址 http://www.bo56.com/tclip人脸识别图片裁剪/#download (建议opencv2.4.4版本)
###安装opencv2
此扩展依赖于opencv2.0 之上版本。因此安装前先安装opencv。opencv的安装步骤如下
yum install gtk+ gtk+-devel pkgconfig libpng zlib libjpeg libtiff cmake
下载 opencv2 安装包
解压安装包
cd 进入安装包文件夹内。
cmake CMakeLists.txt
make && make install
vim /etc/profile
在 unset i 前增加
export PKG_CONFIG_PATH=/usr/lib/pkgconfig/:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
保持退出后,执行如下命令
source /etc/profile
echo "/usr/local/lib/" > /etc/ld.so.conf.d/opencv.conf
ldconfig

###安装tclip扩展
cd 到源代码目录中的php_ext文件夹
phpize
./configure
make
cp modules/tclip.so 到 extension 目录
修改php.ini。加入 extension=tclip.so
重启fpm
###安装命令行
如果想使用命令行方式,可以进行如下安装
cd 进入安装包soft文件夹内
chmod +x ./tclip.sh
./tclip.sh

使用方法说明

第一种:在php中使用格式:
tclip(文件原路径,裁剪后的图片保存路径,裁剪后的图片宽度,裁剪后的图片高度)
示例:
$source_file = "/tmp/a.jpg";
$dest_file = "/www/a_dest.jpg";
$width = 400;
$height = 200;
$watermark_text = ""; //可选
$ret = tclip($source_file, $dest_file, $width, $height, $watermark_text);
裁剪成功 $ret 为 true,裁剪识别 $ret 为false
第二种:命令行
参数说明:
-s 原图路径
-d 裁剪后的图片保存路径
-w 裁剪后的图片宽度
-h 裁剪后的图片高度
-c 配置文件路径。默认 default path is /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml
-t 水印文本
-m 打开debug模式
./tclip -s a.jpg -d a_dest.jpg -w 400 -h 200

贡献者

jonnywang https://github.com/jonnywang

tclip's People

Contributors

exinnet avatar ixqbar avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.