Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Using Microsoft OCR Library with JS/jQuery in VS 2013

I am currently working on a windows 8.1 application and I am using web languages and mostly jQuery (Cordova type project) as it might be used on other platforms. I need to use the Microsoft OCR Library (not Tesseract or any other ones, I know them but I really need to use this one for now) in order to analyze image and use the extracted text in my application.

I downloaded the JavaScript sample app from MSDN and I launched it : it is fully working (after installing the OCR plugin in VS 2013 of course).

I am now trying to integrate the OCR engine in my application (I installed the OCR plugin in my project too) but it is not working at all. In fact, when I try to launch my app on my machine, the execution fails and returns me this error message :

Unmanagable exception on line 11, column 5 in ms-appx://io.cordova.blankcordovaapp2/www/scripts/myscript.js

0x800a1391 - JavaScript execution error : « WindowsPreview » is undefined"

Here is the "buggy" portion of code (it is at the very beginning of my script) :

$(document).ready(function () {

"use strict";

// Keep objects in-scope across the lifetime of the scenario.
var FileToken = "";

// Define namespace and API aliases.
var FutureAccess = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList;

// Should be initialising the OCR engine
var OCR = WindowsPreview.Media.Ocr;
var ocrEngine = new OCR.OcrEngine(OCR.OcrLanguage.french);
document.addEventListener("deviceready", onDeviceReady, false);

I tried to initialize the OCR engine the same way as it is done in the microsoft OCR sample. VS seems not to find WindowsPreview.Media.Ocr which should be, according to the official documentation :

The Microsoft OCR Library for Windows Runtime contains the WindowsPreview.Media.Ocr namespace. The library is distributed as a NuGet package - it is not included in the Windows Software Development Kit (SDK).

I did install the plugin in the project using the NuGet command line so I don't know why it isn't identified and can't be initialized.

Thanks in advance for your help and don't hesitate to ask for further detail if I wasn't clear enough.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This look like a VS Tools for Apache Cordova (TACO) issue.
As a workaround you can open platforms\windows\CordovaApp.sln, switch architecture to x64, add Nuget package to the CordovaApp.Windows project references, save (build will fail because of an issue in the PreBuild event:

<PreBuildEvent>
    cd /d $(MSBuildThisFileDirectory)
    node -e "require('C:\\Users\\{username}\\AppData\\Roaming\\npm\\node_modules\\vs-tac\\lib\\hooks.js').updateAppxManifest('C:\\ocrTest\\ocrTest\\platforms\\windows','C:\\ocrTest\\ocrTest\\platforms\\windows\\..\\..\\')"
</PreBuildEvent>

you can also try to temporarily clear it out to enable builds of the underlying projects).

Then open the parent Cordova project - it should work now.

This will work only for one architecture though so for ARM and Windows Phone you may need another copy (set CordovaApp.Phone as startup project, add Nuget package to it and switch to ARM).

Note: I was testing this on VS 2015 & Cordova Tools upd.1.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!