Aruco Markers Detection Python OpenCV | Easiest Method | Computer Vision

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there guys welcome back to my channel introduce you we will make an aruka marker detection program so in this there are some models required so those are cv2 and there is one more module which is opencv corn trip but if we do it from pip it had some problems so do this from this command and just go to the end of it and just remove the three okay and just try this command out okay and then i have some more fixes these commands just run it over here yes and just save this okay so now we are ready to go with the tutorial so these are some basic models that we required if you run this it gives no error so the solution that we applied was for this module but the problem is it not gets updated in ps code so what you have to just do is right click over here say they will in file explorer close the vs code and again say open with vsco okay so now it should have no problems guys it will just give one warning message or something like that but it will not have any problems okay so next thing that we need to do is create and simple video captures and those are stuff okay camera index if you're using your main camera specify here zero if you want to use your second camera specified button okay in this while loop specify underscore comma image means we will get our image means we are accessing every frame by frame in the video capture and this is real time guys okay it works fine on cpu also and right over here say here weight key brackets one if that is equals to one and three means q then break it and i will call here and i am sure method okay window name will be img and img and i will create here and variable called video cap and by default it will be as false but let's run this code okay so it should show the video means the webcam okay let's see that it works or not guys so again it's a bit slow down because of recording so you can see my webcam live capture if i just press q it exits okay so next thing that we want to check that if the user wants not to use video capture either then he wants to work with images so i have here two images to work with and i will just place it in an if loop if let's say here video cap not video capture video cap okay means if the it's that condition is true then do that else what you can just do is uh you can create an image as i am read okay it's an billion function in cv2 i indeed for that you don't have to install the concrete library don't worry about it and right over here first i will go with one dot png then we will see two dot png okay show you two dot pngs this and one notes png is and basic arrow markers image and some image just are also a bit rotated okay then after doing this if we run this now it will show the image okay i believe it will show the image okay here we go so as you can see it shows us the image but the same problem you have that the image is too big okay in that case i'll just write the code and two lines and i will just say image equals to cv2 dot resize in that function you have to give the image and the d size 0 dot 0 and 0 means if you want to increase that then you can specify the width and height for resizing but i will use the f x and f y right now means i want to uh scale it from an ratio value okay zero point will be perfect 0.5 okay so again it should be scaled down check it out okay so now here we go so we have our arugula markers image right over here if i press q it exits and next thing right over here what you want to do let's resize it now also let's try seven it will work fine okay now let's go to the next thing for let's create and function for the processing okay so i will say find arrow i will just create an function and for that i will need an image and let's take marker size also and by default let's keep it at six because the default values in marker size is always six and let's keep total markers i think uh 250 will be enough okay and next thing is we will also draw the markers by default it will be true okay inside this function what i want to do is i want to convert my image to gray because we always need it in programs like this to process the image okay source will be the image so this is my source and the color code will be color underscore pgr to uh grey yeah so this will convert the image to the grey guys next thing is to get an arrow code dictionary i'll just call it arrow code dict as and short form okay and in that i want to say aruco dot so the argument was dictionary dictionary okay dictionary and it was get so this was the function in the arukko means and the argument was there was something called aruku okay yes aruppo dot in that it was okay and it was underscore six by six and then it takes the total markers means in our case it's 250 so what we want to do is specify it by these values okay and i'm not specifying 2 because arugula marker is and square okay indirectly so that's why i'm getting one so for that it's one function called get attribute so in that what we will do it's considered arrow either variable and the dot dictionary text that all we are getting as and string and it will give us the final function or the statement that we want okay in the get attribute so the first thing is the aruku [Music] and then the means first one is object object is arupo and then there will be an string okay and then the string will be an f string of dict okay and underscore for f string we use these curly bracket and in the underscore here we'll specify the marker size i'll just copy this and here comes the x and then again the marker size and then it comes the total markers okay next thing after getting the text we have to store it in variable let's call it key so this will be our key and we will get the dictionary as the key okay so far so good next thing is to get the parameters okay and in this variable i will say a row code dot detector parameters detect parameters underscore create okay and after that we have to just get the bounding box and our ids and next element is it's rejected or not that i will skip means as an underscore will specify because i don't need it guys those things you didn't don't need it you can just specify other underscore okay i will say here aruco dot detect detect marcos aruco dot detect markers in that the arguments are the grey image that's why we convert a grey image and then uh the dictionary dictionary and then the next thing will be the parameters parameters parameters equals to here i will say the parameters are aruco parameters okay so right now i will just print the ids so we will get the arrow marker id there is an specific id for every aruka marker right over here what i will just do is call the function find a rupo in that i will splits by the image and all those things are by default there okay so now it should process the image properly and it will work fine [Music] okay so now what we are doing in short that we are creating and function and resetting it okay so still this image is too huge i think it isn't got resized yeah so right now if i quit this what it's showing is every arugula marker id okay means every arugula marker has a specific id okay so what i will just do the next thing is also draw the arupa marker means if the user wants to draw then i will draw the arrow markers we say dot draw markers this is a simple statement i will write on the image and bounding box that we need and next thing i will return that to the user i'll return my bounding box and the ids okay and i will also store it right over here bounding box and ids and if you want to use this function anywhere else then you can use it let's go okay i think let's try 0.4 i don't know how it will be you can just mess with mess up with those values if you want to rescale okay so so now the just we need is our final result okay okay draw markers the normal argument called draw markers oh yeah yeah those draw detector markers my bad now it should give no error in this if we see okay it's taking a bit of time so again it shows oh sorry i just i just placed it wrong i have to just place it over here yeah now i do have nowhere okay again it's taking time because we are doing this on cpu and okay here we go so right over here this image is perfectly scaled and best thing in this that you can see the squares at the corners means that's the start point and means these all are normal arugula markers these four and these two our arugula markers are rotated guys so if i close this and if i open my second image this one okay let's try it out on the second image means i have taken that image on a paper guys if you want to do it with the webcam just change this to true as we did before guys okay so it's too small right now what i'll just do just comment the statement out now it will be not that much small but it works fine just check it out guys okay again it's taking some time yeah so now you can see that it works fine on paper also and it also gives more accuracy on paper so you can see that it works if you want to do this on webcam as i told before just simply change it to true means just change it to the true then it will work so thanks for watching guys
Info
Channel: Techno kidzo
Views: 11,728
Rating: undefined out of 5
Keywords: aruco detection, aruco detect ros, aruco detection opencv, aruco detection opencv python, aruco detector parameters, aruco detect ros tutorial, aruco detectmarkers parameters, detecting aruco markers with opencv and python, detect aruco marker python, aruco marker detection python, aruco marker detection, aruco marker detection opencv python, aruco, markers, aruco markers, aruco detection python, aruco detection python cv2, aruco detection python opencv, aruco detection cv2
Id: AQXLC2Btag4
Channel Id: undefined
Length: 16min 24sec (984 seconds)
Published: Sat Dec 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.