Hand Distance Measurement with Normal Webcam + Game | OpenCV Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome to my channel in this video we are going to create a game and we are going to find out how to find distance using a single camera so you can see this is my hand and we can detect the distance of your hand from the camera in centimeters using just a single camera so the game ended so here you can see it's giving the distance in centimeters it is quite stable if i stop you can see it's accurate up to 1 uh two centimeters but overall it is accurate up to three four centimeters so it is not very accurate but it is quite good for a lot of different applications so i can go up to one meter if you press the r it actually resets so basically the game is that you have to press this button that where it appears so here i need to press so here the distance is not enough so it is not getting pressed but if i go closer it will get pressed and then the location will change and then i do i need to press it again so here after the game ends you can see it says game over and that is your score and i can press the r button to reset it so again i can go closer and press and then if i keep pressing it will not work because i need to go back i need to press the button and come back so that's how you can use the distance so i need to come back so i need to press enough like that and come back so that's my score five here and i can reset so this is what we are going to learn today there is a little bit of maths involved but i will explain how it works and it's not that complicated you can do it yourself as well and we don't have a very long code it's a few lines of code and we will have this complete game we will do it step by step so first thing we will do is how to find the distance of our hand and then later on we are going to create this game a very simple game it will take a few minutes to actually create so i'm very excited let's go ahead and start building this game so here we are in our pyjama project and you can see that we have named it hand distance so we will go to file settings and we are going to install our packages first so we will go to project hand distance and then the python interpreter and we have to select so we will click on add and here we are going to use the existing environment and we will press ok now you can see we have python 3.7 this is what i'm using if you face any difficulties in the newer versions you can come back to python 3.7 i'm using python 3.7 3.7.6 so here we are going to add the packages we will write cv zone so this package is going to install the computer fusion library opencv and numpy and then we also have to install media pipe so these are the two packages that we need and the rest of them are installed by default so we will not have to install them separately so cv zone is done and we will wait for media pipe so media pipe is right now installing downloading and installing so let's wait for that okay so now media pipe has been installed and we can go ahead and create our project so we will just need one file so we'll just call it main and we will write all of the code here so the first thing we will need are the packages so we will imports let's say cv2 then we will need the hand tracking module so we will import it from cv zone so we will write cv zone dot hand tracking module import detector so this is the idea and then we will need the webcam so we will open up our web webcam this will be cap is equals to cb2 dot video capture and we will put in the value of zero so i have changed my webcam and i'm going to show you now you will see it's a very big difference so we will see that shortly so cap.set we are going to change the size of it so we want it to be 1280 so this is prop id number three which is width and cap dot set prop id number 4 which is height so we'll put it as 720 so this is the basic idea and then we are going to write our loop so here we will call it loop so while true we are going to read success and image is equal to cap dot read and then we are going to display this cb2 dot im show we'll call it image and img and then we will write cv2 dot wait key and we will put one second a one millisecond delay so this should give us our webcam image so let me show you how that looks like right click and run so let's wait for it and there you go so you can see now this is the new camera and let me show you the previous one and you will be amazed how much of a difference does that make so i have it attached to number two and there you go so this is the image that was before i was using the logitech webcam and this is the newer one and wait for it and there you go look at the difference it is insane anyways so moving on what we are going to do we are going to first of all detect the hand and then i will explain how exactly are we going to find the distance so let's write here uh no before that we need to write it we need to find the or declare the hand detector so we will write here hand detector so here we will write detector is equals to a hand detector and we are going to give the detection confidence at 0.8 which means if it's 80 sure then detect it as a hand and the max hands we are going to detect as one we don't want multiple hands otherwise it will just confuse the system and here we are going to get the hands and we will get the image back from our detector dot find hands and we will just send in our image so that should give us the hand and it should give us all the points there you go and there you go so you can see uh the right hand is being detected and it is fine it is actually my right hand this is the left hand it is detecting fine so what exactly do we need to do now we need to find the distance between this point and this point so this point and this point so what are these points there are numbers for these points there is an index number so first of all let's check if the hand is there so we will say that if hands if the hand is present then do something so what is that something we are going to get our hands and we will get the first element of it which means the first hand and because we only have one hand it will always be zero here so we don't need to worry about that so hands at zero then within this we have a lot of different things that we can access the thing that we need is the lm list the landmark list so we will write here lm list and that will give us the list of all the points so lm list is equals to this and if we print that out lm list you will see that we will have all these uh different values so is it on here so if i bring in my hand you can see all these different values over here so here you can see this is a list and i believe they have 21 points and what exactly do we need which point numbers do we need you can check it on the media pipe website so here we have the mediapipe website and you can see we need point number five and point number 17. so these are the two points that we need and we are going to find the distance between these points so let's go ahead and find that so here we can simply say that our first point which is point number five let's call it x1 and y1 and we will write lm list at point number five and the same thing will be here x2 y2 is equals to lm list and we will put in the value of 17. so this will give us these two points now to find the distance the easiest way is to print out the value by saying x1 or let's say x2 minus or which one was first anyways whatever the value is x2 minus x1 and we can do an absolute so we don't get a minus sign so we can write math dot abs and there we go okay math is not declared we need to go up and we need to import math and let's give it a little bit of space and there you go so let's run that okay let's remove the lm list because that will be annoying let's see what the distance is so let's open this up if i bring in my hand and we have an error so there is no absolute really math dot abs so it's not in math it's just abs what about that so let's run that again um there you go so now you are looking at the distance so if i come closer okay the camera is here i've got the placement so if i come closer you can see the distance is increasing if i go backwards the distance is decreasing so based on this value we can estimate how far the object is or how far the hand is in centimeters we will have to do a little bit of conversion i will explain how to do that but the the problem here is that we are just using x so if i rotate you will see the value dramatically changes which should not be the case because the distance here is not changing so the value should not change so what exactly can we do so this is a problem so what we can do okay it's not closing from here let's close it from here okay so right now let me explain what is happening so right now let's say this is my point one and this is my point two this point number five this is point number 17 this is point number five so right now we are just checking the x distance so the distance of the x but what we need to do is we need to find the diagonal distance here if we find that instead of just using the x value then we will consider x and y and this value will always be constant even if you rotate it it is going to be the same so instead of x we need to find the diagonal value and we will use that instead so how can we do this let's go ahead and use our equation it's very simple uh all we have to do is we have to square it and then square and take the square root of the values so basically we will write y2 minus y1 and then we will take the square of it we will square it and then we will add it to x 2 minus x 1 and then we will square it again and all of this we have to take the square root of this so we will write math math dot sqrt and then we will finish the bracket here so this will give us the distance distance is equals to this and now let's print both of these so this is before and this is after so distance and let's um it is yeah it is pixel so we don't have floating values okay so let's run that and now you will see the previous one and the one right now it will be a big difference uh okay we need to push it in it should be in the if statement my bad and i believe the print as well yeah okay so let's run that again what happened here why is everything in the wrong indentation okay so now it is fine let's run that again okay so let's bring in our hand and you can see the distance is pretty much similar but if i rotate you see the distance at the left changes but the distance on the right does not change so it's it's pretty much similar to what we had before so if i go forward backwards both of them change but the left one does not uh changes when i rotate the right one changes a little bit like it's not a big difference so this is how you can solve the rotation problem uh for the distance okay so um we can change this to integer because we don't want floating values so that's good now we have our values for the distance so how exactly are we going to convert it into actual units for centimeters so how can we do that well first of all we need to check what kind of a relationship do we have here so if i decrease the value does it decrease consistently does it change consistently or is it a little bit different than that so let's see so for example if i'm at 20 and the distance is 10 if i go to 40 that's the distance become 20 is it linear or not if it's not lean oh i'm not printing so if it's not linear then we have to use something else so the relationship here is actually not linear so this means that if you keep going back the difference between the values is not constant so how do i know that well what i did was i took out the values of x and y so let me write down here find function so basically we need to find a function that can basically relate x and y so what is x x is the value that we are getting from our distance this is the x and y is the value in centimeters so let me write it down here x is the distance let's say the raw distance and y is the value in centimeters so basically what i did was i put a measuring tape in front of the camera and i put my hand at 20 and then i checked the value it was 300 then i changed it to 25 i moved a little bit back then the value was 245 then i put it at 30 the value was 200 so if you see the difference here it's not consistent so here 300 minus 45 is 55 here then the difference is 45 then the difference is 30 then the difference is lower and lower and lower and lower so it's not really consistent uh it's not that the value is always 50 uh so 300 will become 250 then it will become 200 then 150 then uh 100 and so on it's not like that so this is not really a linear relationship so what can we do we need to find a polynomial function that actually fits this but what exactly is a polynomial function so let's look at it over here so here you can see this is a website's wikiversity and here they have shown the examples of functions uh what do you call the polynomial functions and what degrees do they have so here you can see this is the degree zero this is degree one degree two so we need to see what kind of relationship do we need to actually create our function but before we do that we need to plot this graph we don't know what exactly are the values so how does it look like so what we will do is we will go to canva because it's free to use and we are going to create a graph so here is my graph and i will put in all the values here and then we will see what does the graph look like so here we are going to put in our values so we are going to put the y values here so we will write in 20. i know this is the x column but it doesn't really matter you can put any numbers that you want uh so here we will put 25 this is 30. now we are putting the y values in the x column because they are consistent and canva doesn't use both uh plots this is just a string so that's why we're putting it like this so 35 and 40 then 45 50 55 60 65 70 75 80 85 90 95 and 100 and then here we will put in our values so the first one is 300 then 245 then 200 170 145 130 wait what did i write 130 okay then we have one one two one zero three one one two one zero three and then we have 93 87 80 75 70 67 62 and 59 and 57 so here we can see that this is our plot and clearly it is not a linear graph so it's not just a single line so it's not like this so if you put it like this it will be very wrong so you will not get the accurate values at all so what do we do we use a polynomial function that will give us this curve value so we need to fit in an equation that will be very similar to this so we can use the uh use machine learning for this but that will be too much because this is simply a second order polynomial function if you don't know about polynomial functions you can read it here this is wikiversity so this is a linear function that is the first degree of polynomial function what we need is the quadratic which is uh basically a curve and the curve that changes direction only once but uh we are not using three because here the direction is chained twice so it basically you can tell by the number of pumps so if you have two bumps it is three degrees if you have four bumps uh if you have three bumps it is four degrees and so on so in this case we only need two degrees we can fit in a curve like that so we need to find the equation for this and numpy actually helps us find this and it's very simple so let's go ahead and try that out so there is our code and these are the values that we have received so what we are going to do we are going to write here simply that uh our coefficients of our equation so our equation will be something like this it's a quadratic equation which means we will have x to the power of 2 plus x and then plus a value c and then the coefficients will be a and b and c so this will be our equation y is equals to this so what we need to do let me put it as a comment so what we need to do is we need to find the value of a and the find the value of b and c if we can find this then using this equation whatever x value we are getting when we put here it will give us the value of y which will be in centimeters so this is the relationship that we need so we need to find these coefficients and we can use numpy so we can go here and import numpy as np and then we can write here numpy dots polyfit so polynomial fit the equation with the values of x x and y with second degree uh polynomial function so second degree if you if you had a different graph and it was changing the direction twice then you will write three if it changes four times uh then you will write five for example so here the direction is changed one time so we will write two second order polynomial function so this is basically the idea i will keep this here in case you want to review this and once we get this equation we are only doing this before the while loop because we need to do it only once once we have this then we can use these coefficients and find the value of the x sorry y so here this is distance so distance in centimeters is equals to our coefficients at zero which is uh or let's just do it like this we will write here a b and c is equals to coefficients so here we will write a multiplied by so our equation was this uh a multiplied by x to the power of two so our x is basically distance so distance to the power of two plus b multiplied by distance and then plus c so this is distance in centimeters so let's just print that out so this will be distance in centimeters and this will be distance so let's run that and hopefully it will give us the value in centimeters so there you go right now it's saying 60 which is not bad it's going back it's around 1 meters now when i come closer you can see that the values are changing there you go so now this is not a perfect method and we are just using a single camera so there is a limit to how much accuracy we can get and the size of the hand well on average it will be similar but some people they have bigger hands some have smaller so you can add a little bit of variation you can add a multiplier there or you can do it uh for each one uh separately but definitely adding a multiplier will help so the idea is not to get a very accurate reading from this so this will not be very accurate compared to a 3d webcam so what what we need is just a rough estimate so actually let's keep it there and what we will do is we will print the value of this on our console so not the console on our image so here we can write cv zone dots uh what is happening i think we didn't import yeah so we need to import cv zone and there you go so cv zone dot put text rect so it will add the rectangle and the text both so that's why we are using this we will put image we put it on the image and then we will write an f string here we are going to write the integer in distance centimeters because we don't want the floating values and then we are going to write dash and not here what did i do here we will write centimeters and then we have to give in the values for where do you want to place it so we need the bounding box information of the hand so here we are going to write bounding box is equals to hands at 0 and then we are going to write bounding box here so that will give us the mounting box information um or we could just write x y width and height i think that will be easier to work with so here we can write the x and then the y so this is our starting point and we need to write another bracket to end it so let's run that and see if we get the distance in the right position so um actually i don't want to show all these points so what we can do is we can remove it from here so we can write draw is equals to false and here we are going to remove this image so now it will only display the text but we are going to put the bounding box as well so right now it's showing only the text but we can show the bounding box so where do we want to put it so we can put it at the very end so let's write it here cb2 dot rectangle and we will put in our image and then we will put in the point one which is x and y and then the width and the heights so x plus width and y plus height and then we will put in the color 255 0 and 255 which is purple and then the thickness as let's say a3 so let's run that and there you go um the the number should be a little bit higher and let's print it after the rectangle so it doesn't intervene um what we can do is we can put here let's say a little bit of an offset so it doesn't interfere so x plus 5 let's say and y minus 10 let's say so it goes up a little bit and on the side little bits yeah i think that's fine so you can see now we are getting the value uh in distance in centimeters again this is not extremely accurate but um it is accurate to a good point to a few centimeters so about three four centimeters i believe this is accurate and uh it actually works well even if you rotate you can see it doesn't change the distance a lot a little bit yeah but not a lot so what we can do is we can use this method to actually create a game in which we are pressing buttons so if your hand is closed it means you're pressing and you have to press it in the right region to get it as a detection so this is the game that we are going to build so now we are going to create a game out of this and we are going to press buttons so whenever the hand is closed and it is in the right position we will detect it as a hit and then we will store the points so the first thing we will do let's just copy this and paste it and here we are going to write game let's say so this is our game code and what we will do is we will go down and the first thing we will do is to create our button so this button will appear in different places so we will write here draw button and then oh button and then we are going to write cv2 dot circle and we will give in our image and then uh the location of this point uh the circle is going to keep changing so we are going to create a variable for it so we will write here game variables and we will write cx and cy so the center of the circle so let's just put any value 250 and 250 this is the initial value and later on whenever we hit the button it will change the location so here we will write cx and cy and then we have to give in the radius let's say it is 30 and then the color let's say it is um actually the color needs to change as well when we click on it it should change to green and when we don't it should be purple so let's put a variable here as well so let's call it color and because it will be changing so we have to put it in a variable so color is equals to two five five zero and two five five so this will be purple in the beginning and what else so we need to fill it cb2 dot failed and let's try that so it is not displaying why is that if i bring in my hand still doesn't display why is that i am show and everything oh we are running main we need to run the game now that's why okay so there you go you can see we have the circle um it's not very interesting so what we can do is we can add a little more layers to it so let's just copy this and we are going to create a line inside of it or let's change the color of it and we'll write 255 255 255. let's make it white and this will give it like a target thing yeah if we add one more circle it will look like a target so let's copy that and let's put this at 20 and then let's keep it white and let's change this to let's say two yeah now it's looking better and we can add one more at the end one more we have already copied it so one more at the end same thing but at 30 and let's make it black so 50 50 not very black but uh kind of a shade of gray there we go so this is our target and if it uh if we click on it it is going to change to green so this is the idea and it should change the position as well so and if we are close and if we keep moving this it should not work whenever we press it should work so that is the idea behind this project okay so this is good then uh we need to add the display for the game so i believe it's called head up display or something so we can write here game head up display so what exactly are we going to put here we are going to put here the time and the number of points that we have so here we will write cv zone dot put text rect and we are going to put it on our image and then we are going to put in time so let's just put any value for now let's say it is uh 30 seconds so we can write here time is 30 seconds and then we will give in a location so 1100 and let's say 75 and we will increase the scale scale to 5. so let's run that you go oh that's too big um let's make it um 1000 and let's decrease the scale to 3. hopefully this will be better yeah now it's better and we can also give it an offset offset oh what did i do offset is equals to let's say 10 so it will add some pixels on the top and the bottom uh not enough let's put 20 and yeah now you can see there's a little bit of offset around it and that's good so next thing it's pretty much the same we are going to add the points so for the points let's just change the location and let's make it 100 instead of one thousand and here we are going to say we have points points is equals to or let's say score score is equals to at thirty and let's put four it's basically how many buttons did you press so that will be our yeah score is four times that this is a little a little bit more than this one so let's re decrease this to let's say 60. yeah so that's better okay so that is good and now what we need to do is we need to add the logic so first of all we need to check if we we clicked so how can we check that we will check the distance so we will say here that if actually let's just put it before the drawing if our distance in centimeters is let's say less than 40. so if it's less than 40 centimeters we will declare it as a click so we will write here prints click or let's change the color the color is equals to green 0 2 5 5 and 0. so this will give us the color change so our button will change the color so if i move in there you go it becomes green if i move back it doesn't change because we didn't tell it to change if the color if it goes back because we need to write an else when that happens but again the concept is working if it's less than 40 this will happen but we don't want it to be anywhere when the hand goes in front it should go in front and click on the exact same spot we where we have the circle not anywhere else so how can we do that so right now what we have is we have the cx location of our circle and we have the x and y location of our bounding box so these are the parameters that we have so we need to check uh if our cx our circle is basically in between x and x plus width so if it's in between that then it will detect it as a hit and the same thing we have to do for the y so we will write here c y is should be in between y and uh what do you call y plus with y plus width so y plus height so if you did not understand that let me just draw it here and hopefully that will be better so let's say that this is our hand and then this is our cx and cy so this is our button and this here is our rectangle or the hand so our x and y are here and our x plus width plus width is here and y plus height is here so this is the point so this is x and y so we need to check that if this let's say this point x and y here the x is let's say 10 and here x plus width let's say is 50. so if this point is let's say 30 it means it's inside the box and then for the same thing for the y we need to check if it's in between these two region so let's say the y here is 20 and the y here is 100 so if this value is right now it's in between so let's say it is 30 so then it means it is detected inside so we are basically checking this if that is the case then we are going to detect it as a hit so we can change the color uh we should not have removed that so we can write here color is equals to green 0 2 5 5 and 0. if that is not the case then we can write else color is equals to two five five zero and two five five so it will become purple there you go and let's test it out so if i push in there you go it's green if i go back wait why didn't return what happened there if this is the case then the color is this else the color is this oh sorry it should be else here my bad else for the distance not for this so there you go green if i go back it becomes purple green purple hits no hit so whenever we hit what we want to do we want to change the color so that the person knows that you hit it and then for a few iterations for like one or two iteration we want to keep the color same so that the person can see if we change the color and change the position at the same time the person will not be able to see so we need to delay a little bit and then we change the location but if you delay using time everything will freeze so we don't want that what we want to do is we want to use counter to actually count how many frames have passed by and then based on that we can change the color so here instead of changing these colors we will remove all of this and we will say that if this is the case counter is equals to one it means start the counter so we will go up here in the game variable we will write counter is equals to zero in the beginning counter is zero if uh it has detected a hit counter will become one and here we are going to write if counter is one or if counter has a value other than zero or false then we are going to do something first of all we will do counter plus equals one and then we will check uh then we will change the color to green counter color is equals to zero two five five and zero and then we are going to check if counter is equals to let's say initial value will be 1 then it will become 2 and then at 3 we will change it so for 2 frames the color will be green and then it will change to purple this will be enough for us to see so if counter is equals to 3 then we are going to change the color back to let's say purple so color is equals to 2550255 so let's run that and we need to put the counter back to zero there you go so if we do that now if we go close it becomes green if we go back it becomes purple it's the same thing and that is good so now what we need to do is we need to change the location as well so the location of this uh circle this circle so we just need to change cx and cy and we can give it some random numbers so we can write here cx is equals to a random dot rand integer and we will given the value from let's say 100 to 1000 or let's say 11 000 1100 and the same thing we will do for the y so we will write here c y and we will put in 100 and let's say 600 so 720 is the max so we'll put it at 600 and yeah that should be good so let's check that out so if i click on it boom it changes location if i go down and i press on it changes location so you can see it tells us when it is green so if i don't do that if i put the counter as let's say if counter is equals to one then we will not be able to see okay so my new camera actually is tilted so it's hard for me to do that so i'm going to change the camera to 2 for testing and later on we can try it again with that so here if i put it add green now you can see this is very good because if i keep pressing it will not go to the next one and that is what it should be i need to press and go back when i go back then it should change the position why is it not going back okay something is wrong what is happening uh counter is equals to two okay so here it changes there you go it changes and if i keep it forward it will not work properly there you go it is changing the positions but again it is not working properly it is not showing us the green lights that we want and uh it is not changing the location when it's forward see here now it is correct because if i have my hand forward it should not go to the next one when i go back it should go to the next one see so what i need to do i need to press so let me flip the screen because it's annoying um here we can write image is equals to cv2 dot flip image and we will give the axis 1 so it will flip in the x axis instead of the y so now it should be easy for me to play this game let's see so here we have that there you go press press press press press there you go so if i don't go back it will not detect it so if i put it forward and i keep it forward then it will not detect it you have to go back to reset it because otherwise you will keep your hand like this and you will just go doing this and it you will win the game so it's not really pressing a button it's just sweeping on the floor so yeah now the last thing we need to do we need to add points so here we will write points plus equals one and or let's call it score score plus equals one and at the top we are going to write score is equals to zero and at the bottom we are going to change here we will make it an f string and here we are going to put in the value of a score and sometimes this value uh it will be it will be one two three so it's one digit we always want it to be two digits so we can convert it into integer uh sorry string string and then we can write dot z fill dot z fill why is it not working okay because here is a bracket this should be here okay dot said fill and we will put in the value of two so we always want two digits so if it's one it will put zero one if it's two it will put zero two so let's try that out so if i push yeah there you go one two there you go i need to go back go back go back there you go so i have four points now the time it's not changing so we need to fix that so let's go ahead and check out the time so here we are going to write time start is equals to time dot time did we import time we don't need to okay uh no we do need to i forgot imports time so time.time this is the initial time that we have and then what we will do is that we will say that maybe here we will say that if time dot time minus my initial time time dot start is less than let's say total time then we will play otherwise we will stop so total time is equals to let's say 20 seconds so the game will be played for 20 seconds so we will put all of this in the if statement except yeah except i am sure and then else we will do something else so we can we can pass for now but later on we can add something if we wanted to so and we need to show the final time the remaining time so the remaining time will be the remaining time will be total time total time minus the time dot time so this will be our and we can change it to integer so that we don't have decimal places so let's run that so what is happening there oh sorry i forgot to add a start time so time dot time minus start time starts time start and that should be fine let's just push it down so you can see just push this a little bit here and let's run it again there you go 17 16 15 14. this is our timer so now that we have the time the last thing we need to do we need to show game over and the points that you have earned after the game is over so what we can do is we can put this text rect and here we are going to first of all write game over game over and it doesn't need to be an f string then we can put it at 400 and 400 we will give the scale of 5 and the offset as let's say 30 and the thickness has let's say 7. so let's run that and actually let's put the game time to be two seconds so that it quickly goes there we don't have to wait for it to go to the next screen so there you go game over and that's pretty good and then we are going to go back and here we are going to copy this and we are going to push it down a little bit and write our points so this will be an f string and we will write here your points are basically a string so we will write here that we have points or let's call it score actually i'm confusing between scoring points score so score we have to convert it into something right now what is the score yeah actually we can just put it here and yeah that should be fine and then we can given the value of let's say 425 and then 500 and do we need to change anything else uh yeah let's change the scale to 3 and the offset to 20. the thickness we will keep it by default yeah better so we need to push it a little bit further so that it can display or we can write here your score and hopefully it will center kind of we can push it a little bit forward so let's say 50. yeah that's fine and the last thing we can do is we can add the button of resetting so here we will store this value as key key is equals to this and then we will write if key is equals to ord let's say r if you press the r button on the keyboard then we need to reset the game so if that is the case we will say time dot star time starts is equals to time dot time and then we will say that our score score is equals to zero and yeah that's pretty much it and we can also write that information here we can write press r to restart and we can write here this at 460 a little bit forward this 475 this as 2 and this as 10. this does not need to be an f string yeah press r to restart so if i press the r button you can see it starts again and then game over again again there you go so this is good and what else do we need yeah just we will replace the time to let's say 20 seconds and now we can actually play this game so let's see how much i score so there you go i will press the buttons as we go along again you have to go back otherwise it will not detect it as a hit you have to press the button quickly there you go oh there you go push yo my score was 12 so i can press the r button and it will reset so i i can play it again and that's how we can make this game so actually let's try it with the better camera as well so how does it work i think i can do better this time where is it oh i couldn't see it oh yes i did 16. so let's try it with the better camera let's go down here because it's not centered that's why it's a little bit harder to play i will i will move try to center from here and let's see so if i click there here so this is the issue because i have to see a little bit tilted there you go there you go yeah it is hard to play like this yeah i can only score six let's try one more time hopefully let me put it a little bit straight i will move the mic and let's try now there you go there you go no and right on the mic it's hard to do that anyway so i'm hoping that you got the idea and it is fun to play and if you add music and other elements to it animation as well it will be much much better so all of this we are going to teach in our game development course that will be released very soon so if you haven't checked it out check it in the description section below and if it seems interesting to you go ahead and enroll and i will see you in that course so hopefully this video was fun for you i hope you have learned something new if you did subscribe share it with your friends like the video and i will see you in the next one
Info
Channel: Murtaza's Workshop - Robotics and AI
Views: 9,727
Rating: undefined out of 5
Keywords:
Id: NGQgRH2_kq8
Channel Id: undefined
Length: 60min 9sec (3609 seconds)
Published: Sun Dec 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.