import Taro , { Component, Config } from '@tarojs/taro';
import { View, Text } from '@tarojs/components';
import './index.scss'
export default class ImageIndex extends Component<any, any> {
config: Config = {
navigationBarTitleText: '图像识别'
}
state = {
res: ''
}
// 选择照片
chooseImg(type) {
let self = this
Taro.chooseImage({
count: 9
})
.then((res) => {
let tempFilePaths = res.tempFilePaths
tempFilePaths.forEach((tempFilePath) => {
Taro.getFileSystemManager().readFile({
filePath: tempFilePath, //选择图片返回的相对路径
encoding: 'base64', //编码格式
success: res => { //成功的回调
let url = ''
if (type == 'image') {
// 图片识别
url = 'https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general?access_token='
使用百度识图 完成图片识别和文字识别
最新推荐文章于 2024-07-02 16:05:46 发布