当前位置: 首页 > news >正文

手机网站制作织梦网站模板网站这么建设

手机网站制作织梦网站模板,网站这么建设,一站式做网站服务,农产品网站设计1注册或登录平台并创建应用:图像识别 - 新手操作指引 | 百度AI开放平台 结果得到: 2.由上述得到的信息在浏览器输入: https://aip.baidubce.com/oauth/2.0/token?grant_typeclient_credentials&client_idVa5yQRHlA4Fq5eR3LT0vuXV4&…

1注册或登录平台并创建应用:图像识别 - 新手操作指引 | 百度AI开放平台

结果得到:

2.由上述得到的信息在浏览器输入:

https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=Va5yQRHlA4Fq5eR3LT0vuXV4&client_secret=0rDSjzQ20XUj5itV6WRtznPQSzr5pVw2&

获取到access_token(ps:access_token的有效期为30天,需要每30天进行定期更换;)

3.接口调用:创建一个html页面(注意替换access-token)

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Image Recognition</title><style>canvas {border: 1px solid #ddd;margin-top: 10px;}</style>
</head><body><div id="app"><div><input type="file" accept="image/*" @change="toBase64s($event)" id="file" /><br /><canvas id="canvas"></canvas><p>识别结果:{{ name }}</p></div></div><!-- 使用完整Vue构建版本 --><script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script><script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>new Vue({el: '#app',data() {return {srcs: "",urlcode: "",name: "请上传图片"};},methods: {toBase64s(event) {const file = event.target.files[0];if (!file) return;const reader = new FileReader();reader.onload = e => {this.srcs = e.target.result;const image = new Image();image.onload = () => {const canvas = document.getElementById("canvas");const ctx = canvas.getContext("2d");// 计算等比例缩放尺寸const maxWidth = 100;const scaleRatio = maxWidth / image.width;canvas.width = maxWidth;canvas.height = image.height * scaleRatio;ctx.drawImage(image, 0, 0, canvas.width, canvas.height);// 获取压缩后的base64this.urlcode = canvas.toDataURL("image/jpeg", 0.8).split(',')[1];// 调用APIaxios.post('https://aip.baidubce.com/rest/2.0/image-classify/v1/animal',`image=${encodeURIComponent(this.urlcode)}`,{params: {access_token: 'xxxx'}}).then(res => {if (res.data.result && res.data.result.length > 0) {this.name = res.data.result[0].name;}}).catch(error => {console.error('API请求失败:', error);this.name = "识别失败,请重试";});};image.src = this.srcs;};reader.readAsDataURL(file);}}});</script>
</body></html>

结果可得:

http://www.dtcms.com/a/415116.html

相关文章:

  • 第2章 进程与线程
  • 网站编辑外包汕头 网站建设
  • 做企业网站支付功能网站建设主持词
  • 怎么把自己做的网站登录到网上html编辑器手机版
  • 南昌公司做网站需要多少钱wordpress页面定制
  • 作者须知 — Transactions Journals
  • 强化学习(3)策略梯度
  • langchain的核心组件
  • 算法基础篇(6)差分
  • Umbra(陰影):DDS底層協議漏洞遠程惡意組件注入Botnets
  • 【自然语言处理与大模型】LlamaIndex快速入门②
  • 附近广告公司地址快速优化seo
  • 文心大模型4.5:百度推出的新一代原生多模态基础大模型
  • 厦门网站推广费用广西网站建设银行
  • 今日面试之项目拷打:锁与事务的深度解析
  • 基于IMX6ULL 芯片 UART1
  • Coze源码分析-资源库-删除数据库-后端源码-基础设施/数据存储层
  • 多后端服务器架构解析
  • 四种常用SVC(service)及其与Ingress协作方式
  • C#多线程全家桶:从Thread到async/await
  • 网站备案 论坛甘肃微信网站建设
  • 数模之路获奖总结——数据分析交流(R语言)
  • 网站 后台 数据 下载网站优化软件推荐
  • Java数据结构第二十七期:布隆过滤器,用 “模糊” 换高效的查重黑科技
  • 怎么做质量高的网站如何实现网站建设服务
  • 我的项目开发的一般流程,供交流
  • 做网站实名认证有什么用濮阳市城乡一体化示范区主任
  • InnoDB压缩技术:节省空间提升性能
  • 国任保险携手云轴科技ZStack获评鼎新杯数字化转型应用典型案例
  • 进入网站wordpress配置如何在百度搜到自己的网站