【发布时间】:2021-07-08 18:43:04
【问题描述】:
在试图找出适用于 Android 设备的问题时被卡住了一段时间。 tensorFlow.js library 中的示例代码表明,必须凭经验确定相机的分辨率。对于 iphone,它在各个版本中相对一致(仅针对版本 6 及更高版本进行更改),但是 android 手机如此多样化,我需要找出一种自动确定它的方法。当分辨率不正确时,身体扫描应用程序中用于指代身体不同部位的航点位于错误的位置(例如:头部靠近肩膀)。有没有人有提示找到解决方案?许多资源只是将它们称为幻数。我还联系了一个有类似问题的人,他有no response。
import { Camera } from 'expo-camera';
import { cameraWithTensors } from '@tensorflow/tfjs-react-native';
const TensorCamera = cameraWithTensors(Camera);
class MyComponent {
handleCameraStream(images, updatePreview, gl) {
const loop = async () => {
const nextImageTensor = images.next().value
//
// do something with tensor here
//
// if autorender is false you need the following two lines.
// updatePreview();
// gl.endFrameEXP();
requestAnimation(loop);
}
loop();
}
render() {
// Currently expo does not support automatically determining the
// resolution of the camera texture used. So it must be determined
// empirically for the supported devices and preview size.
let textureDims;
if (Platform.OS === 'ios') {
textureDims = {
height: 1920,
width: 1080,
};
} else {
textureDims = {
height: 1200,
width: 1600,
};
}
return <View>
<TensorCamera
// Standard Camera props
style={styles.camera}
type={Camera.Constants.Type.front}
// Tensor related props
cameraTextureHeight={textureDims.height}
cameraTextureWidth={textureDims.width}
resizeHeight={200}
resizeWidth={152}
resizeDepth={3}
onReady={this.handleCameraStream}
autorender={true}
/>
</View>
}
}
【问题讨论】:
标签: react-native tensorflow tensorflow.js