Inspiration
Growing up my friends always talked down on my handwriting. While trying to improve I went down the rabbit hole of Graphology. Seeing this amazing community I was inspired to shine a light on it by making a tool that always newcomers to see the basics of Graphology and hopefully fell in love with it as well.
What it does
This python application takes a picture of someone's handwriting and informs them the graphological interpretation of how they write. This program reads the user’s handwriting and tells the users how they can improve on different aspects of their handwriting like the pressure, the angle of the letters, how they write with respect to a baseline etc. Once the user’s handwriting is analyzed, the program also displays various personality aspects that one can infer from the user’s handwriting. These personality interpretations are based on graphological studies.
How I built it
After receiving the image with OpenCV, we pre-process it with the functions from OpenCV to crop, gray scale, blur/smooth and find the edges of the image. Then we find the contours of the image and then clean up the data by removing contours whose bounding box overlapped another and was deemed lower in priority by the contour hierarchy. Then we sort the list to have the left most contour to be the first contour in the list. To find the baseline we take the first contour's bound box and gets its key values of x-position, y-position, width and height. Then going through all of the contours to find the right most contour that is near the same height as the first contour. With the right most contour we can create the baseline from the first contour to the right most contour to help visualize the concept. Going through the list of contours we can find the deviations from the each contour to the baseline. Since the top left corner is 0,0 and we are doing the first contour - current contour, the average will be positive if the word is going in the upwards direction. If the average is negative than it is going in the downwards direction due to the same logic. To find the slant of the word we make a rotated bounding box around each letter and take the four points of the box. We found the side that connects the left most point and the top point by doing the distance formula and then we do the same for the side that connects the left most point and the bottom point. If the side that connects the left most point and bottom point is greater than the side that connects the left most point and the bottom point that means the letter is right slanted and for the left slanted the opposite is true. We have a counter to see the number of letter slanted in each direction and the direction with the most slanted letters is the way the word is slanted. We are able to determine the margin of the text by comparing the position and dimension value of a boundary box around all the text relative to the image. For zoning, we are able to determine the zone of each character by using the same baseline for each character and the centerline of the first character as the top boundary for the rest of the sentence. If the top of the character's boundary box is above the top boundary then it is considered an upper zone character. If the bottom of the character's boundary box is below the bottom boundary then it is considered a bottom zone character. If none of that is met then the character is in the middle zone. This means that the first character in the sentence needs to be a capital. We are also able to determine the pressure of the handwriting by using the average amount of black pixels for different thresholds. Then the average amount of black pixels is compared to a certain value to determine if the handwritten text is either low or high pressure. Once we classify the handwriting into the 5 different graphology categories. We display different aspects of the user’s handwriting in addition to stating the relevant personality traits of the user based on graphological studies.
Challenges I ran into
Not knowing OpenCV created a bunch of our challenges. The first major one was getting the bounding box around each letter and not have the boxes overlap. The contour list that the result from OpenCV's function findContour is not in order causing various problems which was fixed after sorting the list. The contour list is also made of tuples which also ridded our code with bugs in the early stages. Another major issue was the concept of Contours since we couldn't understand what it is and how it is used to find text in images.
Accomplishments that I'm proud of
Getting the first bounding box was the highlight o the day. It was smooth sailing after that. Getting one bounding box per letter was another key moment that we were proud of. Visualizing the baseline was another moment we are proud of since it showed our understanding of the bounding box and what a contour is. Finally making the algorithm to find if the letter is slanted was a lot of fun and we are proud of it.
What I learned
We learned a lot about OpenCV and python. Our basic understanding of Graphology was pushed to its limit as well.
What's next for Handwriting Analyzer
This program can be further perfected by analyzing other aspects of graphology like spacing between words, and the size of the handwriting. In the beginning of the project, we prioritized important aspects of handwriting and we were not able to get to the aspects mentioned above. In addition to the above tasks we can implement a machine learning model that would enable us to read the images more efficiently and provide more quantitative scores instead of providing qualitative scores to the participants. Another idea that we had for this project was to enable users to share their scores with their peers and provide a social aspect for the project, thereby encouraging people to improve their handwriting.
Log in or sign up for Devpost to join the conversation.