title: Tesseract OCR with C# regular expressions
body: <p>I use C# with Tesseract Library for recognition temperature value from webcam, that get video stream from Infrared Thermal Imager Screen. I use Tesseract parameter <code>tessedit_char_whitelist</code> and get not bad result, but it's would be improved.</p>
  <p>Is it possible to use something like Reg Expression in Tesseract?</p>
  <p>In my case, the first digit is always 3 or 4. Then any digit, the separator of the integer and fractional parts &quot;.&quot; and any number. There are only 4 signs to recognize. The color and size of the characters does not change.  However, the background may change and highlight the numbers if a warm object hits the place where the numbers are displayed.</p>
  <pre class="lang-cs prettyprint-override"><code>Tesseract.Rect rCurr = new Tesseract.Rect(x1, y1, w1, h1);
  Tesseract.Rect rMax = new Tesseract.Rect(x2, y2, w2, h2);
  
  using (var ocr = new TesseractEngine(@&quot;./tessdata&quot;, &quot;eng&quot;, EngineMode.TesseractOnly))
  {
      ocr.SetVariable(&quot;tessedit_char_whitelist&quot;, &quot;0123456789.&quot;);
      //ocr.SetVariable(&quot;editor_image_text_color&quot;, &quot;white&quot;);
  
      Bitmap bitMapInput = _imageInput.ToBitmap(); 
      Bitmap bitMapOutput = _imageOutput.ToBitmap();
  
      var imgIn = PixConverter.ToPix(bitMapInput); 
      var imgOut = PixConverter.ToPix(bitMapOutput);
  
      using (var page = ocr.Process(imgIn, rCurr, PageSegMode.SparseText))
      {
          SetTextBoxCurrent(&quot;Текущ: &quot; + page.GetText());
      }
  
      using (var page2 = ocr.Process(imgOut, rMax, PageSegMode.SparseText))
      {
          SetTextBoxMax(&quot;Макс: &quot; + page2.GetText());
      }
  }
  </code></pre>
  <p>Result of OCR1:</p>
  <p><a href="https://i.stack.imgur.com/EauaW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EauaW.png" alt="" /></a></p>
  <p>Result of OCR2:</p>
  <p><a href="https://i.stack.imgur.com/C7dxY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C7dxY.png" alt="" /></a></p>