1- # react-native-vision-utils
1+ <p align =" center " >
2+ <h1 align =" center " >react-native-vision-utils</h1 >
3+ </p >
4+
5+ <p align =" center " >
6+ <strong >High-performance React Native library for image preprocessing optimized for ML/AI inference pipelines</strong >
7+ </p >
8+
9+ <p align =" center " >
10+ <a href =" #installation " >Installation</a > •
11+ <a href =" #quick-start " >Quick Start</a > •
12+ <a href =" #api-reference " >API Reference</a > •
13+ <a href =" #features " >Features</a > •
14+ <a href =" #contributing " >Contributing</a >
15+ </p >
16+
17+ <p align =" center " >
18+ <img src =" https://img.shields.io/npm/v/react-native-vision-utils?style=flat-square " alt =" npm version " />
19+ <img src =" https://img.shields.io/npm/dm/react-native-vision-utils?style=flat-square " alt =" downloads " />
20+ <img src =" https://img.shields.io/github/license/user/react-native-vision-utils?style=flat-square " alt =" license " />
21+ </p >
222
3- A high-performance React Native library for image preprocessing optimized for ML/AI inference pipelines. Provides comprehensive tools for pixel data extraction, tensor manipulation, image augmentation, and model-specific preprocessing.
23+ ---
24+
25+ Provides comprehensive tools for pixel data extraction, tensor manipulation, image augmentation, and model-specific preprocessing with native implementations in Swift (iOS) and Kotlin (Android).
26+
27+ ## 📋 Table of Contents
28+
29+ - [ Features] ( #-features )
30+ - [ Installation] ( #-installation )
31+ - [ Quick Start] ( #-quick-start )
32+ - [ API Reference] ( #-api-reference )
33+ - [ Core Functions] ( #core-functions )
34+ - [ Image Analysis] ( #image-analysis )
35+ - [ Video Processing] ( #video-processing )
36+ - [ Image Augmentation] ( #image-augmentation )
37+ - [ Multi-Crop Operations] ( #multi-crop-operations )
38+ - [ Tensor Operations] ( #tensor-operations )
39+ - [ Quantization] ( #quantization )
40+ - [ Label Database] ( #label-database )
41+ - [ Camera Integration] ( #camera-integration )
42+ - [ Bounding Box Utilities] ( #bounding-box-utilities )
43+ - [ Letterbox Utilities] ( #letterbox-utilities )
44+ - [ Drawing & Visualization] ( #drawing--visualization )
45+ - [ Types Reference] ( #-types-reference )
46+ - [ Error Handling] ( #-error-handling )
47+ - [ Performance Tips] ( #-performance-tips )
48+ - [ Contributing] ( #-contributing )
49+ - [ License] ( #-license )
50+
51+ ---
452
5- ## Features
53+ ## ✨ Features
654
755- 🚀 ** High Performance** : Native implementations in Swift (iOS) and Kotlin (Android)
856- 🔢 ** Raw Pixel Data** : Extract pixel values as typed arrays (Float32, Int32, Uint8) ready for ML inference
@@ -31,7 +79,9 @@ A high-performance React Native library for image preprocessing optimized for ML
3179- ✅ ** Tensor Validation** : Validate tensor shapes, dtypes, and value ranges before inference
3280- 📦 ** Batch Assembly** : Combine multiple images into NCHW/NHWC batch tensors
3381
34- ## Installation
82+ ---
83+
84+ ## 📦 Installation
3585
3686``` sh
3787npm install react-native-vision-utils
@@ -43,7 +93,9 @@ For iOS, run:
4393cd ios && pod install
4494```
4595
46- ## Quick Start
96+ ---
97+
98+ ## 🚀 Quick Start
4799
48100### Basic Usage
49101
@@ -97,9 +149,11 @@ const mobileNetResult = await getPixelData({
97149| ` dino ` | 224×224 | cover | ImageNet | NCHW |
98150| ` detr ` | 800×800 | contain | ImageNet | NCHW |
99151
100- ## API Reference
152+ ---
153+
154+ ## 📖 API Reference
101155
102- ### Core Functions
156+ ### 🔧 Core Functions
103157
104158#### ` getPixelData(options) `
105159
@@ -178,7 +232,9 @@ results.results.forEach((result, index) => {
178232});
179233```
180234
181- ### Image Analysis
235+ ---
236+
237+ ### 🔍 Image Analysis
182238
183239#### ` getImageStatistics(source) `
184240
@@ -396,7 +452,9 @@ result.frames.forEach((frame) => {
396452| ` channels ` | number | Number of channels (only present when outputFormat='pixelData') |
397453| ` error ` | string | Error message if frame extraction failed (frame may still be present with partial data) |
398454
399- ### Image Augmentation
455+ ---
456+
457+ ### 🎨 Image Augmentation
400458
401459#### ` applyAugmentations(source, augmentations) `
402460
@@ -554,7 +612,9 @@ const probabilistic = await cutout(
554612| ` seed ` | number | Seed used for random generation |
555613| ` processingTimeMs ` | number | Processing time in milliseconds |
556614
557- ### Multi-Crop Operations
615+ ---
616+
617+ ### ✂️ Multi-Crop Operations
558618
559619#### ` fiveCrop(source, options, pixelOptions) `
560620
@@ -763,7 +823,9 @@ console.log(batch.data); // Combined Float32Array
763823| ` layout ` | 'nchw' \| 'nhwc' | 'nchw' | Output batch layout |
764824| ` padToSize ` | number | - | Pad batch to this size with zeros (optional) |
765825
766- ### Tensor Operations
826+ ---
827+
828+ ### 🧮 Tensor Operations
767829
768830#### ` extractChannel(data, width, height, channels, channelIndex, dataLayout) `
769831
@@ -860,7 +922,9 @@ const permuted = await permute(
860922console .log (permuted .shape ); // [channels, height, width]
861923```
862924
863- ### Tensor to Image
925+ ---
926+
927+ ### 🖼️ Tensor to Image
864928
865929#### ` tensorToImage(data, width, height, options) `
866930
@@ -892,7 +956,9 @@ const image = await tensorToImage(result.data, result.width, result.height, {
892956console .log (image .base64 ); // Base64 encoded PNG
893957```
894958
895- ### Cache Management
959+ ---
960+
961+ ### 💾 Cache Management
896962
897963#### ` clearCache() `
898964
@@ -918,7 +984,9 @@ console.log(stats.size);
918984console .log (stats .maxSize );
919985```
920986
921- ### Label Database
987+ ---
988+
989+ ### 🏷️ Label Database
922990
923991Built-in label databases for common ML classification and detection models. No external files needed.
924992
@@ -1018,7 +1086,9 @@ const datasets = await getAvailableDatasets();
10181086| ` places365 ` | 365 | Places365 scene recognition |
10191087| ` ade20k ` | 150 | ADE20K semantic segmentation |
10201088
1021- ### Camera Frame Utilities
1089+ ---
1090+
1091+ ### 📹 Camera Frame Utilities
10221092
10231093High-performance utilities for processing camera frames directly, optimized for integration with react-native-vision-camera.
10241094
@@ -1097,7 +1167,9 @@ console.log(rgbData.channels); // 3
10971167| ` left ` | 90° counter-clockwise |
10981168| ` right ` | 90° clockwise |
10991169
1100- ### Quantization (for TFLite and Other Quantized Models)
1170+ ---
1171+
1172+ ### 📊 Quantization (for TFLite and Other Quantized Models)
11011173
11021174Native high-performance quantization for deploying to quantized ML models like TFLite int8.
11031175
@@ -1215,7 +1287,9 @@ Quantize: q = round(value / scale + zeroPoint)
12151287Dequantize: value = (q - zeroPoint) * scale
12161288```
12171289
1218- ### Bounding Box Utilities
1290+ ---
1291+
1292+ ### 📦 Bounding Box Utilities
12191293
12201294High-performance utilities for working with object detection outputs.
12211295
@@ -1315,7 +1389,9 @@ const result = await nonMaxSuppression(detections, {
13151389// Keeps first and third detection; second is suppressed due to overlap
13161390```
13171391
1318- ### Letterbox Padding
1392+ ---
1393+
1394+ ### 📐 Letterbox Padding
13191395
13201396YOLO-style letterbox preprocessing for preserving aspect ratio.
13211397
@@ -1377,7 +1453,9 @@ const result = await reverseLetterbox(
13771453// Boxes are now in original 1920x1080 coordinates
13781454```
13791455
1380- ### Drawing & Visualization
1456+ ---
1457+
1458+ ### 🎨 Drawing & Visualization
13811459
13821460Utilities for visualizing detection and segmentation results.
13831461
@@ -1494,7 +1572,9 @@ const result = await overlayHeatmap(
14941572| ` hot ` | Black → Red → Yellow → White |
14951573| ` viridis ` | Purple → Blue → Green → Yellow |
14961574
1497- ## Type Reference
1575+ ---
1576+
1577+ ## 📝 Type Reference
14981578
14991579### Image Source Types
15001580
@@ -1587,7 +1667,9 @@ getChannelCount('grayscale'); // 1
15871667isVisionUtilsError (error ); // boolean
15881668```
15891669
1590- ## Error Handling
1670+ ---
1671+
1672+ ## ⚠️ Error Handling
15911673
15921674All functions throw ` VisionUtilsError ` on failure:
15931675
@@ -1612,37 +1694,57 @@ try {
16121694
16131695### Error Codes
16141696
1615- | Code | Description |
1616- | -------------------- | -------------------------- |
1617- | ` INVALID_SOURCE ` | Invalid image source |
1618- | ` LOAD_FAILED ` | Failed to load image |
1619- | ` INVALID_ROI ` | Invalid region of interest |
1620- | ` PROCESSING_FAILED ` | Processing error |
1621- | ` INVALID_OPTIONS ` | Invalid options provided |
1622- | ` INVALID_CHANNEL ` | Invalid channel index |
1623- | ` INVALID_PATCH ` | Invalid patch dimensions |
1624- | ` DIMENSION_MISMATCH ` | Tensor dimension mismatch |
1625- | ` EMPTY_BATCH ` | Empty batch provided |
1626- | ` UNKNOWN ` | Unknown error |
1697+ | Code | Description |
1698+ | :-----| :------------|
1699+ | ` INVALID_SOURCE ` | Invalid image source |
1700+ | ` LOAD_FAILED ` | Failed to load image |
1701+ | ` INVALID_ROI ` | Invalid region of interest |
1702+ | ` PROCESSING_FAILED ` | Processing error |
1703+ | ` INVALID_OPTIONS ` | Invalid options provided |
1704+ | ` INVALID_CHANNEL ` | Invalid channel index |
1705+ | ` INVALID_PATCH ` | Invalid patch dimensions |
1706+ | ` DIMENSION_MISMATCH ` | Tensor dimension mismatch |
1707+ | ` EMPTY_BATCH ` | Empty batch provided |
1708+ | ` UNKNOWN ` | Unknown error |
1709+
1710+ ---
1711+
1712+ ## ⚡ Performance Tips
16271713
1628- ## Performance Tips
1714+ > 💡 ** Pro Tips for optimal performance **
16291715
1630- 1 . ** Use appropriate resize strategies** : ` letterbox ` for YOLO, ` cover ` for classification models
1631- 2 . ** Batch processing** : Use ` batchGetPixelData ` with appropriate concurrency for multiple images
1632- 3 . ** Cache management** : Call ` clearCache() ` when memory is constrained
1633- 4 . ** Use model presets** : Pre-configured settings are optimized for each model
1634- 5 . ** Avoid unnecessary conversions** : Choose the right ` dataLayout ` upfront
1716+ | Tip | Description |
1717+ | :----| :------------|
1718+ | 🎯 ** Resize Strategies** | Use ` letterbox ` for YOLO, ` cover ` for classification models |
1719+ | 📦 ** Batch Processing** | Use ` batchGetPixelData ` with appropriate concurrency for multiple images |
1720+ | 💾 ** Cache Management** | Call ` clearCache() ` when memory is constrained |
1721+ | ⚙️ ** Model Presets** | Pre-configured settings are optimized for each model |
1722+ | 🔄 ** Data Layout** | Choose the right ` dataLayout ` upfront to avoid unnecessary conversions |
16351723
1636- ## Contributing
1724+ ---
16371725
1638- - [ Development workflow] ( CONTRIBUTING.md#development-workflow )
1639- - [ Sending a pull request] ( CONTRIBUTING.md#sending-a-pull-request )
1640- - [ Code of conduct] ( CODE_OF_CONDUCT.md )
1726+ ## 🤝 Contributing
16411727
1642- ## License
1728+ We welcome contributions! Please see our guides:
1729+
1730+ | Resource | Description |
1731+ | :---------| :------------|
1732+ | 📋 [ Development workflow] ( CONTRIBUTING.md#development-workflow ) | How to set up your dev environment |
1733+ | 🔀 [ Sending a pull request] ( CONTRIBUTING.md#sending-a-pull-request ) | Guidelines for submitting PRs |
1734+ | 📜 [ Code of conduct] ( CODE_OF_CONDUCT.md ) | Community guidelines |
1735+
1736+ ---
1737+
1738+ ## 📄 License
16431739
16441740MIT
16451741
16461742---
16471743
1648- Made with [ create-react-native-library] ( https://github.com/callstack/react-native-builder-bob )
1744+ <p align =" center " >
1745+ Made with ❤️ using <a href =" https://github.com/callstack/react-native-builder-bob " >create-react-native-library</a >
1746+ </p >
1747+
1748+ <p align =" center " >
1749+ <a href =" #react-native-vision-utils " >⬆️ Back to Top</a >
1750+ </p >
0 commit comments