question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read images from Tensorflow.js Tensorcamera on React Native

See original GitHub issue

I am trying to use Tensorflow.js posenet on React Native but I can not get ‘images’. Currently Expo-camera works ok, but images is undefined. Please advise how to iterate getting images from TensorCamera. Thanks.

const TensorCamera = cameraWithTensors(Camera);

export default class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.handleCameraStream = this.handleCameraStream.bind(this);
  }

  async estimatePoseOnImage(imageElement) {
    const net = await posenet.load();
    const pose = await net.estimateSinglePose(imageElement, {
      flipHorizontal: false,
    });
    this.setState({ pose: pose });
    return pose;
  }

  handleCameraStream( images ) {
    const loop = async () => {
      const nextImageTensor = await images.next().value;
      await this.estimatePoseOnImage(nextImageTensor);
      requestAnimationFrame(loop);
    };
    loop();
  }

  render() {
    return (
      <View>
        <TensorCamera
          type={Camera.Constants.Type.front}
          onReady={this.handleCameraStream}
          autorender={true}
        />
      </View>
    );
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
fergalindezcommented, Feb 29, 2020

I’m trying to follow this demo => https://github.com/tensorflow/tfjs/blob/master/tfjs-react-native/integration_rn59/components/webcam/realtime_demo.tsx, but none of the models’ load. I’m using expo to make the test. @rthadur @tafsiri

1reaction
tafsiricommented, Mar 3, 2020

@sauceishere Could you try changing your react import to import * as React from 'react'; and having your main component extend React.Component. Newer versions of expo use a different import format that what is used in the integration_test app.

If that doesn’t work then from looking at the error stack it seemed to be coming from react-native-svg, so I would first remove all the things from the app other than the model loading and inference and make sure that works before introducing rendering.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read images from Tensorflow.js Tensorcamera on ...
js posenet on React Native but I can not get 'images'. Currently Expo-camera works ok, but images is undefined, and it also shows....
Read more >
DevAsking.com - The issue Cannot read images from... | Facebook
The issue Cannot read images from Tensorflow.js Tensorcamera on React Native has new answer.
Read more >
Real Time Image Classification with TensorFlow and React ...
In this tutorial we will implement a simple mobile app that acts as a pictionary (picture dictionary) for a specific language by using...
Read more >
tf.io.RequestDetails - TensorFlow.js React Native API
Utilities for dealing with images and cameras. Media / Images. decodeJpeg (contents, channels?) function Source. Decode a ...
Read more >
Using TensorFlow.js in a Native iOS App to Perform Object ...
tflite model to your project. To help solve this problem, let's take a look how we can apply a JavaScript version of TensorFlow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found