All right, people.
We are now on to stage two, which is mapping.
Our primary goal for this state is to first convert the maize extractor in the localized state into
some kind of clever symbol map.
The road map for achieving that goal is to simplify our means into pathways and then find interest points
between them.
For this purpose, we create a new file that we name as mapping.
Now, the very first thing that we do inside this farm is perform the necessary inputs.
This includes the CB two
and Numpad.
Then we declare the class that we performed, the actual task of mapping and we name it as bought mapper.
And the very first function that we define inside this class is the and function.
Basically what this function will be doing is simply defining the instance variable that are necessary
for this political class at its initializing state.
So the function that we will be defining here is the.
Boolean variable that basically carries the state of the class or whether the mapping process has been
completed or not.
So because this is basically converting our means to graph, so we name it as graphic file and because
this is the initialized state.
So we said this two fold.
Then we define our second function that we name as graph invite to signify.
I mentioned to the user that this perform the process of converting our mes to a nice looking graph.
Now the stakes in the first argument of self.
And the next argument is extracted means that we can see from the previous stage that is the localising
stage.
And then we simply check the side of this function, whether the graph function has been or the mapping
function has been done or not.
And that can be done by simply calling instance variable of graphing flight.
And if it is not in graph ified or the mapping process has not been completed, then we proceed on to
perform the mapping process.
And the very first thing that we do inside this function is to display to the user the input that we
receive from the previous stage, and that is the extracted means.
Then we perform or simplify our means to get the simplified pathways instead of the complete region
of interest.
And that can be done by using the open CV function of pinning, which is part of X image processing
library.
And we access its kidney function, which takes in a source argument that we provide as extracted means.
Once we provided this this basically upwards of a ten meters or possibly so we named it as ten.
And then once we have this output, we display to the user and then proceed on to the next step and
before moving on, the next thing that we do is to simply first perform our deletion over the spot phase
and then perform turning again.
And the reason we are going to do this is because there can be a lot of interest points when we find
in this particular image.
So you want to simply get a lot less interest points that we might get in this case.
So that can be done by simply deletion and then performing the thing again to simplify our means or
pathways even further.
So we do exactly that by using the morphology, execute to perform the dilation, by using a structural
element and then performing thinning again.
So once we have this simplified thing, we then move on to perform a little bit of cropping.
And the reason are performing cropping because a lot of other things might get on the boundary outside
of the maize, inside the extracted means variable.
And we don't want that.
We only want our maize inside that variable.
So to do that, we are going to crop all the boundaries of our maize.
So to do that, we need a new variable inside that initialization function that is the crop mark.
So we are going to set this to five because we want to remove five pixels all around our maize.
So let's perform the cropping now and that can be done by simply accessing ten variable calling and
cropping the rules by writing itself, not crop amount going all the way to the end end goal and rules.
We're writing ten does zero, which is the rules and subtracting the self or crop mount.
So these are crop cropping for the rules, then we crop for the columns and that can be done the same
way we're writing Crop Mount Ten.
That ship one which is the columns and then subtracting the crop mount to crop out the column on both
sides.
So basically our ten.
Variable has been cropped on all sides by five pixels.
So we named this new variable as ten cropped.
So once we have this up, we can then display this thin crop thin and crop pathways to the user by overlaying
it over the original extracted myth.
So we need to also perform the cropping over the extracted mes so that we could overlay this image over
that one.
Suppose we display this to the user and then perform the overlay.
And the way this works is, is simply cropping our extracted means and then overlaying the tin crop
over our extracted means.
And once we have this information, we can now call the last function that we perform or complete our
mapping.
That is the one function inside this function.
The only thing that we are going to do right now is to extract the interest points from our members.
So let's call that function.
That is the one false the sticks and the only argument of the tin group that we have just received right
now.
So now we need to define this particular function that we perform or extract interest points from our
moves.
Let's define that function.
So we go right over here to find one path and then give it the first argument or so the next argument
of me.
And then the very first thing that we do here is to first create a mes authority.
I have as Ms. is definitely not the means.
So we try and instead of pn.
So once we have the means now correctly, we can then move on to extracting or creating a mes bcr or
a coloured mes.
Now this is necessary to display the interest points that we have found out in this particular function.
So we create that means BGR or Ms. BGR by writing or using the opens in function of convert colour.
So this takes in the source, which is our means.
And for the code I pass in.
Color gray to BGR and this converts or creates our PDR color means.
Now, once I upgraded this, the next step is to simply create a window to display this björkman images
so that can be done by simply writing CV to window.
And then I extract the total number of rows and columns of our mes and this wasn't necessary to simply
loop over all the mes pixels.
And that will be done like mentioning the theory in the form of left or right and then top to bottom.
So we write here for loop.
Rule in range of all the rules or total rules.
So it goes from zero to total rule.
And then we go from column in range of total columns.
And then once we're done with this, we then need to check, identify the probable interest points and
the reason the probable interest points.
And the way that we can find out the probable interest points is by checking the means where it has
a one value or a positive value because that in indicates a pathway that our interest point could be
present.
So we can write it right or find it by writing if missed rule or the current crew and column.
If it is equal to positive value there is to 55, then we are on a probable probable interest point.
So what we need to do to confirm whether this is an interest point or not or not just a part, we need
to find the surrounding pixel intensities.
So what that will be defining will be defining a new function.
Right.
About.
So let's define that function right here.
And there it is.
The gets around fixing intensities.
This takes in the MES and the current column and the control and then gives out the pixel intensities
along with the pathways.
Now to get all the pathways or the number of pathways, we need to convert this mes positive values
from 255 to 1.
So if we have four pathways, then four pixels around our current pixel will have one value and we can
simply sum them up to get the total number of path around the pixel.
So for that purpose, we'll be using a threshold function that takes in the means or the trash we provide
in.
Once any value that is given, then one should get squished to the max value, which is one.
And because we are performing my binary thresholding, so we right here.
THRUSH binary and because threshold provides to our cause and we only one the second we write one.
So this gives me a nice looking move.
So once we have this information, we can then proceed on to extracting the total number of rows and
columns that are present inside.
This means and that can be done by simply writing Miss Dos Sheep zero.
And for the column we write means dodge sheep.
What?
Once we have this information, we proceed on to declare the state variables that basically address
the boundary conditions.
So these are the top row, bottom row, left column and right column.
Whether our pixel is one of these boundary conditions.
So let's check whether the pixel was the boundary condition or not.
And that can be done by simply checking.
If our current show equal equals zero, that indicates that we are on a boundary condition.
There is that we are on the top row.
So we said that true in the same way we addressed other cases and checked whether we are on a boundary
condition or not.
So if our control is the last row and the bottom row should be set to true, if the current column is
the first column in the left column, which after true.
So this is the we are we check whether we are on the boundary condition or not.
Now that we know whether we are on the board, recognition or not mean to address these cases.
So let's address the corner cases.
That is if.
If we are on the top row or the left column.
Oh, the left column.
Then what we need to do.
We can.
We can see now that the top left can simply not be accessed.
So we need to give it a default value of zero.
Otherwise, if that's not the case, we can access the top left value by simply writing the maze and
giving it the current row minus one for the top and current column, minus one for the left.
And the same way we address the rest of the cases.
All right.
Once we address these cases, we need to address the lost cases that are not part of the court cases,
but the general cases.
So, for example, if we are on the top row, if we are the top on the top row, then definitely anything
that is above our pixel cannot be accessed because we are already on the top.
The top will be set to zero.
Else the top can be accessed by simply writing means.
Right in Crunchyroll minus one fixed at the top and the same column or the current column in the same
way we address other cases there is.
Computing the right bottom.
And look, once we are done with this information, we can then proceed on to finding out the total
number of pathways around the current pixel.
So that can be done by simply adding all the positive surrounding fixed line densities that are all
one.
So if we have two pathways, then we have two surrounding pixel that have both intensity of what.
So if we have a number of part there is good in a do I want it to display to the user.
But simply debug whether we are doing this correctly or not.
And then we return everything that we computed.
Once we're done with this, we can then proceed on.
Right before what we were doing inside our one pass function.
So we can call this function of good, strong pixel intensities and get all the following output.
Once we have this output, we need to check whether our parts.
Ah, of a specific number or not.
But before that, one thing that we need to check is whether we are on the start point or an end point
start point representing the MIS entry on the end point, representing the music.
So first we need to find these points and that can be found by simply writing if row row equal to zero
or row equal to.
Rose minus one.
Rules minus one or.
Call them equal equals zero or.
Going.
Equals equals two columns minus one.
All right.
So inside this condition, if such a condition occurs, we checked, we are sure that it's either a
start point or end point.
Now we need to find whether this is a start point or not.
So if they're equal, equal to zero, and this is a start point and we need to give it a distinct color
inside the BGR.
So the user could see it or identify it.
So that can be done by simply providing the row in column for the BGR and then giving it a color of
orange so that we could identify that this is the stock.
Now, once I have done this, I need to address the other case that is and so earn or make exit.
So if such a case occurs, I give it a distinct color.
I give it a distinct colour of green so that the user could identify that this is the music.
Now we need to display this to the user by simply writing I am show means ingress point.
Now, once we have addressed the start and end point, we have found a our major address, other cases
where the pathways are the one, two, three or four.
So if the pathways is one, that means only one path leads up to our interest point.
That means that interest point is a dead end.
So let's address that condition.
So if the path is equal to equal to one, that means it is a dead end.
And we simply give it a distinct colour in the state.
We use it the same way we address the case for whether we are doing or not.
So what it's doing, we have a slightly different case because if the parts are to a number, then it
could be either undoing or either a state.
But so we want to omit all state parts and only key interest points.
That is a done so we check there using this condition and this gives us only the tones and it's the
straight path.
So we give it a nice looking blue on the straight or the tones, and then we address the last four two
conditions.
That is, if it is either a three junction or a four junction and we give them distinct colour.
Show them to the user.
And this completes.
Our one fast algorithm for finding the interest points.
And now we can simply run this and see whether we have implemented this correctly and completed the
first two tasks of simplifying our MES and then finding the interest points or not.
So let's do that.
Now that we have completed board mapping up until finding the interest points, we need to run it to
see whether it is doing its job or not.
But before that, a few things.
One I missed out the declaration of draw interest points, a boolean variable there to draw interest
points once they have been detected.
And we said this to false.
And second, we come out of one box calling of the one algorithm.
For the moment, then we had to work with the myth solver after we imported the bot locus.
Either we invoke the bot mapper from the Borton mapping file, so we input more mapper and then we head
over to the initialization function.
The main solver class we after we have created object for what?
Localized.
We create the bot mapper object.
So once we have done this and move over to the missile and function after we have localized our robot,
we now perform the mapping by calling bot mapper.
And then graphic fire and passing and.
The self-doubt, both localised.
Localize the.
Don't miss occupancy as the expected miss.
This completes the calling process of the mapping module and now we can simply head over to the terminal
when the project.
We launched a simulation.
As soon as a simulation starts up, we will run our Ms. solver.
So as you can see, the main server has started up.
This is the base occupancy that we started from the localized stage and then for press enter and as
you can see starting from the extracted maze, this was the input that we see in the mapping module.
This is the extracted means that we receive from the localizing state and then we perform pinning on
it which to reduce this region of interest into pathways.
Once we have simplified it to part ways, we simplify it even further by performing dilation and then
performing pinning again.
So we get tuning twice.
So this has simplified our process to even further.
And then we process and then we get crop out outside of the maze to remove all the extra boundary that
was just not required.
This gives us the ten crop.
And then finally we overlay this pathway that we have computed or extracted from the maze over the extracted
maze.
And this is the final output that you got up until this moment.
As you can see, this yellow marking represents the pathways that we have computed from our extracted
maze.
Now, to test out the one path algorithm of finding the interest points we head over.
To our school where I have created a desk mapping of sorts, a pest mapping file of sorts that is used
to test the one fast algorithm.
And the way this works is it simply imposed a new means.
And this means is a tiny maze.
And it being tiny helps us to easily identify whether our interest points have been correctly identified
or not.
So I imploded and then passing this tiny image through the OnePlus algorithm.
And if I run it.
Once it starts up, you'll see that this is our myth.
So this is very simple.
And you can easily identify that the top pixel is easily the stock on the bottom is the lower pixel
is easily the end point of them.
Is this the left edge is basically the dead end because only one part is leading up to it.
So if I press enter, you will see interest points that have been detected in the phone colors.
So if you remember we said the orange for start point.
So it has been correctly identified green for End Point.
That is also correct.
And the red is a dead end.
So you can see only one pixel is leading up to this one.
One part is leading up to this interest point.
So this is a dead end.
And the same way, if you look at the dark blue color which represents does so as you can see, these
three pixels make 90 degree angle with each other.
So in the utterance, because only two pathways are leading up to it and purple represents a four junction,
one, two, three, four.
So by this tiny image, easily able to identify that our interest points have been correctly identified.
Now let's move over to our main.
To our men, both mapping and then onwards we are terminal.
We have simulation run.
Build this particular project once more.
But if we're building that project, we uncomment out the one false algorithm.
And also said the interest points to true so that we can now draw the interest points so the user can
see that.
So.
We build this again?
And once this is done, we run the over.
And this time, once we get them, is occupancy grade from the local ocean state.
You press enter and you will see that we have a new output after the pathways being overlaid over the
inmates.
This new output is the main interest points, the interest point that have been identified in our midst.
And as you can see, this red circle represents the dead ends and the three number in our maze, and
they have been correctly identified.
As you can see, only one path is leading up to them.
So if you look at right here, this is what the deadline might look like for this last case.
And as you can see, only the red right pixel is leading up to this pixel.
So this is a dead end under the hood.
And as it can see, this pink triangle represents a three junction and three junction, a three paths
leading up to it.
And this blue rectangle represents a four junction.
The this full path leading up to it.
So in this way, we have confirmed that our.
What mapping process up until finding the interest points is indeed working correctly.
This means now we need to create a graph class to store all the interest points that we are just one.
So let's go do the.