1.2.12 • Published 10 months ago
use-grid-selector v1.2.12
Use Grid Selector
Mobile friendly grid selector
Usage
UI
import { useGridSelector } from 'use-grid-selector'
const { ref, coords } = useGridSelector('/image.jpg', template)
function displayCoords() {
console.log(coords())
}
return (
...
<canvas ref={ref} />
)
Extracting ROIs
worker.ts
:import cv from "opencv-ts"; // or importScripts to a custom opencv.js, or whatever import { onMessage } from 'use-grid-selector/worker' onmessage = onMessage(cv)
MySelector.tsx
:import { grid, models } from 'scoresheet-models' import { prepareWorker } from 'use-grid-selector/worker' const worker = new Worker('/path/to/worker.ts') const api = prepareWorker(worker) // perhaps it'd be recommendable to keep this stuff in a `useRef` function MySelector() { const img = '/image.jpg' const model = models.fcde // or an arbitrary Model const { ref, coords } = useGridSelector(img, grid(model)) function initialize() { api.postImg(img) // not necessary, but makes subsequent calls faster } async function extract() { const config = { model, coords: coords() } for (const idx of range(16)) { const blob = await api.extract(img, idx, config) } } }
You can also pre-post the configuration if you wont change it further:
const CONFIG = { ... } api.postConfig(CONFIG) // then always call with api.extract(img, CONFIG)
1.2.8
10 months ago
1.2.7
11 months ago
1.2.6
12 months ago
1.2.5
12 months ago
1.2.9
10 months ago
1.2.12
10 months ago
1.2.10
10 months ago
1.2.11
10 months ago
1.2.4
1 year ago
1.2.0
1 year ago
1.2.3
1 year ago
1.2.2
1 year ago
1.2.1
1 year ago
1.1.25
1 year ago
1.1.23
1 year ago
1.1.22
1 year ago
1.1.12
1 year ago
1.1.11
1 year ago
1.1.14
1 year ago
1.1.13
1 year ago
1.1.19
1 year ago
1.1.18
1 year ago
1.1.17
1 year ago
1.1.21
1 year ago
1.1.20
1 year ago
1.1.9
1 year ago
1.1.8
1 year ago
1.1.7
1 year ago
1.1.6
1 year ago
1.1.5
1 year ago
1.1.4
1 year ago
1.1.2
1 year ago
1.1.1
1 year ago
1.0.7
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago