# react-native-classify-image **Repository Path**: Darkce/react-native-classify-image ## Basic Information - **Project Name**: react-native-classify-image - **Description**: 🏞 react-native library to classify images using Vision | 对图像进行分类的 react-native 库 - **Primary Language**: Swift - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-26 - **Last Updated**: 2022-08-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
识别结果,`confidence`(置信度,[0 - 1]区间内的小数)的值越大可信度越高。
```js
[
{
identifier: {
en: "animal",
zh_cn: "动物"
},
confidence: 0.848;
},
{
identifier: {
en: "cat",
zh_cn: "猫"
},
confidence: 0.848;
},
{
identifier: {
en: "clothing",
zh_cn: "衣服"
},
confidence: 0.676;
},
{
identifier: {
en: "hat",
zh_cn: "帽子"
},
confidence: 0.631;
},
...
]
```
## ❗️ :warning:
目前仅支持 iOS 13.0+
## Installation
`$ npm install react-native-classify-image --save`
or
`$ yarn add react-native-classify-image`
### React Native
```sh
# RN >= 0.60
cd ios && pod install
# RN < 0.60
react-native link react-native-classify-image
```
### Expo
```sh
expo prebuild
```
## Usage
### 简单使用
```js
import * as ClassifyImage from 'react-native-classify-image';
// 本地路径
const path =
'/var/mobile/Containers/Data/Library/Caches/E5FA7C16-9E74-4C38-A7BA-FC2180D20DE9.jpg';
ClassifyImage.request(path)
.then((result) => {
// success
})
.catch((error) => {
// error
});
```
### 高级使用
```js
import * as ClassifyImage from 'react-native-classify-image';
import RNFS from 'react-native-fs';
const path = `${RNFS.TemporaryDirectoryPath}/IMG_1234.jpg`;
// https://github.com/itinance/react-native-fs
RNFS.downloadFile({
fromUrl: 'https://s4.ax1x.com/2022/01/15/7JJaDI.png',
toFile: path,
}).promise.then((res) => {
ClassifyImage.request(path, {
minConfidence: 0.6,
orientation: ClassifyImage.Orientation.Up,
})
.then((result) => {
// success
})
.catch((error) => {
// error
});
});
```
## API
### `request(path: string, options?: Object): Promise