Reputation: 2334
I have the following React Native App.js File where I'm trying to print nextImageTensor
received, but the flow is not going inside loop(). As a matter of fact loop is not even getting called
App.js
import * as React from "react";
import { Text, View, StyleSheet, Image, Platform } from "react-native";
import { Camera } from "expo-camera/legacy";
import { cameraWithTensors } from "@tensorflow/tfjs-react-native";
import * as tf from "@tensorflow/tfjs";
const TensorCamera = cameraWithTensors(Camera);
export default class MyComponent extends React.Component {
constructor(props) {
super(props);
this.handleCameraStream = this.handleCameraStream.bind(this);
}
handleCameraStream(images) {
const loop = async () => {
const nextImageTensor = await images.next().value;
console.log("Hreee:", nextImageTensor);
requestAnimationFrame(loop);
};
loop();
}
render() {
return (
<View>
<TensorCamera
ref={(ref) => {
this.camera = ref;
}}
type={Camera.Constants.Type.front}
cameraTextureHeight={500}
cameraTextureWidth={500}
resizeHeight={64}
resizeWidth={64}
resizeDepth={3}
onReady={this.handleCameraStream}
style={{ width: "100%", height: "100%" }}
autorender={true}
/>
</View>
);
}
}
package.json contains following dependencies
{
"@mediapipe/face_detection": "^0.4.1646425229",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-navigation/native": "^6.1.18",
"@react-navigation/stack": "^6.4.1",
"@tensorflow-models/face-detection": "^1.0.2",
"@tensorflow-models/handpose": "^0.1.0",
"@tensorflow-models/mobilenet": "^2.1.0",
"@tensorflow/tfjs": "^3.10.0",
"@tensorflow/tfjs-backend-wasm": "^4.20.0",
"@tensorflow/tfjs-react-native": "^1.0.0",
"expo": "^51.0.24",
"expo-av": "~14.0.6",
"expo-camera": "~15.0.14",
"expo-gl": "~14.0.2",
"expo-module-scripts": "^3.5.2",
"expo-status-bar": "~1.12.1",
"expo-updates": "~0.25.21",
"fingerpose": "^0.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.3",
"react-native-fs": "^2.16.6",
"react-native-gesture-handler": "~2.16.1",
"react-native-linear-gradient": "^2.8.3",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-web": "~0.19.6",
"react-native-webview": "13.8.6",
}
Upvotes: 1
Views: 161