OpenCV react wrapper. Hooks first API.
npm install opencv-react-rkloaded state which is provided by the OpenCvProvider component
bash
npm i opencv-react
`
or
`bash
yarn add opencv-react
`
API
OpenCvProvider
$3
- openCvPath: string used to indicate where to load the OpenCv lib from (default to official cdn)
- onLoad: function that gets called whenever the library has finished loading (see the package description)
Usage:
`js
const MyApp = () => {
return (
)
}
`
useOpenCv
$3
`
{
loaded: boolean, indicates if the opencv library is loaded (useful to show a spinner)
cv: undefined or the OpenCV global instance (can also be found in window.cv)
}
`
`js
function MyComponent() {
const { loaded, cv } = useOpenCv()
useEffect(() => {
if (cv) {
}
}, [cv])
return OpenCv React test
}
`
Quick Start
`javascript
function MyComponent() {
const data = useOpenCv()
console.log(data)
return OpenCv React test
}
const App = () => {
const onLoaded = (cv) => {
console.log('opencv loaded', cv)
}
return (
)
}
``