Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 错误请求400将图像作为base64或blob发送到MS Face Api,角度7_Javascript_Angular_Api_Face - Fatal编程技术网

Javascript 错误请求400将图像作为base64或blob发送到MS Face Api,角度7

Javascript 错误请求400将图像作为base64或blob发送到MS Face Api,角度7,javascript,angular,api,face,Javascript,Angular,Api,Face,我试图将我的图像base64编码或作为Blob或bufferArray发送到我的Microsoft Face Api,以了解我的年龄。Im总是收到错误请求400错误:图像太小或图像格式无效。在用我的网络摄像头拍照后,我使用ngx网络摄像头生成我的图像base64 我知道我可以将其作为URL发送,首先上载图像,然后发送正确的URL,但我想尝试将图像作为二进制数据发送到本地存储中 我已尝试将我的图像数据发送到base64:9j/4AAQSKZJRGABAQAAAQABAD…V5LjZGO/vU70e

我试图将我的图像base64编码或作为Blob或bufferArray发送到我的Microsoft Face Api,以了解我的年龄。Im总是收到错误请求400错误:图像太小或图像格式无效。在用我的网络摄像头拍照后,我使用ngx网络摄像头生成我的图像base64

我知道我可以将其作为URL发送,首先上载图像,然后发送正确的URL,但我想尝试将图像作为二进制数据发送到本地存储中

我已尝试将我的图像数据发送到base64:9j/4AAQSKZJRGABAQAAAQABAD…V5LjZGO/vU70eVWYKZCynsT6ihzRj5ONxb7QqMp4Z8n9H/9k=

并作为图像数据url:data:image/jpeg;base64,/9j/4AAQSKZJRGABAQAAAQABAD…V5LjZGO/VU70EVWYKZynst6IHZRJ5ONXB7QQMP4Z8N9H/9k=

作为一个Blob:Uint8Array(58373)[255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 219, 0, 67, 0, 3, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3, 3, 3, 4, 6, 4, 4, 4, 4, 4, 8, 6, 6, 5, 6, 9, 8, 10, 10, 9, 8, 9, 9, 10, 12, 15, 12, 10, 11, 14, 11, 9, 9, 13, 17, 13, 14, 15, 16, 16, 17, 16, 10, 12, 18, 19, 18, 16, 19, 15, 16, 16, 16, 255, 219, 0, 67, 1, 3, 3, 3, 4, 3,4,…]

但任何一个都有成功的回应

App.component.ts (我的ngx网络摄像头库帮助我从网络摄像头生成一个图像作为base64或数据url:我存储图像数据的变量是“webcamImage”)

data.service.ts
在不使用url image alternative的情况下,要将图像正确发送到MS Face Api,正确的图像格式是什么。

对此有任何答案吗?我有相同的问题,但我使用不同的Api有任何答案吗?我有相同的问题,但我使用不同的Api
/* I will not write the functions that helps ngx webcam do with it function,
*/

/* this function is in where I send my variable with the image data as base64
*/

getPersonAge( ){

    this.data.getPersonAge(this.webcamImage.imageasBase64).subscribe((data: 
       string) =>{
      this.persona = data;
      console.log(this.persona);
    })
  }
constructor(public http: HttpClient){    }

 public url =  
'https://eastus2.api.cognitive.microsoft.com/face/v1.0/detect? 
 returnFaceAttributes=age,gender';

getPersonAge(imageUrl : any){

    const httpOptions = {
        headers: new HttpHeaders({
          'Content-Type':  'application/octet-stream',
          'Ocp-Apim-Subscription-Key':'xxxxxxxxxxxx',
           'processData': 'false'
        }) }


      return this.http.post(this.url,{ data:imageUrl}, httpOptions)


 }