
Security News
RubyGems Adds Cooldown Feature to Bundler for Newly Published Gems
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.
react-native-mediapipe-posedetection
Advanced tools
PoseDetection using google's mediapipe models using poselandmark
High-performance pose detection for React Native using Google's MediaPipe models with optimized frame processing for smooth real-time tracking.
You can find the package on npm: react-native-mediapipe-posedetection
⚠️ New Architecture Required
This library only supports React Native's New Architecture (Turbo Modules). You must enable the New Architecture in your app to use this library.
react-native-vision-camerareact-native-vision-camera ^4.0.0 (for real-time detection)react-native-worklets-core ^1.0.0 (for frame processing)npm install react-native-mediapipe-posedetection react-native-vision-camera react-native-worklets-core
# or
yarn add react-native-mediapipe-posedetection react-native-vision-camera react-native-worklets-core
If you are using Expo, you can use the built-in config plugin to automatically copy your MediaPipe model files to the native Android and iOS projects during prebuild.
pose_landmarker_lite.task) to a directory in your project (e.g., ./assets/models/).app.json or app.config.js:{
"expo": {
"plugins": [
[
"react-native-mediapipe-posedetection",
{
"assetsPaths": ["./assets/models/"]
}
]
]
}
}
This plugin will copy all files from the specified assetsPaths to:
android/app/src/main/assets/Note: The
assetsPathsare relative to your project root.
If you haven't already enabled the New Architecture in your React Native app:
In your android/gradle.properties:
newArchEnabled=true
In your ios/Podfile:
use_frameworks! :linkage => :static
$RNNewArchEnabled = true
Then reinstall pods:
cd ios && pod install
pose_landmarker_lite.task)The MediaPipe dependencies are automatically included. Place your model file in android/app/src/main/assets/.
import {
usePoseDetection,
RunningMode,
Delegate,
KnownPoseLandmarks,
} from 'react-native-mediapipe-posedetection';
import { Camera, useCameraDevice } from 'react-native-vision-camera';
function PoseDetectionScreen() {
const device = useCameraDevice('back');
const poseDetection = usePoseDetection(
{
onResults: (result) => {
// result.landmarks contains detected pose keypoints
console.log('Number of poses:', result.landmarks.length);
if (result.landmarks[0]?.length > 0) {
const nose = result.landmarks[0][KnownPoseLandmarks.nose];
console.log('Nose position:', nose.x, nose.y);
}
},
onError: (error) => {
console.error('Detection error:', error.message);
},
},
RunningMode.LIVE_STREAM,
'pose_landmarker_lite.task',
{
numPoses: 1,
minPoseDetectionConfidence: 0.5,
minPosePresenceConfidence: 0.5,
minTrackingConfidence: 0.5,
delegate: Delegate.GPU,
}
);
if (!device) return null;
return (
<Camera
style={{ flex: 1 }}
device={device}
isActive={true}
frameProcessor={poseDetection.frameProcessor}
onLayout={poseDetection.cameraViewLayoutChangeHandler}
/>
);
}
import {
PoseDetectionOnImage,
Delegate,
} from 'react-native-mediapipe-posedetection';
async function detectPoseInImage(imagePath: string) {
const result = await PoseDetectionOnImage(
imagePath,
'pose_landmarker_lite.task',
{
numPoses: 2, // Detect up to 2 people
minPoseDetectionConfidence: 0.5,
delegate: Delegate.GPU,
}
);
console.log('Detected poses:', result.landmarks.length);
console.log('Inference time:', result.inferenceTime, 'ms');
}
For a simpler setup, use the provided MediapipeCamera component:
import { MediapipeCamera } from 'react-native-mediapipe-posedetection';
function App() {
return (
<MediapipeCamera
style={{ flex: 1 }}
cameraPosition="back"
onResults={(result) => {
console.log('Pose detected:', result.landmarks);
}}
poseDetectionOptions={{
numPoses: 1,
minPoseDetectionConfidence: 0.5,
}}
/>
);
}
usePoseDetection(callbacks, runningMode, model, options)Hook for real-time pose detection.
Parameters:
callbacks: DetectionCallbacks<PoseDetectionResultBundle>
onResults: (result: PoseDetectionResultBundle) => void - Called when poses are detectedonError: (error: DetectionError) => void - Called on detection errorsrunningMode: RunningMode
RunningMode.LIVE_STREAM - For camera/video inputRunningMode.VIDEO - For video file processingRunningMode.IMAGE - For static images (use PoseDetectionOnImage instead)model: string - Path to MediaPipe model file (e.g., 'pose_landmarker_lite.task')
options: Partial<PoseDetectionOptions> (optional)
numPoses: number - Maximum number of poses to detect (default: 1)minPoseDetectionConfidence: number - min confidence threshold (default: 0.5)minPosePresenceConfidence: number - min presence threshold (default: 0.5)minTrackingConfidence: number - min tracking threshold (default: 0.5)shouldOutputSegmentationMasks: boolean - Include segmentation masks (default: false)delegate: Delegate.CPU | Delegate.GPU | Delegate.NNAPI - Processing delegate (default: GPU)mirrorMode: 'no-mirror' | 'mirror' | 'mirror-front-only' - Camera mirroringfpsMode: 'none' | number - Additional FPS throttling (default: 'none')Returns: MediaPipeSolution
frameProcessor: VisionCamera frame processorcameraViewLayoutChangeHandler: Layout change handlercameraDeviceChangeHandler: Camera device change handlercameraOrientationChangedHandler: Orientation change handlerresizeModeChangeHandler: Resize mode handlercameraViewDimensions: Current camera view dimensionsPoseDetectionOnImage(imagePath, model, options)Detect poses in a static image.
Parameters:
imagePath: string - Path to the image filemodel: string - Path to MediaPipe model fileoptions: Same as usePoseDetection optionsReturns: Promise<PoseDetectionResultBundle>
interface PoseDetectionResultBundle {
inferenceTime: number; // Milliseconds
size: { width: number; height: number };
landmarks: Landmark[][]; // Array of poses, each with 33 landmarks
worldLandmarks: Landmark[][]; // 3D world coordinates
segmentationMasks?: Mask[]; // Optional segmentation masks
}
interface Landmark {
x: number; // Normalized 0-1
y: number; // Normalized 0-1
z: number; // Depth (relative)
visibility?: number; // Confidence 0-1
presence?: number; // Presence confidence 0-1
}
Use KnownPoseLandmarks for easy landmark access:
import { KnownPoseLandmarks } from 'react-native-mediapipe-posedetection';
const landmarks = result.landmarks[0];
const nose = landmarks[KnownPoseLandmarks.nose];
const leftShoulder = landmarks[KnownPoseLandmarks.leftShoulder];
const rightWrist = landmarks[KnownPoseLandmarks.rightWrist];
Available landmarks:
nose, leftEye, rightEye, leftEar, rightEar, mouthLeft, mouthRightleftShoulder, rightShoulder, leftElbow, rightElbow, leftWrist, rightWristleftPinky, rightPinky, leftIndex, rightIndex, leftThumb, rightThumbleftHip, rightHip, leftKnee, rightKnee, leftAnkle, rightAnkleleftHeel, rightHeel, leftFootIndex, rightFootIndexThis library includes critical performance optimizations for React Native's new architecture:
To prevent memory pressure and crashes, the library automatically throttles:
This dual-layer throttling ensures:
The throttling is transparent and requires no configuration. 15 FPS is sufficient for smooth pose tracking in most use cases.
For even more control, use the fpsMode option:
usePoseDetection(callbacks, RunningMode.LIVE_STREAM, 'model.task', {
fpsMode: 10, // Process frames at 10 FPS
});
If you were using a previous version that supported the Bridge architecture:
Upgrade React Native to 0.74.0 or higher
Enable New Architecture (see installation instructions)
Rebuild your app completely:
# iOS
cd ios && pod install && cd ..
# Android
cd android && ./gradlew clean && cd ..
The API remains the same, so your application code shouldn't need changes.
Cause: New Architecture is not enabled or not properly configured.
Solution:
newArchEnabled=true in android/gradle.properties$RNNewArchEnabled = true in ios/PodfileCause: Model file not found or invalid configuration.
Solution:
Solution: The library automatically throttles to prevent this. If you still experience issues:
numPoses to 1shouldOutputSegmentationMasks: falseDelegate.CPU instead of Delegate.GPU if GPU memory is limitedSolutions:
pose_landmarker_lite.task instead of pose_landmarker_full.taskfpsMode: 10 for lower frame processingnumPoses if you don't need to detect multiple peopledelegate: Delegate.GPUCheck out the example directory for a complete working app demonstrating:
Run the example:
cd example
yarn install
yarn ios # or yarn android
See the contributing guide to learn how to contribute to the repository and the development workflow.
This library is based on the work from react-native-mediapipe by cdiddy77. The pose detection module codes were taken from this repository and upgraded to support React Native's New Architecture (Turbo Modules).
MIT © EndLess728
Made with create-react-native-library
FAQs
PoseDetection using google's mediapipe models using poselandmark
The npm package react-native-mediapipe-posedetection receives a total of 297 weekly downloads. As such, react-native-mediapipe-posedetection popularity was classified as not popular.
We found that react-native-mediapipe-posedetection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.