Image Processor - foolofato0k/Robo-Studio2 GitHub Wiki
Summery and Scope
This subsystem is responsible for processing selfies taken by the user from the GUI, detecting the face and generating outlines of the key facial features for the UR3 to draw.
Scope
- To create the wanted poster, the subsystem only detects one face at a time.
- Though the edge detection is able to pick up detail such as wrinkles and accessories, generating edges of the key facial features is prioritised to make sure the face is recognizable and reduce computaional load.
Challenges and Future Improvements
- Reducing noise while also retaining the features that make a face distinguishable is a big challenge.
- Background noise interferes with the face detection and adds unwanted noise to the image. Implementing a background removal solution would allow us to reduce some of the thresholds of face detection to pick up faces at different angles and in the future, multiple faces.
- The edge detection algorithm is sensitive to complicated lighting, as it uses variations in the intensities of the pixels to detect edges.
Subsystem Architecture
The image processor is library of functions that detect, clean and process a face from the obtained image. Being a library makes it modular and allows us to track where any issues with the overall processor come from, as well as allow the implementation with the rest of the project to be flexible, i.e. can leave out certain steps for initial tests and optimise them later as we did with the create canvas function.
Structure
detectFaceEdges(image)
This section uses Haar-Cascades with a pretrained frontal face detection model and Canny Edge Dectection to detect the face and to convert it to edges.
After detection this function calls reduceNoise and createCanvas respectively.
groupEdges(image)
This is a helper function that uses Connected Components, a labeling alogrithm that groups edge points that connected. This allows us to look at the features of the face independent to eachother as seen in the image below. It returns an array of masks for each feature as well as the number of detected features.
This function is used by reduceNoise and getPaths, the output image it from getPaths. This tutorial provides a better example for connectedComponenets in action.
reduceNoise(image)
This function passes the edge image to the groupEdges function to obtain the individual detected features in a list. It then adds them to a cleaned image, ignoring any groups that have less than 40 edge points in order to reduce the number of unwanted features. Through experimenting with other methods we found that they reduced alot of the detail of the facial features as such we decided to use a Morphological Transformation to combine smaller noisy points with nearby edges.
createPoster(image)
This function takes the processed image, creates a canvas based on the image size and adds text. During testing this functionality was removed to reduce computational load.
getPaths(image)
This function converts the edges to vector paths in carteisan form that can be used for path planning. This is done by first grouping the detected detected features using groupEdges and then converting them to individual paths through PyPotrace. This is the final output that this provided to the path planner.