- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试向 Microsoft 认知服务面部 API 传递用户上传的图像。该图像可在服务器上的上传文件夹中找到。
Microsoft 期望镜像为“application/octet-stream”并作为二进制数据传递。
我目前无法找到一种方法将图像传递到 API,使其能够令人满意地被接受并不断收到“解码错误,图像格式不受支持”。据我所知,图像必须以 blob 或文件格式上传,但对于 NodeJs 来说,我真的不确定如何实现这一点。
到目前为止,我已经有了这个,并且看了一些选项,但没有一个起作用,我尝试的其他选项返回了类似的错误,例如“文件太小或太大”,但是当我通过 Postman 手动测试相同的图像时,它工作正常。
image.mv('./uploads/' + req.files.image.name , function(err) {
if (err)
return res.status(500).send(err);
});
var encodedImage = new Buffer(req.files.image.data, 'binary').toString('hex');
let addAPersonFace = cognitive.addAPersonFace(personGroupId, personId, encodedImage);
addAPersonFace.then(function(data) {
res.render('pages/persons/face', { data: data, personGroupId : req.params.persongroupid, personId : req.params.personid} );
})
最佳答案
您正在使用的软件包,cognitive-services ,似乎不支持文件上传。您可以选择在 GitHub page 上提出问题.
不过,如果可以的话,确实存在替代的 NPM 软件包。与project-oxford ,您将执行如下操作:
var oxford = require('project-oxford'),
client = new oxford.Client(YOUR_FACE_API_KEY),
uuid = require('uuid');
var personGroupId = uuid.v4();
var personGroupName = 'my-person-group-name';
var personName = 'my-person-name';
var facePath = './images/face.jpg';
// Skip the person-group creation if you already have one
console.log(JSON.stringify({personGroupId: personGroupId}));
client.face.personGroup.create(personGroupId, personGroupName, '')
.then(function(createPersonGroupResponse) {
// Skip the person creation if you already have one
client.face.person.create(personGroupId, personName)
.then(function(createPersonResponse) {
console.log(JSON.stringify(createPersonResponse))
personId = createPersonResponse.personId;
// Associate an image to the person
client.face.person.addFace(personGroupId, personId, {path: facePath})
.then(function (addFaceResponse) {
console.log(JSON.stringify(addFaceResponse));
})
})
});
关于node.js - 使用 Node 将图像作为二进制数据上传到认知服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46025649/
使用 Cognito 的 forgotPassword 函数时,如果我尝试运行忘记密码方法超过 5 次,我会收到“LimitExceededException”错误。 此时是否有关于此的进一步文档?
我正在尝试向 Azure 的认知文本分析提供一些简单的、Hello-Worldish 的 JSON 示例;使用此测试数据: { "documents": [ { "lan
我正在尝试向 Azure 的认知文本分析提供一些简单的、Hello-Worldish 的 JSON 示例;使用此测试数据: { "documents": [ { "lan
我无法获得我的 CognitoIdentity 的凭据。当用户通过身份验证成功后,他需要获得一个身份才能访问其他 AWS 服务。在我的例子中就是 AWS IoT。但不知何故,我无法获得任何凭证。 这是
我正在使用 aws lambdas、dynamodb 和 cognito 构建身份验证系统。 我一直在比较 getOpenIdTokenForDeveloperIdentity() 提供的 token
我在 Cognito 中单击了“重置密码”,现在登录时出现“PasswordResetRequiredException”,我该如何处理?我在文档中找不到任何内容告诉我应该怎么做? 最佳答案 检查这个
我正在使用 Azure 认知服务,更准确地说是“bing 图像搜索服务”。我发送请求以获取与特定关键字相关的图像。 为此,我向正确的 Azure 端点发出 HTTP REST 请求: 'https:/
我正在使用 Azure 认知服务,更准确地说是“bing 图像搜索服务”。我发送请求以获取与特定关键字相关的图像。 为此,我向正确的 Azure 端点发出 HTTP REST 请求: 'https:/
如果用户登录,我会检查用户是否有 IoT 所需的策略,如果没有,我会附加它。 如果我是第一次登录,这很好用。 现在,当我注销并尝试使用不同的用户登录时,由于某种原因缺少凭据,当我刷新页面时,它再次工作
我将使用 Express 制作的 API 与 API Gateway 封装在一起。我正在使用 Cognito Userpool 来验证 API Gateway。 当我使用 Angular2 http
目前,每次重新启动应用程序时,用户都必须登录。我希望应用程序能够记住用户,直到他们手动注销。以下是我认为可行的方法,但它只是完全绕过了登录 Activity 。 @Override protected
想知道,如何识别图像是否包含特定对象并且该对象完全可见(而不是部分可见)。 Cognitive Services Computer Vision API提供了一组标签和我发送的图像的描述,但是,没有信
用例如下 我们的系统中有面孔列表 用户将上传一张图片 我们希望显示与上传图像匹配的面孔列表,例如置信度 >0.8 现在查看how to ,我的理解如下 使用人脸检测API,我们需要首先上传所有图像,包
用例如下 我们的系统中有面孔列表 用户将上传一张图片 我们希望显示与上传图像匹配的面孔列表,例如置信度 >0.8 现在查看how to ,我的理解如下 使用人脸检测API,我们需要首先上传所有图像,包
上下文 我使用 booth Cognito 用户池和 Cognito 身份池来登录用户。 我想完成一个简单的任务,让用户在 iOS 应用程序(Swift 应用程序)上登录。 我的应用程序基于自定义版本
我在捕获 Cognito 注册错误时遇到困难。当 Cognito 返回“UsernameExistsException”、“message”:“User already exists”错误时,我试图提
我正在试验 Cognito,当我认为它开始没问题时,我遇到了 (Google) token 在 1 小时后过期的问题。 当我开始使用干净的设备时,我可以注册并使用该应用程序 1 小时,然后当我需要刷新
我正在使用 AWS Cognito ( http://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-us
是否有办法防止云形成更新删除或重新创建 Cognito 用户池资源?我想消除这种情况发生的可能性。有办法吗? 最佳答案 我找到了答案。使用删除策略。适用于任何 Cloud Formation 资源:
我正在调用 Azure 认知 API 进行 OCR 文本识别,并且同时传递 10 个图像(因为下面的代码一次只接受一个图像 - 即 10 个独立的请求并行),从处理的角度来看,这对我来说效率不高,因为
我是一名优秀的程序员,十分优秀!