For Winter School Projects Contains documenation for the Projects.
The variables and parameters for the loop are defined. Using video capture, an video is read. 'subtract' is used to create a background subtraction object to use later for backk=ground subtraction process. 'structureKernel' is used to create a Kernel for cleaning the image.
using video.read, frames of the video are extracted every iteration
A direct background subtraction method is applied from the OpenCV library. Other functions caught more noise than this method.
Manual background subtraction using frame differences lead to worse quality and bad frames, because in the frames the environment also is changing and it is also captured in addition to the desired object.
A direct cleaning function 'cv.erode' is used to clean the image from the Open CV Library The erode function worked better than other options available.
To detect the edges, Sobel Filters were used first. The Sobel Filters were less accurate.
For more accuracy, Schurr Filters were used to detect the edges. 'cv.Schurr' inbuilt function is used to calculate the derivatives along the x-axis and the y-axis. After, the derivatives are added with the weighted formula to get the edges.
Observation : The Schurr Filter does not detect edges as accurate as the Canny Edge Detector.
Note : The above code is able to detect and draw lines with the inbuilt Hough Transform functions.
A separate function for the Hough Transform
All the paramters and the variables are defined. Here (rho = xsin(theta) + ycos(theta))
'diagonal' is defined to get the limits for the values of rho in the hough space. 'theta', 'rho' are defined to create a certain thershold for the respective values.
Now the entire image space dimension is divided into smaller cells. (So that the lines can vote for individual cells, which would yield points through which the line passes in the image.)
In the print statement for the edges, 'NoneType' edges are also detected by the Schurr Filter. To bypass this, before the loop the edges with values are considered.
Now to check for lines, Iterating through all the edges and then plotting the edges in the parametric Hough Space and voting to get the correct cell. and returning the lines.
(The Hough Space detect function has some error to be debugged due to which it is not able to return the lines. There is a index out of range error on running the Hough Space function.)
Alternative that was tried, was to draw best fit lines for the edges in the region of the object but with the inaccuracy of the edge detection and other noises did not work.
Features/Parts not working or not added.
- Hough Space function
- If the inbuilt functions are added, the edges of the object and the line(two in total) are drawn, taking the average of these two lines and marking the medial axis is not in the code. The average method would also not work with Hough Space because the order or the edges cannot be known without printing them out.
References : [https://docs.opencv.org/3.4/d4/d86/group__imgproc__filter.html]
The code includes classes to define the RRT algorithm and the Tree data structure used here.
class implementation : [https://stackoverflow.com/questions/30258788/class-attributes-and-their-initialization]
It includes an implementation of a Tree data structure In this case, a tree node would have a x-coordinate and a y-coordinate and children nodes and parent node(s).
The implementation here did not work for self.par = None Because NoneType cannot have item assignment But online references used the above method and got the results for any class similiar to this structure. Also Tried set_nextnode function(not inbuilt) to set the parent value to the previous node, but wasn't able to read through python documenatations on getting around this error. Alternatively used self.par=[] to assign an empty list and append the nearest node to it. Other Alternatives that I tried were forward referencing in python and using TypeDicts to bypass the error but were not working with the above case. Ref : [https://stackoverflow.com/questions/2482602/a-general-tree-implementation]
It includes the implementation of the RRT Algorithm and its functions
All of the required variables are variables are assigned in the constructor.
The self.nearestNode had similiar issues as self.par hence used an empty list to append the point which is the nearest node.
The function is used to add a sampled point as a child to an node if it is checked that it is in the free space. Also there is a check for the condition that point is the goal itsef.
The parent of the goal node is assigned NoneType even when none value is not used in the code. This leads to discrepancies in the retrace function.
The function is to randomly sample points in the space, but because a basic random function is used it takes more time that it would have taken if a generator biased towards the free space was used. This returns a newly sampled point. Ref : [https://docs.python.org/3.9/library/random.html#module-random]
Works
This function is used move from the nearest_node to the newly sampled point using the step size provided. A boundary condition to check if the extension is out of the image or not.
Works
This function is used to check if there is any obstacle in between the point. By moving with +1 step till self.size, it is check if the extension is on the free space(road), if not then there is a obstacle in between the point and the nearest node and it returns false.
Returns a unit vector along the direction of nearest node to the newly sampled point.
Works
The function is used to find the nearest node to the newly sampled point(returned from the sample function). If there lies a node, where the distance between the node and the sampled point is less than the step size, the node is nearest node to the point is added to nearestNode list. The function is recursively called to check for the child of the root(start) which lies nearest to the sampled point.
Works
Finds the euclidean distance between the point and a node.
Works
Checks if the current point is the goal node or not. Returns boolean value accordingly.
Works
This is function is used to retrace the path by beginning from the goal and moving the goal's parent nodes to reach the root(start) node and everytime it does it adds the point to the path_points list which would be later used to draw the lines on the map. Also used recursively to move along the parents.
Due to the NoneType assignment to the goal.par the function is not able to retrace the path along the nodes. Due to which the lines cannot be drawn.
An image of the map is read and converted into grayscale. A numpy array is defined to plot all the roads on the map.
Loop used to mark all the points with the lowest intensity to be roads/free space on the numpy array. The lowest intensity range is used to mark the roads because the bitwise_not operator assigned the roads from the original with lowest intensities.
Used Matplotlib.pyplot to get the start point and the goal point. Ref : [https://www.w3schools.com/python/matplotlib_pyplot.asp]
Works
The loop is used to implement the RRT Class so that the RRT algorithm is applied onto the map.
Mentioned with the functions which have problems. Summary of the problems :
- The problem with using empty lists or NoneType with the nodes cause problems whenever there is node assignment.
- The sample() function is slow.
- The addchild() function assigns NoneType value to the parent nodes which cause subsequent problems.
- The retrace() function does not work in its entirety.
Video used for reference : [https://www.youtube.com/watch?v=OXikozpLFGo&t=1395s]
The above codes do not work completely, parts of them work.