吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1695|回复: 9
收起左侧

[求助] php 如何在图片上做标记

[复制链接]
fenga6 发表于 2021-6-28 09:00



人体关键点识别
检测图像中的人体并返回人体矩形框位置,精准定位21个核心关键点,包含头顶、五官、颈部、四肢主要关节部位,支持多人检测、大动作等复杂场景
https://ai.baidu.com/tech/body/pose
使用PHP已经获取到json数据,如何在图片上将关键点的位置标记出来?像图片中一样。各位大佬给个思路吧

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

小航 发表于 2021-6-28 10:23
使用GD或者imagic图像处理库
BuWenGuiQi0513 发表于 2021-6-28 11:03
 楼主| fenga6 发表于 2021-6-28 13:44
BuWenGuiQi0513 发表于 2021-6-28 11:03
前端根据接口返回的坐标进行标记

用到什么方法可以在图片上点上一个点
 楼主| fenga6 发表于 2021-6-28 13:44
小航 发表于 2021-6-28 10:23
使用GD或者imagic图像处理库

稍微再详细一些 或者给个指导连接
葱油拌面 发表于 2021-6-28 14:11
把蓝点当作水印一样加上去呢,php应该有好多图片加水印的做法的吧
mgc 发表于 2021-6-28 15:13
imagic库怎么样
 楼主| fenga6 发表于 2021-6-28 19:08
看样子还是要用python简单一些
还没学习python呢
Citrulluss 发表于 2021-6-28 19:53
本帖最后由 Citrulluss 于 2021-6-28 20:03 编辑

可以使用GD库中的imagecopymerge方法解决,具体简易的demo实现如下:
[PHP] 纯文本查看 复制代码
<?
//接口返回坐标数据
$coordinate = '{"person_num":2,"person_info":[{"body_parts":{"left_hip":{"y":577.9326171875,"x":681.2197265625,"score":0.79338431358337},"top_head":{"y":241.53610229492,"x":626.2978515625,"score":0.86288768053055},"right_mouth_corner":{"y":310.18844604492,"x":612.5673828125,"score":0.8880427479744},"neck":{"y":337.64938354492,"x":626.2978515625,"score":0.85405504703522},"left_shoulder":{"y":351.37985229492,"x":701.8154296875,"score":0.85044479370117},"left_knee":{"y":735.8330078125,"x":701.8154296875,"score":0.82074129581451},"left_ankle":{"y":880.0029296875,"x":729.2763671875,"score":0.83270841836929},"left_mouth_corner":{"y":310.18844604492,"x":640.0283203125,"score":0.88584971427917},"right_elbow":{"y":358.2451171875,"x":468.3974609375,"score":0.85978931188583},"right_ear":{"y":289.59274291992,"x":591.9716796875,"score":0.88232797384262},"nose":{"y":296.45797729492,"x":626.2978515625,"score":0.87427651882172},"left_eye":{"y":282.72750854492,"x":640.0283203125,"score":0.89141744375229},"right_eye":{"y":282.72750854492,"x":612.5673828125,"score":0.87547063827515},"right_hip":{"y":577.9326171875,"x":591.9716796875,"score":0.80213278532028},"left_wrist":{"y":371.9755859375,"x":887.1767578125,"score":0.85562163591385},"left_ear":{"y":289.59274291992,"x":660.6240234375,"score":0.88285982608795},"left_elbow":{"y":365.1103515625,"x":784.1982421875,"score":0.82591104507446},"right_shoulder":{"y":351.37985229492,"x":564.5107421875,"score":0.89254647493362},"right_ankle":{"y":886.8681640625,"x":585.1064453125,"score":0.82971853017807},"right_knee":{"y":735.8330078125,"x":585.1064453125,"score":0.80429482460022},"right_wrist":{"y":358.2451171875,"x":365.41891479492,"score":0.86196476221085}},"location":{"height":702.99633789062,"width":649.99780273438,"top":223.81103515625,"score":0.99477624893188,"left":291.72854614258}},{"body_parts":{"left_hip":{"y":576.7080078125,"x":1235.7001953125,"score":0.79379171133041},"top_head":{"y":268.73922729492,"x":1177.9560546875,"score":0.86524486541748},"right_mouth_corner":{"y":339.31539916992,"x":1165.1240234375,"score":0.88485944271088},"neck":{"y":358.56344604492,"x":1171.5400390625,"score":0.84238362312317},"left_shoulder":{"y":364.97946166992,"x":1242.1162109375,"score":0.87357926368713},"left_knee":{"y":724.2763671875,"x":1274.1962890625,"score":0.84274458885193},"left_ankle":{"y":859.0126953125,"x":1319.1083984375,"score":0.8060730099678},"left_mouth_corner":{"y":339.31539916992,"x":1184.3720703125,"score":0.89681082963943},"right_elbow":{"y":390.6435546875,"x":1023.9716796875,"score":0.79912161827087},"right_ear":{"y":313.65133666992,"x":1139.4599609375,"score":0.88635462522507},"nose":{"y":326.48336791992,"x":1177.9560546875,"score":0.87254709005356},"left_eye":{"y":313.65133666992,"x":1190.7880859375,"score":0.88532698154449},"right_eye":{"y":313.65133666992,"x":1165.1240234375,"score":0.86730831861496},"right_hip":{"y":583.1240234375,"x":1158.7080078125,"score":0.76761651039124},"left_wrist":{"y":294.40328979492,"x":1376.8525390625,"score":0.84444415569305},"left_ear":{"y":313.65133666992,"x":1210.0361328125,"score":0.90916079282761},"left_elbow":{"y":320.06735229492,"x":1312.6923828125,"score":0.82172644138336},"right_shoulder":{"y":384.2275390625,"x":1107.3798828125,"score":0.85451996326447},"right_ankle":{"y":871.8447265625,"x":1152.2919921875,"score":0.83917045593262},"right_knee":{"y":730.6923828125,"x":1158.7080078125,"score":0.82230097055435},"right_wrist":{"y":390.6435546875,"x":953.3955078125,"score":0.84904491901398}},"location":{"height":657.05035400391,"width":527.18115234375,"top":245.109375,"score":0.9866943359375,"left":892.57739257812}}],"log_id":"2818757282995098236"}';

//源文件 
$imgInfo = imagecreatefromjpeg("D:/img/img.jpg");

//水印文件
$watermarkInfo = imagecreatefrompng("D:/img/watermark.png");
$watermarkSize = getimagesize("D:/img/watermark.png");

$coordinate = json_decode($coordinate, true);

foreach ($coordinate['person_info'][0]['body_parts'] as $item) {
        //合并水印图片
        imagecopymerge($imgInfo, $watermarkInfo, $item['x'], $item['y'], 0, 0, $watermarkSize[0], $watermarkSize[1], 100);
}
//输出合并后水印图片
imagejpeg($imgInfo, 'new.jpg');
imagedestroy($imgInfo);
imagedestroy($watermarkInfo);

把需要加的点当做水印通过坐标加上去,然后合并成新的图片。
这里纯从用php实现角度出发,实际不太建议用这种方式。最好还是在前端用js通过canvas加上去,看了下百度那边也是通过前端实现的。
3389 (2).png

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
fenga6 + 1 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

 楼主| fenga6 发表于 2021-7-1 20:01
Citrulluss 发表于 2021-6-28 19:53
可以使用GD库中的imagecopymerge方法解决,具体简易的demo实现如下:
[mw_shl_code=php,true]

感谢老大的分享,我要好好学习一下提供的代码
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-26 02:04

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表