Handwritten capital letter recognition based on OpenCV

. Handwriting capitalization recognition is a function of distinguishing handwritten capital letters by means of machine or computer intelligence, which is classified into the field of optical character recognition. Given that capital letters are widely used around the world, identification and analysis are often used as the main components of some control systems. Therefore, the research on handwritten capital letter recognition is also very practical and has important practical significance. The key part of the research contained in this paper is the image preprocessing and the optimal selection of feature vectors, and finally completes the design of handwritten digit recognition system. In this paper, the Fourier and Bayesian commonly used are compared, and eventually the Fourier transform feature is applied to the system classification identification. After completing the test on the relevant experimental data, the results show that the handwritten capital recognition system established in this paper has a high recognition accuracy for handwritten capital letters after repeated training.


Subject background and significance
Due to the prevalence of information technology in daily life, the application of computer networks is constantly evolving. In the actual production life, there are handwriting functions on mobile phones and computers, which involves the identification of handwritten capital letters.
Optical Character Recognition Technology (OCR) (optical character recognition) has the intelligent function of using computer to send information on paper in a short period, using relevant software systems to convert information into text application technology, and can this text is adjusted [1]. Handwriting recognition has always been a hot research direction, and data collection, processing and screening are all dependent on this technology.

Research status
Dausheck International patented optical recognition technology in the early 19th century. For nearly a century, we have seen the results of today's research. OCR has become the most promising research project in all kinds of identification categories in the 21st century. One. The technology has the advantages of image processing, computer graphics and artificial intelligence, and then enters the electronics field and is promoted. Through years of continuous improvement, relatively mature OCR products have flooded into people's lives.

The main research content and arrangement of the paper
The environment designed in this paper is VC platform, which recognizes the handwritten English letters connected to the machine. The functions of all systems include mouse movement track reading, mouse movement track data discrete processing, track isometric feature data reading, and track external maximum quadrilateral. Obtain, de-dimensionalize the data (so that the feature data is independent of its size), obtain five key harmonic data of the Fourier transform , and adopt several techniques such as random tree type identification and estimation.

Visual2010
Microsoft Visual Studio 2010 is the best version of the VS system product IDE enhancement, developed by Microsoft Corporation, is the only IDE that supports the .NET Framework 4.0 development path. VS 2010 is a multi-view development that includes code editors, compilers/interpreters, debugging tools, and installation package building tools. Currently, Windows code is basically developed by it, and its relationship with the .NET Framework is shown in

MFC Introduction
MFC, the Microsoft Foundation Class (Microsoft Foundation Class), both output the VCL application structure with Microsoft's Visual C++ development platform. This system library has released a list of development libraries that can be widely used.
MFC is actually derived from the structure and startup part of Microsoft's C++ platforming software, MFC is attached to a development tool library in a supporting software, such as MFC's VC++ key location (note C++ and VC++) The difference: C + + belongs to a programming language, which helps humans understand the development of software. VC + + belongs to the compiler or compiler + IDE source code editor [2].
In the underlying operations, the use of MFC is very simple, in the combination with the Windows API or the driver can use the original program of the API function, and the driver API and data are both based on the C language, allowing VC R&D engineers make it easy to use Windows API.

Feasibility study
The workbench of the billing machine should use a PC with P4 or higher. In terms of personnel, it is required to be able to operate software development tools and perform tasks associated with the system.
Programming language and development tools:  Programming language:C++  Development tools:Microsoft Visual C++2010、etc. With Windows and VC++ development, the price is relatively cheap and can be developed at low cost.If there is a problem, people can solve it by means of information related to computer hardware software.There are many control elements inside Microsoft Visual C++2010, which can write a large number of programs, which can shorten the development process time.With the above points, we can conclude that the research of the data set conversion device can be realized.

Development design ideas
 This software can adapt to a wide range of computer configuration environments and is inexpensive.  The system should match the goals of the data conversion to meet its final needs.  To achieve standards that are easy to develop, easy to expand, and easy to maintain.

Functional requirements analysis
The template matching method identifies the handwritten uppercase English letters, which is determined according to the design steps of the system. This design is completed on the VC development platform, and the handwritten English letters connected to the machine are recognized. The functions of all the systems include mouse movement track reading, mouse movement track data discrete processing, track isometric feature data reading, and track external connection maximum. Quadrilateral acquisition, data de-dimensionalization (making feature data independent of its size), obtaining five key harmonic data of Fourier transform of feature data, adopting random tree type identification estimation, etc. technical part. Performance requirements:  Correctness: The system must show the steps of the entire process.  Accuracy: Recognition has a high degree of accuracy.  Efficiency: When the input of data is large, the efficiency of processing should be guaranteed.

Overall system design 4.1 System overall functional module design
The overall module is shown in   Hardware interface Includes previous keyboard, mouse, and monitor interfaces for input and output. An interface that interworks with the printer to help print related resources and lists. The purpose is also the output.

Internal interface
The internal interface part borrows function calls, parameter passing, and return values to interact with data between different parts. The data structure design section below will describe the structure of each data in detail. After the data is encapsulated by the data structure, it is passed to different modules in the form of the return value or parameter transfer, and this is sent as a connection part [3].

Principle of code design
 Uncertainty: Each entity or feature is rendered by a specific code.  Standardization: Because each information module unit can basically be consistent with global practices and national unit interests.
 Versatility: Use the original code and facilitate the gradual promotion of the program.  Simplicity: Do not affect the coding and scalable coding position, as far as possible with easy to understand features.

System code design
The function of the code: making it convenient and effective to save, detect and find data and input information to the information system; the efficiency and accuracy of computer execution have been greatly increased due to the existence of the program; the comprehensive and unified information has been enriched. The code design needs to be concerned:the code should be designed according to the user's thinking order. The existence of the code is unique. Save the appropriate expansion location to meet the development requirements. Need to make the composition of the code have a certain realistic effect. It is harder that other characters should not be used to avoid unclear occurrences. For relatively long code, try to separate.

Character trajectory depiction
The completion steps of the handwritten letter drawing command are: handwritten letters are completed by the encapsulation class CDC in MFC, and the canvas is created by the CStatic control in Visual C++. MouseDown moves the mouse down, MouseMove moves the mouse, and MouseUp moves the mouse up. These are messages that respond to mouse events. They are all displayed in the dialog window. If the program saves a specific coordinate of a point, it means this time. The mouse is clicked on the CStatic control [4]. The mouse down event marks the start of the handwritten letter drawing, and the left mouse button indicates the completion.

Image preprocessing
To indicate the characteristics of handwritten letters, the image must be preprocessed. This part of the design roughly includes: image binarization operation. Setting the gray value of the processed image to 0 or 255 makes the black and white hue of the image very prominent. We call this the binarization process. In the system, if a letter is written in a fixed-size control, this control exists in the VC visual editing interface, then we receive a series of coordinates with space upper left position as the origin. Set a two-dimensional data column similar to this control element in the memory (that is, treat the pixel as a unit, produce a picture with a shape and size similar to the area), and take out the specific coordinates in the handwriting area. Because the previous operation has made the handwritten area coordinates the same as the array of data areas in the memory image, in order to obtain a binary image of handwritten letters, we need to match the data in the image data area with the coordinate value just obtained. Let it have a gray value of 255 (white), and let other coordinate values in the region corresponding to a gray value of 0 (black) [4].

Creation of the feature library
A feature library should be set in the design process of handwritten capital letter recognition, and extract the feature value of a letter we write. After the program wants to input the letter, use the program to make the written letter correspond to all the feature values. And as a template library record, before the handwritten letters are recognized, the template library must be initialized. It should be noted that the template library should be expanded at the same time as the recognition if it appears in the process of identification. If the error is not recognized or identified, it should be collected into the template library in time to make the inventory of the template more diverse.

5.1.4.Image letter recognition
The identification of letters needs to be based on the characteristics of handwritten letter images. For the recognition of handwritten letters, we use template matching, which is the last step required for the system design.
The detailed steps are: if there is a sample data X to be tested, the analysis obtains the action distance of the X and the sample Xj in the training data (0<j<m, m represents the number of sample points in the training data). To find the existing sample that is most similar to the sample to be tested, we need to calculate the distance between the test sample and all existing samples in the training set by continuous calculation and compare it. Finally, the sample Y to be tested belongs to Type is the closest sample type we have derived [5].

Drawing of uppercase letters
The most primitive window is presented with the system executing commands, as shown in With the help of the function OnButtonRset(), click the reset button on the system interface to erase the drawn letters after the letter is drawn. Fig. 4. drawing interface

Capital letter feature extraction
The purpose of the extraction of the letter features is to be able to identify the letters accurately. In this paper, the pixel features of the letters depicted are the same as the abovementioned conclusions that the number of target pixels is smaller than the total number of pixels in the upper range. There are a total of 64. This paper uses the function GetROI(const cv::Mat drawImage) to complete the function of obtaining feature quantities and uses the SaveImage(const cv::Mat& drawImage) function to implement the storage function.

Establishment of template feature library
The structure of the feature library can be completed by starting the learning classifier button on the system interface. After many learnings, the feature library will be completed and the recognition effect will be more credible. At the same time, the record data is constructed and the learning of the feature data is completed by means of LoadSamples().

Uppercase English letter recognition
In this paper, with the help of PredictSample(const cv:: Mat& drawImage), the eigenvalues of the uppercase letters written are compared with all existing eigenvalues in the template library, and the difference between them is calculated. The minimum distance difference corresponds. The category is the type of letter written, which can be achieved by clicking the recognize letter button on the system window. The final discrimination result will be displayed as shown in