【问题标题】:Making a request to Face++ detect API with image in base64 format使用 base64 格式的图像向 Face++ 检测 API 发出请求
【发布时间】:2017-11-18 00:03:26
【问题描述】:

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

414 请求 URI 太大

414 Request-URI Too Large

请求的 URL 的长度超过了此服务器的容量限制。

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

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

我希望有人可以帮助我。

谢谢!

【问题讨论】:

    标签: javascript node.js face-detection


    【解决方案1】:

    在我切掉 'data:image/jpeg;base64,' 部分后它对我有用,但如果你的图像太大,我会从那里开始。

    【讨论】:

    • 非常感谢!不过我确实试过了,我猜图像太大了。但是我后来使用 formData 让它工作。再次感谢!
    猜你喜欢
    • 1970-01-01
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 2014-04-16
    • 1970-01-01
    • 2019-01-13
    相关资源
    最近更新 更多