Finger print detection by Krishnam Goyal

Finger print detection by Krishnam Goyal

Today, one of our customer Krishnam Goyal Worked on and shared a nice OpenCV based code to detect hand (fingers) using simple camera module and python code.

This is not a tutorial but just a shared post to congratulate Krishnam for nice work and to encourage to create more such projects.

Its the photo of Krishnam doing the experiment and code

Python Code

import cv2 as cv
import mediapipe as mp

import time
cap = cv.VideoCapture(0)
class handDetector():
    def __init__(self, mode = False,maxHands = 2, detectionCon = 0.5, trackcon = 0.5):
        self.mode = mode
        self.maxHands = maxHands
        self.detectionCon = detectionCon
        self.trackcon = trackcon
        self.mpHands = mp.solutions.hands
        self.hands = self.mpHands.Hands(self.mode,self.maxHands,self.detectionCon,self.trackcon)
        self.mpDarw = mp.solutions.drawing_utils

    def findHands(self,img,draw = True):
        imgRgb = cv.cvtColor(img, cv.COLOR_BGR2RGB)
        self.results = self.hands.process(imgRgb)

        if self.results.multi_hand_landmarks:
            for handLms in self.results.multi_hand_landmarks:
                if draw:
                    self.mpDarw.draw_landmarks(img, handLms, self.mpHands.HAND_CONNECTIONS)
        return img
    def findposition(self,img,handNo = 0, draw=True):
                lmlist = []
                myHand = self.results.multi_hand_landmarks[handNo]
                if self.results.multi_hand_landmarks:
                    for id, lm in enumerate(myHand.landmark):

                        # print(id,lm)
                        h, w, c = img.shape
                        cx, cy = int(lm.x * w), int(lm.y * h)
                        lmlist.append(id, c, cy)
                        # print(id, cx, cy)
                        # if id == 4:
                            # cv.circle(img, (cx, cy), 25, (255, 0, 255), cv.FILLED)'
                return lmlist

def main():
    Pt = 0
    cT = 0
    #cap = cv.imread(0)
    cap = cv.VideoCapture(0)
    detector = handDetector()
    while True:
        success, img = cap.read()
        img = detector.findHands(img)
        detector,
        cT = time.time()
        fps = 1/(cT-Pt)
        Pt = cT

        cv.putText(img,str(int(fps)),(18, 78), cv.FONT_HERSHEY_COMPLEX,3,(255,0,255))
    # if fps >= 20:
    #     cv.putText(img, str(int(20)), (180, 78), cv.FONT_HERSHEY_COMPLEX, 3, (255, 0, 255))
        cv.imshow("Video", img)
        cv.waitKey(1)
    
if (__name__ == "__main__"):
    main()

The modules needed to run this code

Feel free to experiment with this code.

5 tips on How To Stay Productive All Day

Primarily speaking, there are 2 type of works people do. One is the job. While doing a job, most often, there’s a pressure of getting things done. There’s always someone who’s either watching you or asking you for your progress and you’re automatically accountable. Another kind of work is a business. There are many types and forms of business but for the sake of current discussion, lets talk about the work that you do alone or with a very small team of yours. In this case, if you’re the boss, then there’s no one (except your customers) asking you about progress. If you’re not accountable to anyone, it becomes harder to keep yourself productive and motivated all day. And am sure, if you run some sort of business, you do have the feeling that you’re not doing things to the lever you’re capable of doing and the level which you should be working on.

Regardless of you’re working in a job or business, we all face the time during the day when we get bored. or we simply don’t do the things we’re supposed to do. The upper hand here for people with job is they have to drag themselves to complete the task at hand. Whereas its very easy to procrastinate for a business owner. And we’re going to talk about some simple steps that can be taken each day to stay productive all day long.

What kills our productivity?

Stay Productive
Are you productive throughout the day?

There are way too many factors involved which kills productivity or energy level. Look, am not a doctor or a nutritionist. Then what gives me authority to talk on this subject? My credentials are that for most part of my career, I am running business and hence I know how it gets if you don’t work to the level you’re supposed to be.

There are too many factors which I have observed, which if they’re taken care of, the productivity can skyrocket. See these tips below and tell me if you can resonate with it.

How To Boost Productivity?

These are my tips and questions you should ask yourself to keep your productivity on high level throughout the day. This is all based on my personal experiences and you may or may not agree with me, but hey, what’s harm in trying out?

1. How is Your Work Space?

set of different items for travel on surface
Is your workplace Clean?

Perhaps the first and most important thing is about your work space. Your workspace is the most important thing that decides your productivity. A non-healthy work place will create a non healthy work style and ethics. The corporate’s are not crazy to create fancy lobby’s and recreational spaces and properly lit desks and clean offices. If you’re working alone or in a small team, your working place has to meet below criteria’s to keep your work smooth all day long.

Cleanliness

Am not saying to change your office into something fancy; but cleaning the entire space daily is a must. Even small dust or small garbage of papers lying around creates an un-noticeable subconscious disturbance. And without knowing it affects your work. Also make sure to clean your desk before ending your work each day, so that you start your next day afresh and full of energy.

Lightning

Workspace must be very well lit. Now this is a subjective term, but being a technical person I’ll give you a hint to check. Download any lux meter app. Lux is the unit of measuring the light illumination. Your phone already has this sensor and you can easily check your illumination in your home. Download the lux meter app and check its value in various places throughout your room and office. It should always be minimum 400 or greater. The higher it is, the better it’ll be. A well lit area soothes your eye and reduces eye strain while using computer for a very long time.

Temperature

Off course, the next thing after light is temperature. While in places like India, we don’t have much control over temperature unless you have an Air Conditioner in your office. Having Air conditioner is not very common yet in India and not every one can afford it. Still try to have many fans and keep the temperature at an optimum level of between 25 degree C to 33 degree C. Less than that, it’ll create cold and make your atmosphere cozy, which will make you tend to sleep. More than that will make it hot and uncomfortable to sit and work.

Open Space

Its much helpful if you have some open space around your office. If you’re working from home, then the lobby in your building or the road in front of your office is very good place, not to work, but to roam around time to time. Whenever you receive a call, try to get out of your place and roam around in this area. It’ll create some movement and also relax your body and eyes.

Quick Boost Equipment

What is it? nothing fancy, its just something which you can use quickly and get some blood circulation. This is something you use after every 2-3 hours to raise your blood circulation. Consider a small kind of exercise equipment. A simple inexpensive punching bag is very effective to have in your workplace. If you hit your punching bag just 3-4 minutes every couple hours, it’ll keep the release of endorphins going on throughout the day. Release of endorphins makes us feel good and energized. There are other alternatives like having a skipping rope or hula hoop or pullup bar. If nothing, then just doing 1 minute jumping jack will give you enough exercise to keep you fresh every couple of hours.

2. How you started your day?

woman turning around on green fields
Fresh Morning ensures productive day

We should have actually started with this one, but never mind. How the day started has a huge impact on how our day goes. It doesn’t matter how good your workplace is, if you cannot start your day well then its difficult to keep energy level high during the day. Ideally I recommend these 3 morning habits as mentioned below

  • 10 minutes sitting in Silence
  • 10 minutes of reading
  • 10 minutes of exercise

I know 10 minute of exercise is not much; but I belong to India and I know few exercise things like Sun Salutation (Surya Namaskar) done EVERYDAY for even just 10 minutes are great energy booster for your body. It takes very little time and no equipment except a mat.

Then the simplest meditation is a 10-minute silence. Just sit silent. There are 100 or more different meditation techniques which needs laborious work to learn. However meditation is not something you have to do. If you have to do it, then its exercise. Meditation just happens to you when you simply sit there. On your day 1 whenever you set your 10 minute timer and sit, your mind will be clouded by thoughts. The thing is, we don’t have to do anything here. Do not try to suppress those thoughts. Do not try to NOT THINK about them. Just don’t indulge in anything. Simply notice. On day 1 you won’t feel any change. But on day 15, you’ll feel a complete different level of serenity. And all am asking is 10 minutes a day in morning. Is it that difficult to do?

After Meditation, try to read your favorite book just for 10 minutes. Try not to read novel or fantasy stories this hour. Try to read something nice, simple and motivational. Not even too complex like think and grow rich. No, not that. Just something very simple. If you’re spiritual then something in that sense. For reading daily, I have some recommendations here. The text in these books will never become old and it is highly recommended to read it daily.

  • The Greatest Salesman in the World — Og Mandino
  • 7 spiritual laws of success — Dipak Chopra, also written here very nicely
  • The 10x Rule — Grant Cardone
  • Inner Engineering — Sadhguru

If you gift these 30 minutes of your life daily, it’ll create a drastic change in the quality of your life. And you don’t have to take my word for it. You already know that these things are good, They won’t cost you any high money. So just get started doing it and see the results.

3. What you ate?

brown wooden chopping board with pink and white cream
Photo by Neetu Laddha on Pexels.com

Next thing to discuss is what you ate before starting your work. Its important to eat before starting your day and its equally important to eat right food before starting a day. I know of a standard routine that is followed throughout the world. We have a breakfast in morning, then lunch and then dinner. Many people also have a habit to eat something between lunch and dinner since the gap is to high.

Again am not a diet expert and hence I won’t pretend to be. But I’ve done several experiments with myself and those I’ll share with you.

Breakfast

Try to take a breakfast which should be high in energy and light on stomach. And without fail, there has to be a water based food in your breakfast. Water based foods keep your energy level high. These includes fruits / sprouts / veggies. Am not saying you eat veggies every day morning. But whatever you eat, a portion of it must be fruit or something which contains lots of water. A very simple suggestion that I have is start your breakfast with a banana and then eat whatever it is that you eat. Banana is available almost everywhere in world, its affordable and tastes good. The breakfast should be fulfilling and light on stomach. What I mean by this is, eat to your satisfaction but try to avoid too much fried stuff or too much meat in morning. Remember, something which is water based is key to your morning energy. Don’t take my word at all, just experiment and you’ll feel the difference.

Lunch

Lunch is different for different people across the world. For some it may be a full Indian Thali, for some it may be a burger or a sandwich. The only tip here is whatever you eat, just try to eat slowly. Give maximum time to lunch. Don’t just rush to finish your lunch to catch some free time from break. The lunch hour is hour long for a reason and that is you should eat slowly. When you eat slowly, you just can’t overeat at all. This will help you get full without eating much of whatever you’re having.

Dinner

Although, most dieticians say that you should take very light dinner, I’d contradict here a little. Dinner is the kind of meal which we take when we’re done with work, mostly happy with family and hence we tend to have most food at night time. We also tend to have parties or outing with friends at night time. You all know what must be eaten and how much, so you can decide it for yourself. My only suggestion is, if you want to eat whatever you want, just make your dinner as early as possible. The earlier you eat, the better your body will handle the food and the better you’ll sleep. When you eat late in night, during sleep, body is utilizing lots of energy for digestion and hence you won’t awake fresh the next morning. Once again, just give it a try ๐Ÿ˜‰

4. How much distractions you handle?

apps blur button close up
Phone is probably number 1 time killer!

During the day, there are too many distractions for our work. Its imperative to keep a log of our distractions throughout the day to monitor how we work. Deep Work is something very uncommon these days and if you want to work deep, you’ll have to keep the distractions at bay. The easy way to do is, just count your distractions for one day. Just one day. Just try to keep a notebook and write on it whenever you checked social media / messages and responded to them. Also mention how many coffee/tea breaks you took. When you create a log, you create a rule for yourself about how you lie to handle these things. Its up to you how to reduce these, but at least if you have a log, then you know the reason why you’re not up to the mark today. I hope you got my point. Ideally when am writing, I just keep my phone on airplane mode. Not everyone has this luxury and we have calls to attend to. But whenever possible, try to keep the phone at least in silent mode.

5. How you feed your mind and body throughout the day?

white printer paper on white table
Say No to news and coffee ๐Ÿ™‚

The most important point is this. No matter how good you started the day, no matter how good you ate and kept yourself distraction free. If you don’t feed your mind and body with good stuff during the day, you’ll not feel productive. In order to keep the mind healthy, I have few tips, you don’t have to try them all just look at them and see how many you can try.

How To Keep The Mind Healthy Throughout Day

Throw away newspaper and never read it. You don’t need to read about the murder and rapes happening in world. Frankly, you don’t also need to know what’s happening in the politics unless its your field of work. This just deteriorate the state of mind which is hazardous for us

Do not google search for everything, someone told you about that classic Robert De Niro movie he watched and you open search engine and check it and then go to imdb and see the ratings and reviews and then see where you can watch them. And then see what other good movies are there and HEY HEY HEY, wait. Nothing of it is going to be good for your work. You have evenings to do them. Don’t fill your mind with unnecessary knowledge just because you have access to.

Avoid Family Phone calls, I know it sounds rude, but its better that you don’t know what’s going at home unless its urgent. You don’t need to discuss the wedding plans of your cousin and you absolutely don’t need to discuss about your next holiday with wife when you check flights during work. Unless its urgent, don’t talk to family during the day. You may not agree with me, but as said, you don’t need to believe me. You just need to give these things a try

After taking care of mind, just follow simple things for keeping your body good throughout the day

How To Keep The Mind Healthy Throughout Day

You know it and probably hundred people told you about, but its so important that I cant skip it. Drink lots of water. Period, you know everything about it

Keep handful of nuts in your drawer, peanuts, almonds, chickpea whatever you like. This should be your go to snack whenever you feel to have something. A cheese cube is also a good option.

Avoid coffee as much as possible, Am not saying don’t drink coffee, but try to replace it with something similar and good, e.g. lemon tea. While caffeine gives you immediate boost, it also dehydrates you. You know it all, just avoid as much as possible ๐Ÿ™‚

Try to avoid lunch parties. We tend to have birthdays or something when working in a company. In such case, Its common to have Pizza or Biryani parties for lunch. Once such things are done, your work for day is almost over, try to avoid. Just cut the cake and have your regular lunch and party hard in evening ๐Ÿ˜‰

Am pretty sure I have not told you things which you already don’t know, but I have definitely summarized them for future reference. Feel free to try them and let me now in the comments. Also let me know if you don’t agree with anything I said. Once more, you don’t need to agree with it, you just have to try it.

All the best, thank you for reading.

How to Earn Passive Money?

If there’s one thing that COVID-19 pandemic taught me, then its that You simply cannot rely on one income source otherwise your family’s future can be easily jeopardized.

Although Most of my life, am not working in a job, but even a business of just one thing looks like a job. It pays you a round about income for the kind of things you sell. I used to run an electronics training center and it had to be shut down due to lockdown. I had several consulting jobs which were paying me a regular income, all of a sudden, they were gone too. And there was something I had done as side-kick which not only survived me, but also gave me a new perspective to look at career.

That one thing was my online courses on Udemy. Yes, the same things I was teaching in my training center, I used to create videos around them and then combining them together, I had created online courses. During lockdown, my online courses put food on my table and sparked new ideas in my mind while keeping my morale high. And most importantly, it was all passive income. I wasn’t even working for earning it. Don’t you want to know what is passive income? let me tell you

What Is Passive Income?

person holding turned on silver laptop computer
Passive Income

Passive income is the kind of income for which you don’t have to work on daily basis. Its nothing new. If you own a property and rent it to someone, you earn passive income as rent. If you have bought huge stocks they pay you dividends. If you have invested huge amount of money, then it pays you as interest. All these things are passive income. But there is a catch!

In order to earn passive income in above way, you have to have a huge income upfront. Or at least a family fortune ๐Ÿ˜‰๐Ÿ˜‰ in terms of property.

But there are other sources of passive income also. In the advancement of internet, there are multiple different doors of passive income available to just about everyone. So coming to the million dollar question, How to make passive income?

How to Earn Passive Income?

crop payroll clerk counting money while sitting at table
Making passive income

If you’re like most people, then you don’t have a huge money to invest upfront, neither you have a huge family fortune. So how to earn passive income in digital world? You see, we all have these things in front of us for all the time, yet we never looked at them. Or even we looked at them but never thought of doing anything about it. There are multitudes of sources from where you can earn passive income without spending almost no money, which includes but are not limited to

  • Starting a blog (like the one you’re reading)
  • Write a book (you’ve already read plenty of them)
  • Start a Youtube Channel
  • BUT, yes there’s a big but, and that is all above things take a long time to make as well as them get them ready to earn money. So what else is there?
  • ONLINE COURSES

How to online course generate passive Income?

Yes online courses can generate passive income. Online course is something which will take the least amount of time to create and will start making money to you fastest. An online course is a collection of lessons, video + audio + text. But should contain more video and less of other things. Compiled together, this online course should help someone achieve something. The bigger the rewards the bigger the demand for your course. And understand, even if your course makes someone very happy because now they can draw micky mouse easily, this is a big achievement for them and its a big achievement for you. So don’t think you have to teach some sci-fi coding. You can teach any skill that people love to know about and get paid for it.

There are platforms like skillshare and udemy where you don’t have to do any marketing and just upload your course and start making money. I have written a detailed tutorial about how to teach on udemy and generate passive income for yourself and your family which you can read here.

What can be done with Passive Income?

What not?

Let me tell you what passive income can do for you.

If you can make a mere โ‚น 6000/- per month, you donโ€™t ever have to pay for your big annual expenses

  • Smartphone for you and your spouse 
  • Television Set or any other equipment you wanted to have 
  • Extra curriculum classes for your kids 
  • Your next laptop / ipad

If you can make just 12000/- in passive income, you donโ€™t ever have to pay for 

  • Schooling for one of your kids 
  • That car you wanted to buy 
  • Fuel for your bike
  • Next Scooter for your younger sibling or your wife

If you can make 24000/- in passive income, you donโ€™t ever have to pay for

  • Schooling for both of your kids
  • Big savings per month that you wanted
  • Your mid sized Sedan and its fuel

If you can make 48000/- in passive income, you donโ€™t need to pay for

  • Your home EMI and monthly savings OR
  • Your dream SUV and monthly savings

I hope you got the point am making here. Look even small passive income can offload you of lot of financial worries. And yes its possible if you just work 20 minutes per day. Yes just 20 minutes is all that is needed for you to share the skills you already have and share it with world. And am just another person like you who is doing this and I believe if I can do it then anyone can do it. Hence I want to share this thing with you. You can also earn passive income by just sharing the knowledge you have with world and I have already written it in detail how to do that in this post here.

How You earn Passive Income with Online Courses?

young lady typing on keyboard of laptop in living room
Work with the Computer you already have

You create your online course, you publish them to Udemy and skillshare and many such platforms. Students visiting these sites, see at your course. They purchase it from there. The Udemy or any such company gets to pay some portion of your money and you get other part of your money. Nothing else is needed. However if you’re tech savy, you can always setup your own website and sell these courses there also. There is no exclusiveness to courses on Udemy. Even if you sell it there, the content is owned by you, not by Udemy and hence you’re free to sell them any place as you want to including your own site.

What’s next?

Look its a proven fact that people like me and thousand others are already earning passive income, its just about time that you realize you can too and get started with it. The earlier the better, however there is never too late. Just grab a pen and paper and start writing your ideas.

And if you really feel you need some expert help in shaping up your online course, you can always contact me :).

person doing thumbs up
All the best

Wishing you All the best ๐Ÿ‘


Want to know how you can start your alternate source of passive income? Lets talk

C# Code to connect to MYSQL on Raspberry Pi

C# Code to connect to MYSQL on Raspberry Pi

This is a follow up post to this last one where we installed mysql on raspberry pi and added a remote user to it. If you haven’t done it, then please go here and do that first on raspberry pi

Add the MySQL Connector to Visual Studio

In order to use MySQL related code in your program, you need to add the default mysql connector to your project. Which is using MySql.Data.MySqlClient;

To do this, just right click your project and click on “Manage nuGET Packages”

manage nuget packages

manage nuget packages

Click on the Manage nuget packages link as shown in the yellow box in above Image. This will open the nuget package manager in visual studio. Here, simply search for Mysql and you’ll get the first result as the MySQL.Data by Oracle. That is the one we need to install

See the Image below

mysql on raspberry pi

Click on the MySQl.Data and install that package, it should take about 2-5 minutes. Once done, you can run the next program to check the connection between C# code and mysql running on raspberry pi

.net code to connect to mysql on raspberry pi

Once everything is in place, just open your visual studio and create a console application. You need to use below code in console application to test your connection. Make sure to use the IP address, user name and password according to your particular instance. Just make sure to change this line in the code as per your raspberry pi address and userid and password of database and also the database name.

string cs = @”server=192.168.0.133;userid=YOURUSERID;password=YOURPASSWORD;database=YOURDBNAME”;

Run the console application. If it shows the version of the mariadb on console, it means your connection is working

using System;
using MySql.Data.MySqlClient;

namespace ConsoleApp_testMariadb
{
    class Program
    {
        static void Main(string[] args)
        {
            string cs = @"server=192.168.0.133;userid=dfpl;password=dfpl;database=mts";
            using var con = new MySqlConnection(cs);
            con.Open();
            Console.WriteLine($"MySQL version : {con.ServerVersion}");
            con.Close();
        }
    }
}

More Sample Codes are found here

C# MySQL tutorial – programming MySQL in C# (zetcode.com) (zetcode.com/csharp/mysql/)

Connect to MySQL on Raspberry Pi from Windows PC

Connect to MySQL on Raspberry Pi from Windows PC

While experimenting with mysql on Raspberry Pi, I often stumble upon few steps. Therefore I decided to write a post about creating the remote connection on mysql on raspberry pi. This post is about how to login to mysql on raspberry pi from windows computer. The steps are as they worked for me and may be different for you depending on version on your raspberry pi and your mariadb.

I have Raspberry Pi 4, 2GB RAM with the raspberry Pi os version February 2021

Mariadb on raspberry Pi Version : 10.3.27-MariaDB-0+deb10u1 |

How to connect to mariadb (free version of mysql) Server running on Raspberry Pi from Visual Studio Application

Install MySQL on Raspberry Pi

Since MySQL is a proprietary ORACLE product, there is no way you can install the MySQL on raspberry pi, however, we can use the free version of mysql which is called MariaDB on Raspberry Pi. Exactly the same functionality for all basic rdbms applications

Install Mariadb On Raspberry Pi

To install mariadb on raspberry Pi, run following series of commands. The update and upgrade are optional if you’ve recently done them on your raspberry Pi. So Open the terminal of Raspberry Pi, and use these commands to get mariadb installed on your raspberry pi

sudo mysql -u root -p
sudo apt update
sudo apt upgrade
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo mysql -u root -p

ย 

Allow remote connection to Mariadb On Raspberry Pi

By default, MySQL or Mariadb on raspberry pi is not configured to accept remote connections. You can enable remote connections by modifying the configuration file: For me, in the raspberry pi, the configuration file WAS NOT LOCATED on this address

sudo nano /etc/mysql/my.cnf

Instead I found it at

/etc/mysql/mariadb.conf.d/50-server.cnf

So you may need to experiment with your raspberry pi and the version of mariadb to see where you find this file

Here, find the bind-address line which should be currently pointing to localhost address which is 127.0.0.1. In order to login from external source, you’ll have 2 options.

  1. To access from A specific computer ONLY, you need to put address of that computer
  2. To access from Any computer on LAN, change this address to 0.0.0.0 In my case, I did this.

Now,

Restart the MySQL service

sudo service mysql restart

Setup MySQL permissions

Connect to your MySQL instance as root:

mysql -p -u root

Remember, you can’t access mysql remotely using root user, so don’t try with it and simply create a new user which should be created at both localhost and at ‘%’ just like below

Now, Create a user:

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';

The apostrophes ( ‘ ) in the syntax are required

After this,

GRANT ALL ON *.* TO 'myuser'@'localhost';
GRANT ALL ON *.* TO 'myuser'@'%';
flush privileges;

Login to Mariadb on Raspberry Pi from Windows Computer

Now that we have created a user to login to our database remotely, its time to test this connection. To do this, you’ll need to install some database client on windows machine just like dbeaver

Once you install dbeaver, you can login to your database by specifying the server address as IP_OF_YOUR_RPI:3306

3306 is the default port number of mariadb server on raspberry pi and then you can see the data through dbeaver

mariadb on raspberry pi connection from windows pc

mariadb on raspberry pi connection from windows pc