How To Make An AI Based Virtual Keyboard In Python OpenCV / CV2 | OpenCV Tutorials | Computer Vision

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there guys welcome back to my channel and in this video we are going to see how to make and virtual hack game so let's start so right over here you can see that i have here an app when i press so it just types that letter so you can see that it works fine so let's see how to make it i will just exit this and and what i will just do is go to my previous hand tracking code which i had so you must remember it so i will also give the tutorial and the source code link in the description and she will also get the source code link of the ai virtual keyboard project which we are making right now so let's see so so let's import our imports i will import map app and i will use a new module called pi and put for keyboard controlling i will see here from by and put import controller and i will also import the key now let's just import the controller and now what i will just do is i will also add here the time dot sleep so i should get angry so that's why i will import time and what i will just do before starting i have here and variable list for the keys so i will just paste this you will also get this list in my description so in this i have basic keys which i need and i list and it is we have sub list for rows and columns and now what i will just do is create here class for storing the data which i used for drawing the keys here i will create and stop store class and here we'll define and init function something like that and inside this init function what i will just do is i will say here self dot so first let's ask it for our arguments and the arguments are position and then the size and then the text so let's define them so i will say here position equals to position which you have and then the size equals to the size we have and then self dot text equals to the text we have so just below it what i'll just do now we have our store function so i will also create a function for drawing i'll see here define draw and inside this function what i will just do is ask it for my image and this stored brass and then just below it what i will just say here from va and store and what i will just do inside this i will see here one dot position and i will just set it as x and y and i will see here the width and height as bar dot size something like that and what i will just do to draw the rectangle here i will say cb2 dot rectangle means the button which we will draw and put text on it here we'll see i will see here image and then i will see here button dot position and then what i will just do is see here my x y plus fifth height and here also similarly and then what we need is the color so the color will be a grayish color between 64 64 by 64 and for the thickness i will say filled and just below it i will also put the text for the button and here what i will just do is here image and then here i will say button.txt actually text and here i will set the x and y and x plus 10 and y plus y plus and let's start here 43 so i have just tested this parameters before and what i will just do after adding the the x and y here will set the point as hershey plane and just keep the scale at three and in the color as right and then the thickness as too right and here what i will just do return my image after drawing it so that just wraps up the draw function and what i will just do is create here and stored and what i will just do just below it i will see here for i in range of the prompt so it will be the length of the case and just inside it what i will just let's see here for g and the key and this will be in enumerate [Music] and here we see the key and i will access the i right so now what we will get is the index of the element and the keys so what i'll just do let's say here stored dot append and inside this what i am going to append is my here i will say i will call my stopover function and inside this what i will say is here we say 60 as and multiplied by so what i i'll just do is wrap this in the other list and here we say multiplied by j we'll say plus 10 and here as the y will be 16 multiplied by i plus and this time i will say plus 10 also and for the size it will be 50 by 50 and then the text will be the key that we have and now what we should get is the stored bar so now what i will just do after getting the stored bar is just do it i will first let's get the element list lm list equals black so to get the lm list what i have to just do is write over here say for id and the element and enumerate so i will just copy this results dot multi landmarks and paste it in this enumerate here i will say the first index and here's a dot landmark right and just over here what i will just do so zero means the first hand that we have and he will say h height width and then the channel and he will say image dot shape so right over here after getting the shape i will also get the center x and center y and those both will be integer here i will say l m dot x multiplied by width okay multiplied by width and similarly here just after that i will just copy this all and paste it and here we'll see multiplied by height you'll see why right and what i will just do is say here ln list dot append and inside this i will append my cx and cy right and after this here we'll check that if the lm list so first let's draw it here we'll say just and over here i will say image equals to draw i will call this function here with my image here will say stored pass right so now if i try this code out so now what i will just do here is so let's delete this previous main dot py file which i had [Music] let's keep it so now if i run this so now you will be able to see this and now actually i have in the wrong files so now here i have it so now here you should be able to see something like this so actually i am writing the wrong code which i have so the file so what i will just do is delete this file [Music] and what i will just do is rename this into the main dot py i will save this code and now if i try out so this file is me and now you should be so here we get an error cannot import the problem here was i was importing the store one from my previous one so here i will change this name itself to store and now if i try it now it should not be getting that error so here i get here an error for this i have to say here dot keyboard okay and now if i try this to work and to press enter we need to see so now you will be able to see now we have these keys drawing now if i close this right so to make the main functionality here what i'll just do is come over here and i will just say here if lm list is not planned then only what you can just do come over here and inside this kit you want in the stored wireless and just what i will just do is check here my here let's define our x and y force [Music] and here also let's define our width and height as bar dot size right and here what i will just do is running and if condition if the x is less than greater than sign and then list so the so the pointing finger which we have here i will say eighth finger as the index here will say zero and here we see greater than less than sign x plus one and so here tells us to y less than greater than l m list and he also will say eighth element and here is zero and what i'm just saying is less than greater than x plus height actually he will be writing it means we are checking that we are on that rectangle so if i bring my index finger on that rectangle then what i will do is show that i am on that i am pointing at that rectangle so here also what i will say is rectangle and here we will see image and here is a x and y and x plus fifth then five plus height and here what i will just do it's say here plus five so here's a plus five plus 5 and he also say minus 5 and he also say minus 5 and here what i will just do is show the color as red and this time the thickness will be as filled and what i will just do is see how to get the length so to get the length here we'll define my x1 and the y1 as lm list eighth element and here we'll define my x x two and y two as my lm list lm list 12th element to calculate the distance what i will just do is use my math dot high pot and inside this math dot hypot what i will just do we need to specify two arguments x 2 minus x 1 and here we'll say minus 30 and similarly here we'll say y 2 minus y1 minus 30 so we will get the distance between those fourth finger will say print l and here we'll add the condition for the when clicked so first let's check our popular proper distance i will save it and there we go so now let's check it what we have yes so whenever i click this [Music] so here we have an if you're okay now yes [Music] right so whenever i click so it's being a 63 so it's less so it's i'll just come over here and say here if not let me just close this right so here i will say if not and here what i will just do is say here if not the l here will say greater than less than 63 and means it's clicked and when i click what i have to do let's see here so here i will use my pi input we will say keyboard [Music] equals to so here we'll say say controller and what i will just do is come over here and here we'll see keyboard dot press and here what i will just do also draw that rectangle when i press i will also draw that rectangle in the color of being so now we have almost made this project what i will just do in the keyboard.press here will say bar dot text and here if you want to press enter you can use if condition and say here from my input dot keyboard you can import the key and here you can say key dot enter so i will just go with this and just below it i will use my time dot sleeve at last and here we'll sleep it for 0.15 seconds as the flow right so now we have made this so let's test it out i will open it i will just open my notepad right over there and now let's try this out so let's give it a try [Music] you
Info
Channel: Techno kidzo
Views: 2,161
Rating: undefined out of 5
Keywords: virtual keyboard opencv python, virtual keyboard using python and opencv, ai virtual keyboard using opencv, virtual keyboard using opencv ai virtual keyboard, virtual keyboard hindi, ai virtual keyboard using python, How to Make AI Virtual Keyboard In OpenCv Python, How to Make Virtual Keyboard In OpenCv Python, How to Make AI Virtual Keyboard In CV2, Opencv, cv2, cv, Computer Vission, Computer Vission 2022
Id: ji5Ec3MLRrM
Channel Id: undefined
Length: 18min 41sec (1121 seconds)
Published: Sun Feb 20 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.