A React SDK for XtraVision API
It is an sdk for fitness related data assessments like calories, rep-count, yoga pose-matching etc specifically for the vite framework
npm install @xtravision/xtravision-react
or
yarn add @xtravision/xtravision-react
- import the relevant features you want:
import {
ClassCategory,
Features,
Assessment,
XtraVisionOnDemandProvider,
useXtraVisionOnDemandContext,
useXtraVisionAssessmentContext,
XtraVisionAssessmentProvider,
XtraVisionEventEmitter, // optional
} from "@xtravision/xtravision-react";
- use the context to get the values:
const { lastJsonMessage, isCamOn, setIsCamOn } = useXtraVisionAssessmentContext();
const videoElementRef = useRef<any>(null);
// use for draw skeleton
const canvasRef = useRef<any>(null);
const isEduScreen = false;
// assessment name you want
const assessment_name = 'SQUATS';
const auth_token ="__AUTH_TOKEN__";
const connectionData = {
assessment_name,
auth_token,
}
const requestData = {
isPreJoin
}
- wrap the component in the context provider and pass the results from the previous context:
<XtraVisionAssessmentProvider
videoElementRef={videoElementRef}
connectionData={connectionData}
requestData={requestData}
canvasElementRef={canvasRef}
>
{children}
</XtraVisionAssessmentProvider>
{children}
elements must have below code and need to connected media input devices usingnavigator.mediaDevices
. Please take further reference from demo app.
<video ref={videoElementRef} ></video>
<!-- <canvas ref={canvasElementRef}></canvas> // use canvas if you need skeleton -->
- If you need live user key-points then you can use
XtraVisionEventEmitter
XtraVisionEventEmitter.on('onUserKeyPoints', (data: any) => {console.log('data.toString()');})