// Update is called once per frame private void Update() { if (Time.frameCount % FrameInterval == 0) { //Initialize if (Service == null) { Service = UWPBridgeService.GetService <IOcrService>(); Service.OnRecognized = SetString; } //Perform optical character recognition Service.Recognize(); } }
/// <summary> /// Prepare the device to perform optical character recognition and initialize the <see cref="OcrService" />. /// </summary> public static async Task InitializeOcrServiceAsync(SetMediaCaptureObjectAsync action) { //Get camera device of HoloLens. var deviceInformationCollection = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); var deviceInformation = deviceInformationCollection[0]; var captureElementSource = new MediaCapture(); await captureElementSource.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = deviceInformation.Id }); await action(captureElementSource); UWPBridgeService.AddService <CameraScript.IOcrService>(new OcrService(captureElementSource)); }