UNPKG

@gymbrosinc/react-native-mediapipe-pose

Version:

React Native MediaPipe Pose Detection with GPU acceleration, jump detection, and high-performance analysis

38 lines 1.36 kB
import * as React from 'react'; export default function ReactNativeMediapipePoseView(props) { const [mediaStream, setMediaStream] = React.useState(null); const videoRef = React.useRef(null); React.useEffect(() => { // Request camera access const constraints = { video: { facingMode: props.cameraType === 'front' ? 'user' : 'environment', }, }; navigator.mediaDevices .getUserMedia(constraints) .then((stream) => { setMediaStream(stream); if (videoRef.current) { videoRef.current.srcObject = stream; } props.onCameraReady?.({ nativeEvent: { ready: true } }); }) .catch((error) => { console.error('Error accessing camera:', error); props.onError?.({ nativeEvent: { error: error.message } }); }); return () => { if (mediaStream) { mediaStream.getTracks().forEach((track) => track.stop()); } }; }, [props.cameraType]); return (<video ref={videoRef} autoPlay playsInline muted style={{ width: '100%', height: '100%', objectFit: 'cover', ...props.style, }}/>); } //# sourceMappingURL=ReactNativeMediapipePoseView.web.js.map