I shared this picture on Twitter of a little demo that I was writing for a talk where the PC (via the web cam) was reading a page of text;
and I got asked to share the source so I’m doing that here although the source is a little bit ‘rough and ready’.
I then looked up my old posts and realised that the code here is just an evolution of the code from this post so I won’t add too much here. Essentially, the way it works is something like;
- MainPage.xaml UI displays a CaptureElement, a Canvas and a TextBlock.
- The code behind MainPage.xaml.cs does;
- Creates a class I wrote called CameraPreviewManager which takes a reference to the CaptureElement and a filter to be applied to find the ‘best’ camera and then starts the previewing of video to the CaptureElement.
- Creates a class I wrote called OcrDetectionFrameProcessor which essentially runs a loop on a separate thread to pull preview frames from the camera, process them by using the OCR engine to gather some results and then fires a FrameProcessed event.
- Handles the FrameProcessed on the UI thread to draw the results to the screen as shown above.
- That’s pretty much it – code’s here for download, it’s a bit hacky so caveat emptor as usual
Thx, I may give this a try in an app I’m writing that could help read in part numbers off manufacture tags…I’ll take a close look later when I’m at an actual computer, but did you write your own ocr stuff or is that a separate library you reference that does the actual ocr work?
Hi,
It’s really “neither” – the Windows 10 UWP platform has an OCR Engine built into it which I’m using here, it’s a fairly simple API where you feed it an image and it comes back with a set of results as to where it sees text in that image and what the text is.
Mike.
Awesome…I love easy to use simple to impliment stuff. Thx for your post. 🙂
Hmm. With this in mind, I may revisit an app I did a while ago called Picturl which used the camera to detect urls and show thumbnails of the website on screen before allowing the user to press the thumbnail to visit it. In fact I ended up using tiny WebViews rather than thumbnails as that ended up being easier.. http://www.manchesterdeveloper.com/blog/post/LeedsHack-2015-Picturl