Azure OCR for image captured by mobile camera

Chetan Bawankule 1 Reputation point
2021-04-14T12:41:52.353+00:00

I am trying to perform OCR on image captured on mobile camera, I can perform it with url but I want to do it with local image.

const ocr = async(imageurl) => {
var axios = require('axios');
var data = JSON.stringify({
"url": 'http://jeroen.github.io/images/testocr.png'
});

//console.log(data);
var config = {
method: 'post',
url: 'my endpoint',
headers: {
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': 'my key'
},
data : data
};

await axios(config)
.then(function (response) {
console.log("this is what we get ",JSON.stringify(response.data));
})
.catch(function (error) {
console.log("there is error ",error);
});
}

I want to know how to pass local file as data.

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,094 questions
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 53,866 Reputation points
    2021-04-15T08:17:25.433+00:00

    Thanks for the details. This can be done with addling camera logic. I can give you two sample for IOS/ Android/ Windows.

    1. OCR on iOS with Workflow and Cognitive Services
      https://www.taygan.co/blog/2018/07/23/ocr-on-ios-with-workflow-and-cognitive-services
      88163-image.png
      1. Performing OCR for iOS, Android, and Windows with Microsoft Cognitive Services
        https://devblogs.microsoft.com/xamarin/performing-ocr-for-ios-android-and-windows-with-microsoft-cognitive-services/
      // Bring these namespaces in at the top of the class
      using Plugin.Media;
      using Plugin.Media.Abstractions;
      ...
      await CrossMedia.Current.Initialize(); MediaFile photo;
      if (CrossMedia.Current.IsCameraAvailable)
      {
      photo = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
      {
      Directory = "Invoices",
      Name="Invoice.jpg"
      });
      }
      else
      {
      photo = await CrossMedia.Current.PickPhotoAsync();
      }

    Regards,
    Yutong


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.