Detecting text in an image on the web in real-time

The Shape Detection API is still in development, and neither the FaceDetection nor the Barcode Detection API’s are available outside experimentations (you need to enable “Experimental Web Platform features” in chrome://flags) but it is a very exciting space to watch and see another platform capability being opened up to developers and users on the web.

The latest addition is the Text Detection API that will take an image and scan it for readable text. The video at the top of this article is a great example (note, I stole some of the code from Miguel but put my own spin on it, notably the synthesis part.)

The model is exactly the same as the Face and Barcode Detection APIs, you get an image (either an img, canvas or ImgData object) and pass it into a instance of the type of detector you want to use. You can the process the results and perform some action on the data (for example draw on the image where the item was detect). In this case the results are an Array of DetectedText which you can use to extract what text was detected.

This currently works only on Chrome Canary for Android, but if you want to experiment check out the code and the demo and the process is not too painful although my code is incredibly hacky. I quite like this demo, it detects text in the image, draws a box around the text and then when the user clicks inside the bounding box, it will read the text back to the user.

The API is not amazingly complex. If you wanted to implement something yourself you can follow these steps:

1. Get access to the camera

Query the list of mediaDevices and select the first camera that is front-facing (note: there are better ways to do this).

  .then((devices) => {
    let thedevice;
    for(let device of devices) {
      if (device.kind == 'videoinput') {
        thedevice = navigator.mediaDevices.getUserMedia({
          "video": {
            deviceId: {exact : device.deviceId},
            width: { max: 640 }
    return thedevice;

2. Capture a full resolution frame

capturer = new ImageCapture(theStream.getVideoTracks()[0]);
capturer.grabFrame().then(frame => {  /* */  })

3. Create a TextDetector and start detection

var textDetector = new TextDetector();
return textDetector.detect(frame).then(boundingBoxes => { /* */ })

4. Process the results

For each item that is detected and element will appear in the array that is passed to the Promise returned from the detect function. You can then itterate over this array, find where they are positioned in the image, and get access to the data detected.

for(let box of boundingBoxes) {
  // box.boudingBox => DOMRect
  speechSynthesis.speak(new SpeechSynthesisUtterance(box.rawValue));

Yup, I am excited!

This API opens up so many interesting possibilities for users such as easier and broader access to assistive technologies for parsing content in images; Real-time translation of text in images are just a few examples that quickly spring to mind.

Originally Posted at https://paul.kinlan.me/detecting-text-in-an-image/



HTML SSI – The forgotten awesomeness!!

Server Side Includes or SSI is an age old simple interpreted server-side scripting language used almost exclusively for the web. It basically consists a set of directives that are inserted in an HTML page which are evaluated on the server when the page is being served. Simply put it allows for more modular and dynamic HTML. The most important use of SSI is however for creating prototypes without using languages like PHP for including files etc and again to keep things modular.

As an interactive developer many times we are given VD’s (visual designs) in Photoshop which need to be converted into static HTML templates that can be integrated with the Server side scripting logic. In most cases we have the assets i.e. the CSS, Images and JS  files arranged in a modular fashion for better understanding. But what about the modules used inside the HTML like header, main menu , sidebar or footers. They are merely copy pasted from one HTML to another.  Well that’s not modular !!. So here is what you need to do.

The Apache set up:

1. Stop your apache server if it is running.

2. Open the apache httpd.config file and locate the following lines

AddType text/html .shtml

AddOutputFilter INCLUDES .shtml
Once located insert the following on a new line
Options +Includes

just after the line “AddOutputFilter INCLUDES .shtml”
(This tells Apache that you want to permit files to be parsed for SSI directives.)

3.  Next we would like to add some legacy support for directives if the apache instance has been updated recently.

Add the following lines inside a Directory tag in the httpd.config file.

    <IfModule include_module>
          SSILegacyExprParser on

4. Restart your apache server.

Using Grunt:

Finally if you have to dispatch the work you have done for code review or html validation or to a client who hasn’t set up apache you can use the grunt task defined in the project folder to  create a distribution folder containing the compiled .shtml file into pure well formed .html pages with all the includes appearing as inline HTML.

For more info on SSI and the various directives that exist please visit the following links:

Apache Tutorial: Introduction to Server Side Includes – Apache HTTP Server

Server Side Includes – Wikipedia, the free encyclopedia


WordPress’s amazing facts and stats infographic

WordPress most amazing facts and stats infographic – The phenomenal growth of WordPress as the world’s best CMS

The image gives the most amazing facts and stats infographics, this explains why and how WordPress became one of the favorite blog and CMS platform. From blogs to Corporate websites, WordPress is used extensively in the web space.

Also, below are some more amazing stats on WordPress –

– 14.7%  of the top 1 million websites in the world are now powered by WordPress (one year ago it was 8.5% only)
– 1 in every 5 new domains created in US are running on WordPress (for new sites its easy to get started with WordPress – design, functionality and cost wise)
– 500 Thousand downloads in the first 48hrs of the 3.2 release (its not only how big the community is but almost everybody is active as well)
– 200 Million plugin downloads (how actively and beautifuly the community is contributing – proven by the use of the plugins)
– 92% of wordpress users now use it as a CMS (most important stats as per my understanding as I have noticed over years many a people using wordpress without harnessing any of its powers which is a shame)
– WordPress Maintains a zen like process of core development allowing it to be adaptive, flexible and open to extension (why we all love wordpress – its the only platform which is flexible and well documented for us to mould and develop further upon to make it even more stronger and beautiful as per the reuqirement of individual projects)


Cross-Browser Testing Tools

The chart below shows the basic features offered by these cross-browser testing services and applications, making it quick and easy to compare.

Tool Number of browser versions supported IE? Interactive testing? Side-by-side testing? Pricing
Adobe BrowserLab 13 IE6+ No Yes Free
Browsershots 60+ IE6+ No No Free
SuperPreview Varies IE6+ Yes Yes Free
Lunascape 3 IE6+ Yes Yes Free
IETester 6 versions of IE IE5.5+ Yes Yes Free
IE NetRenderer 5 versions of IE IE5.5+ No No Free
Spoon 16+ no IE Yes No Free
Browsera 9 IE6+ No Yes Free – $99/month
Browserling 9 IE5.5+ No No Free – $20/month
Mogotest 7+ IE6+ No Yes $15 – $4,499/month
Cloud Testing 4+ IE6+ Yes Yes Not specified
BrowserCam 90+ IE5.2+ No Yes $19.95 – $89.95/month
Multi-Browser Viewer 80+ IE6+ For some browsers Yes $139.95
CrossBrowserTesting 100+ IE6+ Yes Yes $29.95 – $199.95/month

Source: smashingmagazine.com