图片服务 - thumbor自定义检测

图片服务 - thumbor自定义检测

 

如果您需要比预先打包的探测器更能检测到(即:您需要检测眼镜),您可以随时实施自己的探测器。

如果你的探测器可以使用python的导入机制找到,thumbor将能够使用它。只需将其全名添加到探测器 配置中

 

创建自定义检测器

你可以在这里看到https://github.com/thumbor/thumbor/blob/master/thumbor/detectors/face_detector/__init__.py,很容易实现你自己的自定义探测器。

您所要做的就是创建一个继承自BaseDetector的类,并实现一个接收上下文字典的detect方法。

在上下文字典中有一个名为“focal_points”的键,您应该在其中附加您在图片中找到的任何焦点(使用FocalPoint类)。

如果您的探测器没有找到任何点,则简单地调用传递给上下文的next()方法,以便进一步检测。

Pollexor 是 Thumbor 图片服务的 JAVA 客户端,兼容 Android 平台。Maven:<dependency>   <groupId>com.squareup</groupId>   <artifactId>pollexor<artifactId>   <version>2.0.2</version> </dependency>Gradle:compile 'com.squareup:pollexor:2.0.2'示例// Without encryption:Thumbor thumbor = Thumbor.create("http://example.com/"); // With encryption:Thumbor thumbor = Thumbor.create("http://example.com/", "key");thumbor.buildImage("http://example.com/image.png")     .resize(48, 48)     .toUrl()// Produces: /unsafe/48x48/example.com/image.pngthumbor.buildImage("http://example.com/image.png")     .crop(10, 10, 90, 90)     .resize(40, 40)     .smart()     .toUrl()// Produces: /unsafe/10x10:90x90/smart/40x40/example.com/image.pngthumbor.buildImage("http://example.com/image.png")     .crop(5, 5, 195, 195)     .resize(95, 95)     .align(BOTTOM, RIGHT)     .toUrl()// Produces: /unsafe/5x5:195x195/right/bottom/95x95/example.com/image.pngthumbor.buildImage("http://example.com/background.png")     .resize(200, 100)     .filter(         roundCorner(10),         watermark(thumbor.buildImage("http://example.com/overlay1.png").resize(200, 100)),         watermark(thumbor.buildImage("http://example.com/overlay2.png").resize(50, 50), 75, 25),         quality(85)     )     .toUrl()// Produces: /unsafe/200x100/filters:round_corner(10,255,255,255):watermark(/unsafe/200x100/example.c 标签:Pollexor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值