简体   繁体   English

React-Native 从图像列表中进行人脸检测

[英]React-Native Face detect from list of images

i want to detect faces from list of images which are listed from photo albums..我想从相册中列出的图像列表中检测人脸..

here is my code..这是我的代码..

  // 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);
            });
          })
}

// Detect faces from list of images // 从图像列表中检测人脸

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,
      });

  }

All things are worked correctly but when image array size was big then my app was stuck and close only in android device.一切正常,但是当图像数组大小很大时,我的应用程序被卡住并仅在 android 设备中关闭。

Try to split it to new array when the size of the array is to big当数组的大小很大时尝试将其拆分为新数组

Have you tried to save it to file and load it from there?您是否尝试将其保存到文件并从那里加载?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM