React Native mask segmentation canvas library: OpenCV semantic segmentation + SkSL Shader coloring
Go to file
a1518 3a3f07628d
Some checks failed
Deploy Docs to GitHub Pages / deploy (push) Has been cancelled
Publish to npm / publish (push) Has been cancelled
feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement
- New magneticLasso module: Sobel energy map + Dijkstra shortest-path + Douglas-Peucker
- New activeContour module: greedy snake + balloon force for polygon-to-edge refinement
- wallTextureSplit: edge barrier mask, morphological mask hole closing, Moore boundary tracing, simplified polygon contours, manual pick map patching, gap absorption
- MaskSegmentCanvas: full lasso gesture pipeline (tap vertices, drag, magnetic paths, close polygon, endLasso/cancelLasso/deleteLasso)
- New maskConfig options: splitWallsEdgeBarrierThreshold, splitWallsCloseMaskRadius, manualSplitWalls, manualSplitWallsMaxCount, manualSplitWallsGapAbsorbDilatePx, magneticLasso, activeContourRefine
- New ref methods: startLasso, endLasso, cancelLasso, getManualRegions, deleteLasso
- New exported types: LassoPolygon, ManualWallPartition
- RegionMaskData carries indexToName and wallSemanticIdx through downsample
- Simplify README to point to documentation site
- Update documentation site (EN + ZH-CN) with all new APIs and interaction guide
- Example app: lasso mode toggles and operation buttons

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 20:23:57 -07:00
__tests__ feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement 2026-07-06 20:23:57 -07:00
.bundle Initial commit 2026-06-13 06:47:11 +08:00
.github/workflows Fix GitHub Pages deploy workflow permissions and branch trigger 2026-07-02 23:34:48 -07:00
android feat: add MaskSegmentApp source code and config 2026-06-26 00:23:52 -07:00
assets/test feat: add MaskSegmentApp source code and config 2026-06-26 00:23:52 -07:00
dist feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement 2026-07-06 20:23:57 -07:00
docs feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement 2026-07-06 20:23:57 -07:00
example feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement 2026-07-06 20:23:57 -07:00
ios refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
patches refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
scripts refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
src feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement 2026-07-06 20:23:57 -07:00
.eslintrc.js Initial commit 2026-06-13 06:47:11 +08:00
.gitignore Add example app and fix Android asset loading on image switch. 2026-06-30 20:24:43 -07:00
.npmignore refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
.prettierrc.js Initial commit 2026-06-13 06:47:11 +08:00
.watchmanconfig Initial commit 2026-06-13 06:47:11 +08:00
app.json Initial commit 2026-06-13 06:47:11 +08:00
App.tsx refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
babel.config.js feat: add MaskSegmentApp source code and config 2026-06-26 00:23:52 -07:00
Gemfile Initial commit 2026-06-13 06:47:11 +08:00
index.js refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
jest.config.js Initial commit 2026-06-13 06:47:11 +08:00
metro.config.js refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
package-lock.json refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
package.json feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement 2026-07-06 20:23:57 -07:00
react-native.config.js Add example app and fix Android asset loading on image switch. 2026-06-30 20:24:43 -07:00
README.md feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement 2026-07-06 20:23:57 -07:00
README.zh-CN.md docs: add bilingual README (EN default, ZH-CN via switcher) 2026-07-02 22:50:32 -07:00
tsconfig.build.json refactor: remove Chinese, add build obfuscation, polish README 2026-07-01 19:07:32 -07:00
tsconfig.json Initial commit 2026-06-13 06:47:11 +08:00

🇨🇳 中文文档


🎨 react-native-mask-segment-canvas

A React Native 0.79 interactive mask segmentation library combining OpenCV semantic layout + Skia GPU-accelerated texture painting.

  • 🧠 OpenCV (react-native-fast-opencv): mask semantic layout, baseboard patching, region extraction
  • 🖌️ Skia RuntimeEffect (SkSL): single-pass LAB frequency-layer color blending
  • ✂️ Skia Path: dashed outline highlights per region
  • 🧲 Magnetic Lasso: manual wall partitioning with edge-snapping + Active Contour refinement

📖 Full Documentation

All API references, configuration guides, integration examples, and troubleshooting are maintained on the documentation site:

👉 https://tonychan-hub.github.io/react-native-mask-segment-canvas/

Section Description
Overview Architecture & pipeline overview
Installation Peer deps, postinstall, Metro config
Basic Usage Minimal example, state variables, watchState
API Reference Props, ref methods, types, storage convention
Performance Benchmarks, optimization tips, pipeline config tuning
Troubleshooting Common issues & fixes

📦 Quick Install

npm install react-native-mask-segment-canvas

Required peer dependencies:

npm install @shopify/react-native-skia react-native-reanimated \
  react-native-fast-opencv react-native-fs buffer upng-js

Your host package.json must include patch-package in postinstall:

{
  "scripts": { "postinstall": "patch-package" },
  "devDependencies": { "patch-package": "^8.0.1" }
}

See the Installation Guide for full Metro configuration and troubleshooting duplicate module errors.


🧪 Example Project

The example/ directory contains a complete consumer-side integration demo using only the public API — ideal as a template for your own project.

cd example
npm install
cd ios && pod install && cd ..
npm start

🏗️ Dev Demo

The root App.tsx is a self-test demo that imports directly from ./src:

npm install
cd ios && pod install && cd ..
npm run ios  # or `npm run android`

📁 Project Structure

MaskSegmentApp/
├── src/                 # Library source → published to npm
│   ├── index.ts
│   └── components/ / utils/
├── docs/                # Docusaurus documentation site
├── example/             # Consumer-side integration demo
├── App.tsx              # Dev self-test (imports from ./src)
└── patches/             # patch-package patches for react-native-fast-opencv