簡體   English   中英

React-Native 從圖像列表中進行人臉檢測

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

我想從相冊中列出的圖像列表中檢測人臉..

這是我的代碼..

  // 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 設備中關閉。

當數組的大小很大時嘗試將其拆分為新數組

您是否嘗試將其保存到文件並從那里加載?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM