English | 简体中文
For the identification result, the larger the value of confidence (confidence, a decimal in the [0 - 1] interval), the higher the confidence.
[
{
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;
},
...
]Currently only supports iOS 13.0+
$ npm install react-native-classify-image --save
or
$ yarn add react-native-classify-image
# RN >= 0.60
cd ios && pod install
# RN < 0.60
react-native link react-native-classify-imageexpo prebuildimport * as ClassifyImage from 'react-native-classify-image';
// Local path
const path =
'/var/mobile/Containers/Data/Library/Caches/E5FA7C16-9E74-4C38-A7BA-FC2180D20DE9.jpg';
ClassifyImage.request(path)
.then((result) => {
// success
})
.catch((error) => {
// error
});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
});
});| Name | Type | Description |
|---|---|---|
| path | string | Local absolute path to the image file. Available with react-native-fs constants |
| options (Optional) | object | See below Options |
| Name | Type | Description | Default |
|---|---|---|---|
| minConfidence (Optional) | string | Minimum confidence, only return data greater than or equal to this value. Ranges:[0-1] | 0.1 |
| preferBackgroundProcessing (Optional) | boolean | If set to true, this property reduces the request's memory footprint, processing footprint, and CPU/GPU contention, but may take longer to execute. |
false |
| usesCPUOnly (Optional) | boolean | Execute on CPU only. Setting false means that the GPU is free to use the GPU to speed up its processing. |
false |
| orientation (Optional) | number | Image orientation | Orientation.Up |
| Name | Type | Description |
|---|---|---|
| identifier | object | Category label name |
| confidence | number | confidence, [0 - 1] |
Orientation.Up:1- default orientationOrientation.UpMirrored:2- flip horizontallyOrientation.Down:3- rotate 180°Orientation.DownMirrored:4- vertical flipOrientation.Left:5- Flip horizontally and rotate 90° counterclockwiseOrientation.LeftMirrored:6- rotate 90° clockwiseOrientation.Right:7- Flip horizontally and rotate 90° clockwiseOrientation.RightMirrored:8- rotate 90° clockwise
- Check your minimum iOS version. react-native-classify-image requires a minimum iOS version of 11.0 (currently only supports iOS 13.0+).
- Open your Podfile
- Make sure
platform :iosis set to 11.0 or higher - Make sure
iOS Deployment Targetis set to 11.0 or higher
- Make sure you have created a Swift bridging header in your project.
- Open your project with Xcode (xxx.xcworkspace)
- Follow these steps to create a Swift file File > New > File (⌘+N)
- Select Swift File and click Next
- Enter the file name BridgingFile.swift, then click Create, click Create Bridging Header when prompted
- Support Android
- Support to identify the specified area
- Support web images
MIT
