<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Femi Oladeji on Medium]]></title>
        <description><![CDATA[Stories by Femi Oladeji on Medium]]></description>
        <link>https://medium.com/@femidotexe?source=rss-97651ab69b4b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*sqDFOQPGQLROIRbs.</url>
            <title>Stories by Femi Oladeji on Medium</title>
            <link>https://medium.com/@femidotexe?source=rss-97651ab69b4b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 21:13:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@femidotexe/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tracking AWS Lambda Functions error via Slack]]></title>
            <link>https://medium.com/@femidotexe/tracking-aws-lambda-functions-error-via-slack-2e9f0733e043?source=rss-97651ab69b4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e9f0733e043</guid>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[lambda-function]]></category>
            <dc:creator><![CDATA[Femi Oladeji]]></dc:creator>
            <pubDate>Sat, 20 Apr 2019 08:04:42 GMT</pubDate>
            <atom:updated>2019-04-20T08:04:42.351Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pLICYdJvw7FrISkGUVNZZg.jpeg" /></figure><p>I’ve been working with AWS Lambda functions for over a year now and it’s been an awesome experience so far. I want to share my experience about how I get notified on slack whenever there’s an error.</p><p><strong>What is Lambda Function?</strong></p><p>Before we go into the nitty-gritty, let’s understand what lambda functions are. <a href="https://aws.amazon.com/lambda/">AWS Lambda functions</a> support serverless computing by allowing you to write code that runs in response to certain events. With lambda functions, you don’t need to worry about having a server that persistently listens for requests. All you need is to define triggers. For example, a lambda function can be connected to AWS API gateway so that when a request is made to the endpoint, the lambda function gets executed. You only get charged based on the number of seconds it takes for the function to run.</p><p><strong>Why error tracking?</strong></p><p>It’s possible your infrastructure heavily relies on lambda functions and you may have a lot of them invoking one another at several points in time. It can be very difficult knowing when there’s an error in one of those functions or when a function is timing out thereby affecting the whole system. Having an automated error detection that notifies you on slack can be a quick and easy way to ensure that your application is available and effective almost every time.</p><p><strong>Let’s get started</strong></p><p>It’s time to get cracking. Let’s assume I have a lambda function that helps me with rounding numbers to a specific number of decimal places and I want to know whenever something is wrong with it. Login to your AWS account, go to the lambda function section and create a lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CnpAIEeo2uovMs6BcSwTiw.png" /></figure><p>Enter your desired function name then select Node.Js 8.10 as runtime. Expand the permission section, select create a role with basic permission and click on create function. A text editor interface will be launched to write the function body. You can also choose to upload a zipped file if the lambda function is huge. Since we’re doing something small, let’s just stick to the interface. Paste the code below in the editor</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34de86ea0326cb290a300e091de3551b/href">https://medium.com/media/34de86ea0326cb290a300e091de3551b/href</a></iframe><p>The <em>exports.handler</em> function is what gets called when the lambda function is invoked. The lambda function expects the post payload to have number and places properties, <em>roundNumber</em> function performs the actual approximation operation and the response is the object that gets returned to show the result. An error is thrown if any or both values posted is not a number. This was done intentionally to simulate how to know when an uncaught error happens in your lambda functions from slack.</p><p>In order to test what we’ve done so far, we can use the test menu at the top right corner of the page. You’ll have to create a new test event like this { “body”: “{\”number\”:4.87976,\”places\”:3}” }. Click on create and then hit the test button. You should see the result of the operation.</p><p>However, we want users to be able to use this by just making an API call to an endpoint. In order to do this, we’ll have to set up our API gateway. <a href="https://aws.amazon.com/api-gateway/">AWS API gateway</a> is a service that makes it easy to set up REST and WebSocket APIs at any scale. Go to the API gateway section and click on <em>Get started</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SnRqR_yvAQjP7VOqZccQNA.jpeg" /></figure><p>Enter your preferred API name and make sure you check the REST and New API option. Once you’ve created the API, a new page will show up with a dropdown button captioned Actions. Select the add method option and choose the POST method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1vzbAlg-wQ9oPdK3ctmiOw.jpeg" /></figure><p>You need to make sure you check the use lambda proxy integration. It allows us to have full control of the request and response from the lambda function. You can check <a href="https://medium.com/@lakshmanLD/lambda-proxy-vs-lambda-integration-in-aws-api-gateway-3a9397af0e6d">this article</a> out for more insight. Choose the lamdba function we just created and click on save. Before we can use the API we need to deploy it. Click on the / just under resources then click on the action dropdown and select deploy option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*qz9q_25gETOMlGbm062t6g.png" /></figure><p>You’ll have to create a new stage to deploy the API. A confirmation page will be displayed with the API endpoint showing just at the top of the page. Copy the endpoint and make a valid post request to it from your API client app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*M1SDTEkVUHVDlF_BjUxOeA.png" /></figure><p>Now let’s get a little mischievous and change the number field to an invalid value, we get an internal server error. This is the type of error we want to be notified of whenever it happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*Iek2Bhzo9m7Nc1UhDgHDEw.png" /></figure><p>To set up the notification we’ll have to create an alarm. Before we go and ahead and create the alarm there are a couple of things we need to understand. The AWS alarm is just a way of setting some threshold value for certain events. Whenever the alarm state has transitioned to another state, we need to create an action that gets triggered. A typical action will send a notification to an amazon SNS (Simple notification service) topic. Let’s start with the topic creation. Go to SNS menu and click on topics to create a new topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*945ZEvjbFHXZmvRhmvZNog.png" /></figure><p>After creating the topic, we need to add a subscription to the topic. The subscription determines the resource that will receive the notification sent to the topic. SNS topic subscriptions can be delivered to some protocols e.g http(s), lambda, email, SMS etc. We’ll be using the lambda protocol and that requires us to create a new lambda function. Let’s call the new function reportErrors. The function will be responsible for posting any error notification to slack. We’ll leave the function implementation blank for now. Copy the ARN value and go back to the subscription page on SNS and create a new subscription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*lUic3DI-2gf429R6cmN3YA.png" /></figure><p>Now that we’ve set up the notification service, let’s go to cloudwatch section and click on alarm. Create a new alarm and click on the select metric button. Choose the lambda option. You can choose to select a metric that spans across all lambda functions or you can choose to track a particular lambda function. Let’s go with the later. Click on the option By function name and check the error option since that’s the only metric we want to track. You can change the period frequency by navigating to the graphed metric tab. I set this to 1 minute so that I can quickly get notified whenever an error occurs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcPrYc7fs-R2O_j3tYo8ZA.jpeg" /></figure><p>Hit the select metric button at the bottom right of the page. We then need to specify some parameters for the alarm. Enter your desired alarm name. Choose the threshold for the alarm. Let’s set it to when the error is greater than 0 for a single data point i.e basically whenever there’s at least an error within the last one minute. We also need to specify the action that will be fired when the state gets transitioned to the alarm state. Click on the drop down for send notification and choose the SNS topic we just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*v1vO60s0klIutIotHfjeCQ.png" /></figure><p>We need to modify the lambda function that the SNS topic is connected to so that we can post the notification to slack. Before we go ahead and do that, we have to make some preparations on slack starting with the creation of an incoming webhook. Go to <a href="https://api.slack.com/">https://api.slack.com/</a> and click on start building. Enter the app name and choose the slack workspace you are adding it to. Under the add features &amp; functionality section, click on incoming webhook option and toggle it on. Add new webhook to the workspace, choose the channel the notifications will be posted to and authorize the app.</p><p>The next step is to edit the reportErrors lambda function. Paste the code below in the code editor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/174f4d329452cfb7032f00b4aa72080c/href">https://medium.com/media/174f4d329452cfb7032f00b4aa72080c/href</a></iframe><p>The code uses the https module to make a post request to the slack incoming webhook. Let’s test this again. Make a post request to the roundNumber endpoint with valid data, just to confirm it’s still working. Make another request with invalid data. Wait for about one minute (provided the error period was set to 1 minute) and check the slack channel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*Qe-uFqZ0_aKghTy4BAxUMw.png" /></figure><p><strong>Summary</strong></p><p>I know we’ve touched a lot of things but let’s attempt a recap. We created a lambda function that is connected to an API endpoint through the AWS API gateway. Lots of people are making requests to the endpoint and we want to know whenever there’s an error so we created a cloudwatch alarm that posts notification to an SNS topic. The topic has a subscription that is connected to another lambda function. The lambda function takes the notification message and makes a post request to the slack incoming webhook and when we check the slack channel we can see that the message is there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e9f0733e043" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I developed Apple’s Screen time Chrome Extension]]></title>
            <link>https://medium.com/backticks-tildes/how-i-developed-apples-screen-time-chrome-extension-988e0c451894?source=rss-97651ab69b4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/988e0c451894</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Femi Oladeji]]></dc:creator>
            <pubDate>Tue, 27 Nov 2018 09:52:45 GMT</pubDate>
            <atom:updated>2018-12-17T16:17:09.068Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the features of iOS12 that I love is screen time. It gives me an idea of the apps I spend so much time on, and I can even set a time limit for the apps. I spend most of my time on my laptop and I sometimes find myself wandering away on twitter or getting carried away with youtube videos even when I have pending tasks to attend to. That motivated me to think of how I can track how much time I spend on popular social media sites and restrict access based on certain conditions in order to increase productivity.</p><p><strong>Set up the project</strong></p><p>I used <a href="https://vuejs.org/">vuejs</a> to develop a chrome extension that helps me keep track of time spent on several sites on my browsers, and put some control measures in place.</p><p>The first step is to install the <a href="https://cli.vuejs.org/">vue cli</a>. The cli makes it easy to set up all the necessary files you need to start coding.</p><pre>npm install -g @vue/cli<br>vue create screentime</pre><p>After all the modules have been successfully installed, create a manifest.json file. All extensions must have this file. It informs chrome browser all the basic information it needs to know about your extension.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2de1235256e342f64bf75badee27fd7/href">https://medium.com/media/b2de1235256e342f64bf75badee27fd7/href</a></iframe><p>The key fields to focus on are browser_action, background and permissions. The browser_action specifies the html to load when the extension icon is clicked. The background script specifies the javascript file that will continuously run in the background as long as chrome is opened. The permissions field is to explicitly request for resources that the extension will be using. The tabs permission allows us to know the currently active tab and also know when tabs are being switched.</p><p><strong>Background task</strong></p><p>The background task will have to listen to every update happening on tabs so that we can know when a url is being visited. The first thing we need to do is add an event listener for <a href="https://developer.chrome.com/extensions/tabs#event-onUpdated">tab updates</a>.</p><pre>chrome.tabs.onUpdated.addListener((tabId, changeDetails, tab) =&gt; {<br>  console.log(tab);<br>});</pre><p>To test out what we’ve done so far (still quite little right 😄), let’s package our extension and test it out in chrome. We need to build the vue files. To do that, run npm run build command from your terminal. A dist folder should be created. Copy the manifest.json file into the dist folder and copy the background.js file into a js folder in dist (this will be automated later). Open chrome browser and open the extensions page (chrome://extensions) click on the Load unpacked menu at the top left (make sure developer mode is toggled on) and select the dist folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*tcgafXd58A5io0iX0bzssw.png" /></figure><p>Click on the background page to view the console and then visit any site. Every time a response is received from the site, the details should be logged to the console.</p><p>Another thing we need to track is when tabs are being switched. If the tab is switched to a site we’re tracking then we need to mark the moment, and when a new tab is activated we need to mark that moment also in order to calculate how much time the user spent on the site that was switched away from. In order to achieve this, we need to add an onActivated event listener from the chrome tabs api. Add this snippet to the background.js file.</p><pre>chrome.tabs.onActivated.addListener(() =&gt; {<br>// query the active tab<br>  chrome.tabs.query({<br>    active: true,<br>    currentWindow: true<br>  }, activeTab =&gt; {<br>    // details of the tab<br>    console.log(activeTab);<br>  });<br>});</pre><p>Each time you switch tabs, the new active tab details are displayed on console.</p><p>Also, when the chrome browser is no longer in focus, we need to mark that moment and also know when it’s back in focus. The chrome.windows.onFocusChanged is the event we need to achieve that functionality.</p><pre>chrome.windows.onFocusChanged.addListener(window =&gt; {<br>  console.log(window);<br>});</pre><p>Each time the chrome browser loses focus, -1 is logged on the console. When it regains focus, the chrome browser window ID is logged.</p><p><strong>Track time spent</strong></p><p>It’s time to put all these events together and find a way to track the number of seconds spent on each site. To do that, we need to modify our background.js file and make it more robust.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf7dd0e3539d3c8985df9723d4bebda9/href">https://medium.com/media/bf7dd0e3539d3c8985df9723d4bebda9/href</a></iframe><p>The extension console should look like this each time you navigate through the four urls in background.js file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*fjpNeAauVngu2ciEvzedVQ.png" /></figure><p><strong>Storage</strong></p><p>The next thing that has to be done is to save how much time is spent on each site every day. The <a href="https://developer.chrome.com/extensions/storage">storage</a> permission will have to be added to the manifest.json file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c994bf21ddfe81919011a2921b1df99/href">https://medium.com/media/2c994bf21ddfe81919011a2921b1df99/href</a></iframe><p>Three new functions will be added to the background.js file. A function to retrieve data from chrome.storage.local, update the data and the third is to save.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/708b3a59b1a71934f54d2387d4d588fb/href">https://medium.com/media/708b3a59b1a71934f54d2387d4d588fb/href</a></iframe><p><strong>Show the chart</strong></p><p>The final step is to show the bar chart on chrome indicating how many seconds were used on each of the four sites. Ensure that the background.js and manifest.json files in your root directory are updated. The next thing is to install a <a href="https://vue-chartjs.org/">vue js chart</a> module so that we can better visualize the data.</p><pre>npm install vue-chartjs chart.js --save</pre><p>Create a chart.js file in the components directory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7499df1d2ba20eae50e17aaed0bab6ab/href">https://medium.com/media/7499df1d2ba20eae50e17aaed0bab6ab/href</a></iframe><p>The chart.js file reads from the chrome storage and constructs a horizontal bar chart. The chart.js file will now be imported in the HelloWorld.vue file essentially making the file this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31fa604a39d38eee6919c19e93aab4b7/href">https://medium.com/media/31fa604a39d38eee6919c19e93aab4b7/href</a></iframe><p><strong>Build Extension</strong></p><p>Let’s get the extension all fired up now. The build script in package.json file will have to be edited to support copying the manifest.json file and background.js file each time we build</p><pre>&quot;scripts&quot;: {<br>    &quot;serve&quot;: &quot;vue-cli-service serve&quot;,<br>    &quot;build&quot;: &quot;vue-cli-service build &amp;&amp; npm run move&quot;,<br>    &quot;move&quot;: &quot;cp manifest.json dist/manifest.json &amp;&amp; cp background.js dist/js/background.js&quot;<br>}</pre><p><em>The move command may be slightly different for windows users</em></p><p>Run the build command and load the dist folder in chrome extension. Try visiting the four sites hardcoded in the background.js file and then click on the extension icon to see the chart indicating how much time you’ve used on each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*hHYxzMy9_91GADpHDj-yOQ.png" /></figure><p>Full project can be found here <a href="https://github.com/femioladeji/screentime">https://github.com/femioladeji/screentime</a>. The full extension offers a feature where you can set the maximum number of minutes you want to spend on a site daily. Once you’ve gotten to the time limit, you’ll not be able to access the site again till the next day. You can install the packaged extension here <a href="https://chrome.google.com/webstore/detail/screentime/ofmanejijbcohgebmdfacglmhemiifca">https://chrome.google.com/webstore/detail/screentime/ofmanejijbcohgebmdfacglmhemiifca</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=988e0c451894" width="1" height="1" alt=""><hr><p><a href="https://medium.com/backticks-tildes/how-i-developed-apples-screen-time-chrome-extension-988e0c451894">How I developed Apple’s Screen time Chrome Extension</a> was originally published in <a href="https://medium.com/backticks-tildes">Backticks &amp; Tildes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing a License Plate Recognition System with Machine Learning in Python]]></title>
            <link>https://medium.com/devcenter/developing-a-license-plate-recognition-system-with-machine-learning-in-python-787833569ccd?source=rss-97651ab69b4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/787833569ccd</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Femi Oladeji]]></dc:creator>
            <pubDate>Thu, 03 Aug 2017 07:52:02 GMT</pubDate>
            <atom:updated>2018-12-17T16:11:53.581Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, I’ll be taking you through the basics of developing a vehicle license plate recognition system using the concepts of machine learning with Python.</p><p><strong>What exactly are we trying to do?</strong></p><p>License Plate Recognition Systems use the concept of optical character recognition to read the characters on a vehicle license plate. In other words, LPR takes the image of a vehicle as the input and outputs the characters written on its license plate. Can you imagine how invaluable this would be to your undercover/detective skills? You can pull off all the necessary details about a car from the license plate characters.</p><p><strong>What has Machine Learning got to do with this?</strong></p><p>I’m tempted to say everything but nah! that would be wrong. LPR systems can actually be developed without using machine learning. Other concepts like template matching, feature extraction etc. can be used. However, with machine learning, we can improve the system accuracy by improving the training process. We’re going to use machine learning for the character recognition aspect i.e map a character image to its actual character and differentiate between As, Bs etc.</p><p><strong>Is this tutorial really for me?</strong></p><p>If you’re thinking of building your own JARVIS with Morgan Freeman’s voice then yeah. Ok that’s an exaggeration. Essentially this tutorial just shows you how you apply image processing and machine learning towards solving a real life challenge. All you need to know is Python and some concepts in image processing and machine learning. I will do my best to explain those concepts but you can do further research to understand them.</p><p><strong>Let’s get started then…</strong></p><p>LPR sometimes called ALPR (Automatic License Plate Recognition) has 3 major stages.</p><ol><li>License Plate Detection: This is the first and probably the most important stage of the system. It is at this stage that the position of the license plate is determined. The input at this stage is an image of the vehicle and the output is the license plate.</li><li>Character Segmentation: It’s at this stage the characters on the license plate are mapped out and segmented into individual images.</li><li>Character Recognition: This is where we wrap things up. The characters earlier segmented are identified here. We’ll be using machine learning for this.</li></ol><p><strong>Enough of the theory, can we start coding?</strong></p><p>Sure, let’s prepare our environment. First thing we need to do is create a virtual environment. This makes it easy to manage our project dependencies and packages. You can use <a href="http://python-guide-pt-br.readthedocs.io/en/latest/dev/virtualenvs/">virtualenv</a> package to create a virtual environment.</p><pre># install virtualenv if you don’t have the package already<br>pip install virtualenv<br>mkdir license-plate-recognition<br>cd license-plate-recognition<br>virtualenv lpr<br>source lpr/bin/activate</pre><p>A folder with the name lpr should now be in your project directory.</p><p>Now, let’s install our first package <a href="http://scikit-image.org/">scikit-image</a>. It’s a Python package for image processing. To <a href="http://scikit-image.org/download.html">install</a> it, run.</p><pre>pip install scikit-image</pre><p>Some key dependencies of the package are <a href="https://docs.scipy.org/doc/scipy/reference/">scipy</a> (for some complex scientific calculations), <a href="https://docs.scipy.org/doc/numpy/">numpy</a> (for n-dimensional arrays manipulations) and <a href="http://matplotlib.org/contents.html">matplotlib</a> (for plotting graphs and displaying images). Another important package is <a href="https://pillow.readthedocs.io/en/4.2.x/">Pillow</a> — a python imaging library.</p><p><strong>License Plate Detection (Plate localization)</strong></p><p>This is the first stage and at the end of this stage, we should be able to identify the license plate’s position on the car. In order to do this, we need to read the <a href="https://github.com/andela-foladeji/License-Plate-Recognition-Nigerian-vehicles/blob/master/test_images/car6.jpg">image</a> and convert it to grayscale. In a grayscale image, each pixel is between 0 &amp; 255. We now need to convert it to a binary image in which a pixel is either complete black or white.</p><p><strong>Note: </strong>If you have issues using matplotlib on your mac-os, follow this <a href="http://chrome-extension//klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=osx%20-%20Installation%20Issue%20with%20matplotlib%20Python%20-%20Stack%20Overflow&amp;uri=https://stackoverflow.com/questions/21784641/installation-issue-with-matplotlib-python">instruction</a>.</p><p>The output of the code below will show two images, one in grayscale and the other in binary.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/437fd5236e606035d0e405c784f5a568/href">https://medium.com/media/437fd5236e606035d0e405c784f5a568/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09504b7fc6397ca1e97991e3c4d4d5a9/href">https://medium.com/media/09504b7fc6397ca1e97991e3c4d4d5a9/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Jz_MSXOlaYmUFJylqVB2Ow.png" /><figcaption>Gray scale and binary image</figcaption></figure><p>We need to identify all the connected regions in the image, using the concept of <a href="https://en.wikipedia.org/wiki/Connected-component_labeling">connected component analysis</a> (CCA). Other approaches like edge detection and morphological processing can also be explored. CCA basically helps us group and label connected regions on the foreground. A pixel is deemed to be connected to another if they both have the same value and are adjacent to each other.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b14e71ec75d26119655a1ba5a53c61c1/href">https://medium.com/media/b14e71ec75d26119655a1ba5a53c61c1/href</a></iframe><p>We had to import the previous file so that we can access the values we have there. The <a href="http://scikit-image.org/docs/dev/api/skimage.measure.html#label">measure.label</a> method was used to map all the connected regions in the binary image and label them. Calling the <a href="http://scikit-image.org/docs/dev/api/skimage.measure.html#regionprops">regionprops</a> method on the labelled image will return a list of all the regions as well as their properties like area, bounding box, label etc. We used the <a href="https://matplotlib.org/api/patches_api.html#matplotlib.patches.Rectangle">patches.Rectangle</a> method to draw a rectangle over all the mapped regions.</p><p>From the resulting image, we can see that other regions that do not contain the license plate are also mapped. In order to eliminate these, we will use some characteristics of a typical license plate to remove them.</p><ol><li>They are rectangular in shape.</li><li>The width is more than the height.</li><li>The proportion of the width of the license plate region to the full image ranges between 15% and 40%.</li><li>The proportion of the height of the license plate region to the full image is between 8% &amp; 20%.</li></ol><p>Don’t hesitate to tweak these characteristics if it doesn’t work for the shape of your license plate (the probability of that is low though).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/083aa01c11a4c3cf8cd4fb3910bcd977/href">https://medium.com/media/083aa01c11a4c3cf8cd4fb3910bcd977/href</a></iframe><p>From the revised version of the cca.py script, other regions that are likely not license plates are eliminated. However, it’s still possible that certain areas (headlamps, stickers etc) that look exactly like a license plate are also being marked. To eliminate those other regions, we’ll need to do a vertical projection. The concept is implemented by adding all the pixels in each column. It is assumed that the license plate area will have lots of pixel values due to the fact that characters are written on it.</p><p><strong>Character Segmentation</strong></p><p>This is the stage where we map out all the characters on the license plate. We’ll be using the concept of CCA here also.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e45533a0636cc97149d0215109483ee/href">https://medium.com/media/1e45533a0636cc97149d0215109483ee/href</a></iframe><p>The plate_like_objects is a list of all the regions on the car that look like a license plate. From the image I used, three regions were identified as candidates for a license plate. To save time, I hardcoded the index 2 because that’s the one with the license plate. The final code I’ll be sharing will contain a license plate validation technique to eradicate other regions that do not actually contain the license plate.</p><p>Then a CCA was done on the license plate and each character was resized to 20px by 20px. This was done because of the next stage that has to do with recognition of the character.</p><p>In order to keep track of the order of the characters, the column_list variable was introduced to take note of the starting x-axis of each region. This can then be sorted to know the correct order of the characters.</p><p><strong>Character Recognition</strong></p><p>This is going to be the last stage, it’s at this stage we introduce the concept of machine learning. <a href="http://nkonst.com/machine-learning-explained-simple-words/">Machine learning</a> can simply be defined as the branch of AI that deals with data and processes it to discover pattern that can be used for future predictions. The major categories of machine learning are supervised learning, unsupervised learning and reinforcement learning. <a href="http://machinelearningmastery.com/supervised-and-unsupervised-machine-learning-algorithms/">Supervised learning</a> makes use of a known dataset (called the training dataset) to make predictions. We’ll be taking the path of supervised learning because we already have an idea of how As, Bs and all the letters look like. Supervised learning can be divided into two categories; classification and regression. Character recognition belongs to the classification category.</p><p>All we need now is to get a training data set, choose a supervised learning classifier, train a model, test the model and see how accurate it is, then use the model for prediction.</p><p>Let’s start with training our model. I have two different <a href="https://github.com/andela-foladeji/License-Plate-Recognition-Nigerian-vehicles/tree/master/training_data">datasets</a>, one is 10px by 20px and the other is 20px by 20px. We’ll make use of the <a href="https://github.com/andela-foladeji/License-Plate-Recognition-Nigerian-vehicles/tree/master/training_data/train20X20">20px by 20px </a>because we’ve already resized each character to that size. Each letter except O and I (a typical Nigerian license plate doesn’t have these letters because of their resemblance with 0 and 1) has 10 different images.</p><p>There are several <a href="http://blog.echen.me/2011/04/27/choosing-a-machine-learning-classifier/">classifiers</a> we can use with each of them having its advantages and disadvantages. We’ll use SVC (support vector classifiers) for this task. I chose to use SVC because it gave me the best performance. However, this does not necessarily mean that SVC is the best classifier.</p><p>We’ll have to install the <a href="http://scikit-learn.org/stable/index.html">scikit-learn</a> package for this stage.</p><pre>pip install scikit-learn</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3831d124a7e4f3957a0cdb6dda5b12fa/href">https://medium.com/media/3831d124a7e4f3957a0cdb6dda5b12fa/href</a></iframe><p>In the gist above, each character in the training dataset was used to train the svc model. A 4-fold cross validation was also done to determine how accurate the model is and then the model was persisted to a file so that predictions can be done without training a model anymore.</p><p>Now that we have a trained model, we can attempt to predict the characters that we earlier segmented.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f659db4055d6a1a2c807e016c278e703/href">https://medium.com/media/f659db4055d6a1a2c807e016c278e703/href</a></iframe><p><strong>NOTE</strong></p><p>One of the most important things about the system is to ensure that the images used are clear. Also ensure that the size of the image is not too big, a width of 600px is good enough. If you have questions please drop it in the comments section. Thanks</p><p>The full app can be found on <a href="https://github.com/andela-foladeji/License-Plate-Recognition-Nigerian-vehicles">https://github.com/femioladeji/License-Plate-Recognition-Nigerian-vehicles</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=787833569ccd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devcenter/developing-a-license-plate-recognition-system-with-machine-learning-in-python-787833569ccd">Developing a License Plate Recognition System with Machine Learning in Python</a> was originally published in <a href="https://medium.com/devcenter">Devcenter Square Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Andela: 2 Days In]]></title>
            <link>https://medium.com/@femidotexe/andela-2-days-in-9ae48818eadd?source=rss-97651ab69b4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ae48818eadd</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[andela]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Femi Oladeji]]></dc:creator>
            <pubDate>Wed, 05 Oct 2016 22:00:17 GMT</pubDate>
            <atom:updated>2016-10-05T22:00:17.139Z</atom:updated>
            <content:encoded><![CDATA[<p>If someone told you to summarize the key takeaways you’ve gotten from your first two days at work you’ll probably wonder if you’ve gotten enough to summarize. It is a whole new ball game here,barely 48 hours in and I already have enough things to summarize.</p><p>Ok so where should I start from? The beginning right? One of the first few statements that struck a nerve within me was;</p><blockquote>“Andela is give and take”.</blockquote><p>It was an eye opener to the fact that this is a symbiotic relationship that both organisms need to benefit from.</p><p>Another punchline was learning != education and learning = identity. It was a wake up call to instill the consciousness that this is not the traditional form of education that I’m used to. Also, the things I learn shape who I become.</p><blockquote>I am limitless.</blockquote><p>Yes I am, I decide if there should be boundaries or to break any box that I’ve found myself in. It’s my responsibility to take charge and do what I need to do to become who I want to be.</p><p>Now I know that I must make conscious effort to learn and effectively apply the things I learn seamlessly and correctly on a daily basis to increase productivity.</p><p>My mind has now been programmed to believe that the stretching and straining will definitely come but in the end the process will be worth the result.</p><blockquote>If you always do what is easy, your life will be hard</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ae48818eadd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Dive Into Machine Learning]]></title>
            <link>https://medium.com/@femidotexe/my-dive-into-machine-learning-340cde9a2ecd?source=rss-97651ab69b4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/340cde9a2ecd</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[andela-bootcamp-nigeria]]></category>
            <category><![CDATA[andela]]></category>
            <dc:creator><![CDATA[Femi Oladeji]]></dc:creator>
            <pubDate>Wed, 17 Aug 2016 14:22:55 GMT</pubDate>
            <atom:updated>2016-08-18T08:09:14.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*zaRLGpP3bsZtm85yNnOBEQ.jpeg" /></figure><p>It all started few months ago, I saw a Ted Talk video on <a href="https://www.ted.com/talks/fei_fei_li_how_we_re_teaching_computers_to_understand_pictures?language=en">“Teaching computers to recognize images”</a>. It was a jaw dropping talk from Fei Fei Li and I was greatly inspired. I began to believe that I could transform my machine from a dumb one to an intelligent one (who wouldn’t want such super powers in this “Marvel” age).</p><p>My sleep was suddenly robbed from me, I just couldn’t take my mind off attempting something cool with machine learning but unfortunately I had no idea how to go about it but I knew I wasn’t going to let this go.</p><p>Therefore, I did what anybody would do in a 21st century; Google search; and I was amazed at the huge resources available on the subject. It was at that moment it felt as though the world had been revolving around me, but I was somehow stuck up in a corner and now I’ve got lots of grounds to cover.</p><p>After reading about all the basics of subject I decided it was time to build something cooooooool (time to flaunt my super power). This came at a time when Python (not snake) became my friend. My focus then shifted to machine learning in python and I stumbled on a wonderful package <a href="http://scikit-learn.org/">scikit-learn</a>. My goodness! It was like discovering a gold mine.</p><p>I finally came up with a project to attempt because I believe you can’t really say you’ve learned a thing until you’ve been able to apply it in your own unique way. The project was centered on recognizing the characters on a Nigerian license plate from images of a vehicle. After performing some image processing activities I got to the point where I needed to classify each character image to the right category and I discovered this was a classification problem under supervised learning.</p><p>I delved into the documentation of the sci-kit learn package and watched some video tutorials recorded during pycon 2015 and scipy 2015. I couldn’t wait to develop my own model and after rigorous research and learning for a couple of weeks I finally got what I wanted. Yaay! It was the best thing that happened that day. It was during the training of the model I learnt how important it is to have good training datasets.</p><blockquote>The quality of your result is as good as the quality of your training dataset</blockquote><p>After experimenting with my first machine learning model, I needed a model for the task of recognizing the characters on Nigerian license plates. In order to do this, I had to take snapshot of over 50 license plates and segmented the characters on them. I then labeled the image appropriately. The label is the character text. It took a while to get 10 samples for each characters and I had to synthesize for some rare ones like Z &amp; Q.</p><p>I now have a working machine learning model that can categorize license plate characters (now I know what having super power feels like).</p><p>It’s been a good experience so far and my feet are already glued to the learning throttle so I’m not stopping anytime soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=340cde9a2ecd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>