title: Capture camera live frame for OCR in Xamarin forms
body: <p>I am implementing OCR in xamarin forms. I am using <a href="https://github.com/halkar/Tesseract.Xamarin" rel="nofollow noreferrer">TesseractApi</a> following <a href="https://shamsutdinov.net/2015/07/01/tesseract-orc-xamarin-part-1/" rel="nofollow noreferrer">Tesseract OCR for Xamarin (part 1)</a>, <a href="https://github.com/ThatCSharpGuy/xocr" rel="nofollow noreferrer">xocr</a> and <a href="https://github.com/jamesmontemagno/MediaPlugin" rel="nofollow noreferrer">MediaPlugin</a>. The implementation is straightforward from saved/captured image, but I am looking is to perform OCR from the frames not from the saved pic.</p>
  
  <pre><code>private async void Button_Clicked(object sender, EventArgs e)
          {
              if (
                  !CrossMedia.Current.IsPickPhotoSupported)
              {
                  await DisplayAlert("No Upload", "Picking photo is not supported!", "OK");
                  return;
              }
  
              if (!_tesseractApi.Initialized)
                  await _tesseractApi.Init("eng");
  
              var photo = await TakePic(); //capture picture
             if (photo != null)
              {
  
                  var tessResult = await _tesseractApi.SetImage(photo);
  
                  if (tessResult)
                  {
                      recognizedTextLabel.Text = _tesseractApi.Text;
                  }
              }
          }
  
  private async Task&lt;Stream&gt; TakePic()
          { 
              var file = await CrossMedia.Current.PickPhotoAsync();
  
              if (file != null)
              {
                  //show stream in image - this is for test only
                  img.Source = ImageSource.FromStream(() =&gt;
                  {
                      return file.GetStream();
                  });
                  //return stream for ocr reading
                  return file.GetStream();
              }
              return null;
          }
  </code></pre>