Reactjs AWS识别图像编码问题
我有一个项目要完成,每当图像被编码到base64,就像AWS Rekognition docs告诉我的那样,以获取元数据Reactjs AWS识别图像编码问题,reactjs,amazon-web-services,webcam,encode,amazon-rekognition,Reactjs,Amazon Web Services,Webcam,Encode,Amazon Rekognition,我有一个项目要完成,每当图像被编码到base64,就像AWS Rekognition docs告诉我的那样,以获取元数据 .getScreenshot()返回已捕获图像的base64 以下是我目前的代码: import React, { Component } from "react"; import Webcam from "react-webcam"; import AWS from "aws-sdk"; import { creds } from "./secret"; import {
.getScreenshot()
返回已捕获图像的base64
以下是我目前的代码:
import React, { Component } from "react";
import Webcam from "react-webcam";
import AWS from "aws-sdk";
import { creds } from "./secret";
import { Grid, Container, Button, Input } from "semantic-ui-react";
AWS.config.update({
accessKeyId: creds.accessKeyId,
secretAccessKey: creds.secretAccessKey,
region: "us-east-1"
});
const rekognition = new AWS.Rekognition({ apiVersion: "2016-06-27" });
class CameraComponent extends Component {
constructor() {
super();
this.state = {
verificationFailed: "",
verificationSucceed: "",
faceId: "",
fileName: ""
};
this.changeToFileName = this.changeToFileName.bind(this);
}
setRef = webcam => {
this.webcam = webcam;
};
capture = () => {
const image = this.webcam.getScreenshot().slice(23);
console.log(image);
const params = {
SourceImage: {
Bytes: image
},
TargetImage: {
S3Object: {
Bucket: "my-bucket",
Name: "my-image.jpg"
}
},
SimilarityThreshold: 0.0
};
rekognition.compareFaces(params, (err, data) => {
if (err) console.log(err);
console.log(data);
});
};
提前谢谢 你真正的问题是什么?您遇到了什么问题?@JohnRotenstein的问题是,即使编码后的base64字符串按说明传入“Bytes”属性,它也不会返回数据。this.webcam.getScreenshot()从捕获的图像返回base64数据。您成功修复了此问题吗?面对同样的问题