我想从相册列出的图像列表中检测人脸。
这是我的代码。
// get All images from particular album
await CameraRoll.getPhotos({
first: count,
after,
assetType: 'Photos',
groupTypes: 'All',
groupName: this.props.navigation.state.params.album,
})
.then(r => {
this.setState({ data: r.edges, isLoading: false, });
this.state.data.map((p, index) => {
this.getFaces(p.node.image.uri);
});
})
}
//从图像列表中检测人脸
async getFaces(uri) {
await FaceDetector.detectFacesAsync(uri).then(res => {
if (res.faces.length > 0) {
console.log('Has faces: ' + uri);
this.state.faceImage.push(uri); // array of face images and set it to Flatlist
} else {
console.log('No faces: ' + uri);
}
});
this.setState({
faceImage: this.state.faceImage,
isLoading: false,
});
}
一切正常,但是当图像数组很大时,我的应用程序被卡住并仅在android设备中关闭。
答案 0 :(得分:0)
尝试在数组大小较大时将其拆分为新数组
答案 1 :(得分:0)
您是否尝试过将其保存到文件并从那里加载?