<?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 sudhir jain on Medium]]></title>
        <description><![CDATA[Stories by sudhir jain on Medium]]></description>
        <link>https://medium.com/@sudhirjain01dec?source=rss-cdedc87b925------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*CQt5F9bmBCGqdyqv.</url>
            <title>Stories by sudhir jain on Medium</title>
            <link>https://medium.com/@sudhirjain01dec?source=rss-cdedc87b925------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 19 May 2026 12:23:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sudhirjain01dec/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[Search Bluetooth Devices using Python.]]></title>
            <link>https://medium.com/@sudhirjain01dec/search-bluetooth-devices-using-python-73e01dd2697e?source=rss-cdedc87b925------2</link>
            <guid isPermaLink="false">https://medium.com/p/73e01dd2697e</guid>
            <category><![CDATA[bluetooth]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[sudhir jain]]></dc:creator>
            <pubDate>Mon, 16 Oct 2017 03:04:16 GMT</pubDate>
            <atom:updated>2017-10-16T03:04:16.903Z</atom:updated>
            <content:encoded><![CDATA[<p>I was trying to make some program to enable communication over Bluetooth using my Raspberry Pi 3. So I come up with this basic program to get started with this topic. I hope this will be helpful.</p><p>For Setting up Bluetooth in Raspberry Pi or in your laptop run the following command from your terminal.</p><p><em>sudo pip install pybluz</em></p><p>Now the coding part.</p><pre>import bluetooth<br>print &#39;Sreaching for nearby devices...&#39;<br>nearby_devices=bluetooth.discover_devices(duration=8,lookup_names=True,<br>                                          flush_cache=True)<br>print &#39;found %d devices&#39;%len(nearby_devices)<br><br><br>for addr,name in nearby_devices:<br>    try:<br>        print &#39; %s - %s&#39;%(addr,name)<br>    except:<br>        print &#39; %s - %s&#39; % (addr, name.encode(&#39;utf-8&#39;,&#39;replace&#39;))</pre><p>This will print all the nearby devices. There are many wonderful things we can do with this small piece of code. Like you can Turn on your laptop when ever you come near automatically using your phone’s Bluetooth. You can make your own chatting application using this.</p><p>This can be very useful for the embedded devices like Raspberry Pi to communicate with other devices using Bluetooth. We can control different peripherals attached to the Rasp Berry p using this.</p><p>There are enormous uses we can think of.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73e01dd2697e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When your painting leads you to places]]></title>
            <link>https://medium.com/@sudhirjain01dec/when-your-painting-leads-you-to-places-a0f8c7e5716a?source=rss-cdedc87b925------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0f8c7e5716a</guid>
            <category><![CDATA[krishna]]></category>
            <category><![CDATA[painting]]></category>
            <category><![CDATA[discover]]></category>
            <category><![CDATA[art]]></category>
            <category><![CDATA[travel]]></category>
            <dc:creator><![CDATA[sudhir jain]]></dc:creator>
            <pubDate>Mon, 11 Sep 2017 13:10:47 GMT</pubDate>
            <atom:updated>2017-09-14T04:01:13.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*1wI0Q6LR7bsjVLNnHBEuuQ.jpeg" /></figure><p>It started when I want to paint my first canvas painting. I choose this one, as I see a great subject in this. This is the painting of Lord Krishna playing this flute and traveling through the woods giving the message of how life should be.</p><p>When this painting was partially completed I started reading books on him and one day I decided to went to his birth of place Mathura and the place where he lived Vrindavan. So the next morning I packed my backs and left for the twin cities from Delhi with my friend Sumit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*777TuiKpqgBNiGbX1H9CjA.jpeg" /><figcaption>source : my camera</figcaption></figure><p>This place carries purity , spirituality and lessons for life. You Just need to open your eyes and ears, these cities will tell you thousands of tales.</p><p>I went to different temples and the banks of Yamuna. Discovering the things I was painting was a very exciting experience for me. You just need to observe and even a Pigeon can teach you some important lessons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UfQFmrqmxYzew_g45yCViw.jpeg" /><figcaption>source : google</figcaption></figure><p>These Pigeons were flying over both the Temple and the Mosque. They were sitting on dooms of both. They don’t have any preferences , only the shade is what they needed whoever can provide it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fVR2nQDFrtO8GsjsGYtRXA.jpeg" /><figcaption>source : my camera</figcaption></figure><p>At the end, this journey was a great experience for me and helped me a lot connect more with the painting and to complete it.</p><p>Hope you liked this blog , for more do follow me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0f8c7e5716a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optical Character Recognizer using kNN and OpenCV ! Part2.]]></title>
            <link>https://medium.com/@sudhirjain01dec/optical-character-recognizer-using-knn-and-opencv-part2-57637649079c?source=rss-cdedc87b925------2</link>
            <guid isPermaLink="false">https://medium.com/p/57637649079c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[character-recognition]]></category>
            <dc:creator><![CDATA[sudhir jain]]></dc:creator>
            <pubDate>Mon, 11 Sep 2017 10:23:18 GMT</pubDate>
            <atom:updated>2017-09-11T10:26:38.543Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKPpJ_CXDMLKODVRJSnIhA.gif" /></figure><p><strong><em>Update: </em></strong><em>This article is part of a series. Check out the full series: </em><a href="https://medium.com/@sudhirjain01dec/very-simple-yet-powerful-ocr-using-opencv-python-and-knn-part-1-a5aa1b00869a"><em>Part 1</em></a><em> and</em><a href="https://medium.com/@sudhirjain01dec/optical-character-recognizer-using-knn-and-opencv-part2-57637649079c"><em> Part 2</em></a><em>.</em></p><p>The very basic method to do OCR is using kNN . Prerequisite of this method is a basic knowledge of Python ,OpenCV and Machine Learning.</p><p>The whole process can classified in two group.</p><ol><li>Training our ML model and knowing it’s efficiency .</li><li>Loading the model created to recognize the character.</li></ol><p>Lets Begin with the Training Model.</p><p>I am going to use this image to train our model with Hand written character.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NY0jiUkRq8hC6VVtM0xp0A.png" /></figure><p>This Image contains 5000 handwritten digits 500 each. You can save this file as “digits.png” in your program directory.</p><p>We basically needs to extract the 5000 images from this file out of which we will use 2500 to train our model and 2500 to test the efficiency of our model.</p><pre><strong>import </strong>cv2<br><strong>import </strong>numpy <strong>as </strong>np </pre><pre><em>#Load the training image <br></em>img = cv2.imread(<strong>&quot;digits.png&quot;</strong>)<br>#Convert this Image in gray scale</pre><pre>gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)<br><em># Now we split the image to 5000 cells, each 20x20 size<br></em>cells = [np.hsplit(row,100) <strong>for </strong>row <strong>in </strong>np.vsplit(gray,50)]<br><em># Make it into a Numpy array. It size will be (50,100,20,20)<br></em>x = np.array(cells)<br><br><em># Now we prepare train data and test data.<br></em>train = x[:,:50].reshape(-1,400).astype(np.float32)   <em># Size = (2500,400)<br><br></em>test = x[:,50:100].reshape(-1,400).astype(np.float32) <em># Size = (2500,400)<br># Create labels for train and test data<br></em>k = np.arange(10)<br>train_labels = np.repeat(k,250)[:,np.newaxis]<br><br>test_labels = train_labels.copy()<br><em># Initiate kNN, train the data, then test it with test data for k=5<br></em>knn = cv2.ml.KNearest_create()<br>knn.train(train, cv2.ml.ROW_SAMPLE, train_labels)</pre><p>By this small piece of code we have trained our kNN model. Now can test its accuracy. If you have used the same process, the accuracy of the Model will be around 92%. So its a good habit to at least save 20% of your data set for testing purposes to know accuracy of your ML Model.</p><pre>ret,result,neighbours,dist = knn.findNearest(test,k=5)<br><em># Now we check the accuracy of classification<br># For that, compare the result with test_labels and check which are wrong<br></em>matches = result==test_labels<br>correct = np.count_nonzero(matches)<br>accuracy = correct*100.0/result.size<br><strong>print </strong>accuracy</pre><p>We can also save the model for future use. Because every time training the model to test our images will be time taking process.</p><pre><em># save the kNN Model<br></em>np.savez(<strong>&#39;knn_data.npz&#39;</strong>,train=train, train_labels=train_labels)</pre><p>Now the Part 2 of this programs starts where we can load the trained model and test our own image.</p><p>I will using this image for predicting you can save it as “test.jpg” in your working directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/50/1*hnktzAtIoWt9uljSp_rPag.jpeg" /></figure><pre><strong>#Load the kNN Model<br>with </strong>np.load(<strong>&#39;knn_data.npz&#39;</strong>) <strong>as </strong>data:<br>    <strong>print </strong>data.files<br>    train = data[<strong>&#39;train&#39;</strong>]<br>    train_labels = data[<strong>&#39;train_labels&#39;</strong>]<br> <br>knn = cv2.ml.KNearest_create()<br>knn.train(train, cv2.ml.ROW_SAMPLE, train_labels) <br>  <br>test_img=cv2.imread(<strong>&quot;test.jpg&quot;</strong>)<br>test_img =cv2.cvtColor(test_img,cv2.COLOR_BGR2GRAY)<br>test_img =cv2.resize(test_img, (20, 20)) <br>x = np.array(test_img)<br>test_img = x.reshape(-1,400).astype(np.float32)<br>ret,result,neighbours,dist = knn.findNearest(test_img,k=1)<br><em>#Print the predicted number <br></em><strong>print </strong>int(result)</pre><p>While predicting keep the value of k Nearest Neighbors(k) be odd as having a even value can cause a draw and will be conflicting.</p><p>I hope you find this blog helpful. Will cover the kNN in more detail with bigger data set in the next part.</p><p>Do follow me for more technical blogs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57637649079c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optical Character Recognizer (OCR) !]]></title>
            <link>https://medium.com/@sudhirjain01dec/very-simple-yet-powerful-ocr-using-opencv-python-and-knn-part-1-a5aa1b00869a?source=rss-cdedc87b925------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5aa1b00869a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[opencv]]></category>
            <dc:creator><![CDATA[sudhir jain]]></dc:creator>
            <pubDate>Fri, 07 Jul 2017 08:03:38 GMT</pubDate>
            <atom:updated>2017-09-11T10:25:19.114Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKPpJ_CXDMLKODVRJSnIhA.gif" /></figure><p><strong><em>Update:</em></strong><em> This article is part of a series. Check out the full series: </em><a href="https://medium.com/@sudhirjain01dec/very-simple-yet-powerful-ocr-using-opencv-python-and-knn-part-1-a5aa1b00869a"><em>Part 1</em></a><em>, and </em><a href="https://medium.com/@sudhirjain01dec/optical-character-recognizer-using-knn-and-opencv-part2-57637649079c"><em>Part 2</em></a></p><p>OCR ,<a href="https://en.wikipedia.org/wiki/Optical_character_recognition"><strong>Optical Character Recognizer</strong></a> is one of the very hot topics nowadays. It has been there in the picture since very long time.In simple words OCR processes the image, PDF or any other file and extract the textual information from it. It is very easy for human beings to recognize a word they know,but what about a word from different language which we don’t know.Same is the case with Computers,they don’t know anything about these words or characters .Now here comes Machine Learning in the picture. We can train our machine like a baby by showing different images to him. Isn’t this great !!!.</p><p>We can’t even imagine all the applications of OCR.Imagine a person without vision pointing his mobile towards a Medicine Packet and then the mobile reads all the important information to him like name of medicine,it’s expiry date ,it’s price and then may be searching on internet the prescription of that medicine. A machine converting very old precious book into PDF ,so that the whole world can enjoy that book. And even when me visiting a restaurant in China and converting the menu written in Chinese in English or Hindi so that I can order something to eat.</p><p>If you sit and think about all these applications of OCR ,you will find out that there are many that can change every one’s life.</p><p>In this series of blogs, I will cover different methods for OCR .From most basic one to most efficient one,I will cover different aspects and applications of OCR and how one can implement it. In the beginning of this series I will be using kNN for OCR and will move forward on different Machine Learning models .</p><p>I hope you will enjoy this journey :) .</p><p>To begin your journey in OCR please visit my next blog where I covered the basic OCR using kNN in OpenCV python.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5aa1b00869a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>