javascript - 使用 Base64 格式的图像向 Face++ 检测 API 发出请求

标签 javascript node.js face-detection

我正在尝试将图像发送到 Face++ Detect API 使用 image_base64 参数。但是我收到一个错误:

414 Request-URI Too Large

414 Request-URI Too Large

The requested URL's length exceeds the capacity limit for this server.

我使用以下代码来发出请求:

function sendImageProcess(img_64) {
    var url = "https://api-us.faceplusplus.com/facepp/v3/detect";
    request({
        uri: url,
        method: 'POST',
        qs: {
            api_secret: fpp_pass,
            api_key: fpp_key,
            return_attributes: "gender",
            image_base64: img_64,
            return_landmark: "1"
        }
    },function (error, response) {
        if(!error){
            console.log(response.body);
            return response.body;
        }
        else{
            console.log(error);
        }
    });
}

这里img_64是图像的base64字符串。

也许,我不明白发送 image_base64 参数的方式。

img_64 字符串如下所示:

data:image/jpeg;base64,/9j/4RSJRXhpZgAATU0AKgAAAAgADAEAAAMAAAABAawAAAEBAAMAAAABAn0AAAECAAMAAAADAAAAngEGAAMAAAABAAIAAAESAAMAAAABAAEAAAEVAAMAAAABAAMAAAEaAAUAAAABAAAApAEbAAUAAAABAAAArAEoAAMAAAABAAIAAAExAAIAAAAkAAAAtAEyAAIAAAAUAAAA2Idp.........and so on

我希望有人能帮助我。

谢谢!

最佳答案

在我砍掉“data:image/jpeg;base64”部分后,它对我有用,尽管如果您的图像太大,我会从那里开始。

关于javascript - 使用 Base64 格式的图像向 Face++ 检测 API 发出请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44568431/

相关文章:

javascript - 根据上下文进行 toPrimitive 转换

node.js - nginx 代理到子目录中的远程 Node.js Express 应用程序

node.js - 当在Mongoose中使用时,Node.js UUIDv4产生恒定的id值

javascript - NodeJS - 解析 JSON(仅字符串或数字)

python - mediapipe 解决方案::FaceDetection

android - 在 Android 中裁剪检测到的人脸

javascript - 如何将加载的图像读入 blob?

javascript - 我怎样才能让父元素在大小方面与它的子元素完全一样?

javascript - 指令中的链接功能是否通过路由运行?

android - 慢人脸检测android