【问题标题】:convert image to binary data . How can i do?将图像转换为二进制数据。我能怎么做?
【发布时间】:2019-06-16 04:01:29
【问题描述】:

我在从 ionic 应用程序发送二进制数据时遇到问题。 该应用程序以 base64 格式从相机捕获照片,她必须将其以二进制数据格式发送到 API 服务器。 我必须将图像发送到 azure 认知服务以进行图像识别。

这是我的捕获功能:

公共 takeFoto(){

const options: CameraOptions = {
  quality: 100,
  destinationType: this.camera.DestinationType.DATA_URL,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE,
  correctOrientation:true,
  saveToPhotoAlbum: true
}

this.camera.getPicture(options).then((imageData) => {

 this.myPhoto = 'data:image/jpeg;base64,' + imageData;
 this.imgData = imageData;

}, (err) => {
 // Handle error

});



}

这是我的帖子功能:

    classifica(){


this.crudService.postAzureApi( /*binary data*/ '','https://northeurope.api.cognitive.microsoft.com/vision/v2.0/tag').then((result)=>{

        console.log(result);
        this.resultPost = result;

},(err)=> {

                        console.log(err);
                     this.resultPost = err;

});

}

标题是:内容类型:application/octet-stream 和 apikey

【问题讨论】:

标签: javascript angular typescript ionic-framework binary


【解决方案1】:

您可以转换为字节数组。有工具可以做到这一点。例如bin2c

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-26
  • 1970-01-01
  • 1970-01-01
  • 2017-02-04
  • 2017-08-05
相关资源
最近更新 更多