Freehand to Digital Circuit Reconstruction Using HOG and SVM

: Sketches are commonly used in the fields of engineering and architecture, especially for the early design phases. Engineers spend considerable time setting up initial designs using pencil and paper, and then redrawing them to any software. This problem can be solved by using the idea to scan the circuit sketch with android device which is drawn on the paper and translate it into standard layouts and run circuit simulations. The scanned image will be pre-processed and further segmented. The segmented image will be used to extract the features which are in turn given for classification. Recognizing sketches may seem so quick and intuitive to humans but it is really a big challenge for the machine. In this proposed work the aim is to achieve high precision trainable electronic circuit component recognizer for sketched circuits with fast response time and simple extensibility to new components.


Introduction
In real life, it is often very handy to draw an electronic circuit with various components on paper. However, paper is not a reliable media for storing information. On the other hand, if the authors want to try things out and test on paper if the sketched circuit is functional or not which is almost impossible. In sketch recognition, a difficult task is to maintain a good balance between the ability to draw and the significance of recognition. A sketch recognition system would save a great deal of time for engineers to redraw these into professional applications. With the help of this system, they can provide scanned image as the input which is hand drawn on paper and directly get the results. The project focuses on developing a system that will reduce human efforts to redraw the circuits on desktop and directly provide a scanned image as the input. Thus, by using this the authors can redraw to check whether the system is functioning properly or not and also to check out the results of the circuit drawn. Digital circuits area unit less liable to noise or degradation in quality than analog circuits. It is conjointly easier on digital signals to perform erro detection and correction using digitized circuits. Electronics sector is immensely classified because it produces equipment for industries like telecommunications, electronic elements, producing and manufacturing equipment * e-mail: shristivmittal@gmail.com * * e-mail: satputerhutuja50@gmail.com * * * e-mail: mohite.shubhu61@gmail.com * * * * e-mail: leena.ragha@rait.ac.in † e-mail: dhanashri.bhosale@rait.ac.in with growth within the semi-conductor business has become price over four hundred billion dollars globally. [1] product created by this sector area unit wide utilized in a spread of client and industrial physics product, which incorporates PCBs (printed circuit boards) within those electronic product. PCB circuits can also cause errors like potential distance variations between the written lines, line thickness dissimilarities, false alarms owing to dirty atmosphere, etc. though the PCB business has enforced advances, these days constant reasonably errors continue to exist, and it's still developing examination determination. Hand drawn circuit recognition project may well be a bridge between paper drawn circuit and generated digital circuit, which might eventually scale back time used for making a digital circuit for PCB. Similarly, this projectmay well be helpful for education systems like for physics department for teaching students, process those fashioned circuits yet as any drawn circuit may well be digitized to see if the operating of the circuit is correct.

Objectives:
The main objectives of this paper are that the recognition of hand-drawn circuit schematics with the application of digital image process. The person utilizing this project will discover hand drawn circuit elements and varied kindsof circuit diagrams into the machine.

Motivation:
The fields of electronics have been relatively much slow in developing due to the in feasibility and inconvenience of its physical nature in the fast-paced digital world. Engineers have to manually feed them to machine and convert them from an image diagram to machine understandable format. This system aims to assist electrical engineers, students, examiners, professors in detailed detection and re-drawing circuits of the free hand drawn electrical circuit making it easier to mobilize and practice them.
The organization of the paper is as follows. Section 2 discusses the survey and analysis of the existing systems. Section 3 provides the proposed system. The results are discussed in section 4 followed by conclusion and references.

Survey of Existing Systems:
The paper of B. Edwards, V. Chandran with concept of "Machine recognition of hand-written circuit diagrams" [1] has advantage of 92 percent accuracy for resistors and conductors. Small spots are often ignored in most systems of circuit recognition. However, in spite of the accuracy there is wrong classification of capacitors and voltage sources. "Proposed a system of Hand-drawn logical circuit component recognition using Support Vector Machine and Fourier Descriptor" by Mayuri D. Patare and Madhuri S. Joshi has Support Vector Machine (SVM) [2] whichat the same time minimizes error in the empirical classification and maximizes the geometric margin. The shape signature is chosen which makes it more precise and effective using complex coordinates. The overall accuracy of circuit detection is reached by 83 per cent. But the device does have minimal detection of components.
Computer Vision Approach is extremely useful as it uses syntactic simulation in "Automatic contextual recognition of hand-drawn content" by Williams, Kyle, Filho, Milton Ribeiro, Renshaw and Megan [3]. It does classification using a com-bination of invariant moments pixel-distribution options that are scalar and straight-line vector representations in two-dimensional figure representations. Srikanth Sridar's and Krishnan Subramanian's, "Circuit Recognition using netlist proceedings" [4] is a vital project because it focuses on a brand-new methodology victimization Artificial Neural Network (ANN) to form amachine that may directly browse from a hand drawn cir-cuit image any electrical symbols. It reduces the errorsby combining with back propagation so it modifies theweights of the assorted layers.
"Segmentation and Recognition of Electronic components in hand-drawn circuit diagrams" by Momina Moetesum, Syed Waqar Younus, Muhammad Ali Warsi and Im-ran Siddiqi [5] concluded that more components are detected and a combination of traditional pre-processing methods with modern novel methods are used to create a Netlist for simulation. The authors see that input symbols and data need not be provided.
""Pre-processing Techniques in Character Recognition" by Yasser Alginahi [6] gives us another way of recognizing freehand drawn circuits using Convolution Neural Net-works (CNN). A network is trained using huge amounts of data set of 28 thousand images. It gives an accuracy of 91.85 percent in recognizing handwritten digits but slow computing time makes it difficult.

Analysis of Existing Systems:
On surveying the assorted systems, the authors have understood the downsides and understood the areas they'd like to work on to create an efficient and successful system. They understand that a robust data-set with varying features was missing in most systems leading to less accuracy of versatile input. They must aim to gather and build a versatile and real data from experts and amateurs as their project would be utilized by the users. Thus, to form a decent size of training and testing dataset to figure on various classifiers. They see drawbacks in system because of ignorance of noise, small spots, shadows and ranging illumination, color and large size data where the photographs don't seem to be processed properly before giving as input causing poor feature extraction. [4] Pre-processing is an especially vital method to enhance the results of any classifier. The image must be clear, its partsand components precise for input. They realize that they want to settle on the proper set of features by creating a strong segmentation procedure. [2] The low accuracy within the existing systems is additionally because of feature extractor. [1] They see that HOG (Histogram of Oriented gradients) has worked more effectively as compared to SURF (Speeded up robust features) [2]. In the systems they tend to see that ANN, CNN and SVM dominate among others pretty much as good classifiers. Neural networks like ANN and CNN perform higher on terribly massive datasets however they increase complexity. The system victimization ANN gets too advanced and isn't scalable. [3] CNN provides the simplest accuracy of around 91 [5] and SVM around 92 percent [1]. On additional survey, they've realized that the system operating on CNN needs an enormous dataset and still performs slower. Their goal is to form this application for users in real life to be used existing handheld devices and not on GPU powered computers that CNN wouldn't be able to fulfil.

Proposed System
The proposed system has the following steps.
-Collection of data -Preprocessing of Data -Segmentation -Feature extraction -Classification -Detection and Redrawing Each of these stages is explained in detail in the following sub sections.

Dataset
A decent quantity of data is needed to train Support Vector Machine. Most on-line data-sets don't seem to be accurate as they do not capture the varied features of hand-drawn circuits as real data does. They have collected the data from varied students and colleges from completely different departments in our university for flexibility and versatility in the data. The data is hand-drawn complete circuits. These pictures once captured square measure either blur, of low image quality, and additionally contain varied noise like paper lines, sunlight, and shadow. the photographs captured additionally could contain over one circuits and additionally text.
The training data-set consists of three files of 400 images for components for resistor, inductor, diode cropped from each circuit. These images are in jpeg format. The testing data-set has 100 images for the three components. The data-set also contains the components in all possible vertical and horizontaldirections and the images are also rotated in three directions 90,180,270 to get all possible angles.
The sketch of the circuit is a composition of component symbols and connection lines, every symbol requires a specified recognizer that should be trained with a data set. The interest here is restricted to "capacitor, inductor, diode, resistor, voltage source and ground components". They alsomade some ideal conditions and assumptions given below, 1. The connection lines are only horizontal and vertical direction wires. 2. Open lines represent a component symbol such as capacitorand ground.
These assumptions make it easier to segment symbols and connection. Recognition task consists of segmentation of component symbols and recognition of these symbols.

Pre-Processing
The proposed system takes the scanned image of handdrawn circuits and supports the jpeg format. The images taken with a digital camera should be of a minimum of two pixels. The images of hand-drawn circuits obtained not only havelots of noise and illumination variations but are also of varied sizes and colors. Also, the circuits are almost scribbled thus having lots of errors, and hence they need to be pre-processed to create a clean and relevant data-set to feed as input toSVM for better classification rate. As their focus in this project is the outline and components of the circuit, the background data is irrelevant and hence increases size and noise when fed in for feature extraction and classification. Thus, by applying image pre-processing techniques they have reduced the trainingtime drastically and increased the accuracy of the classifier to a huge extent. Hence, they have focused on pre-processing.

Resizing
The images that are captured using a camera are usually of different sizes due to the exposure and quality of the camera system. The pixel values are between 0 and 255 recorded in integers. Generally small weight values are used by most classifiers and neural networks because slowing down or disrupting the resizing process is usually caused by large weight or integer values. First, these images are resized to a (100,100) pixel size which seemed the best small size to extract features from using HOG without too much loss and feed as input to SVM.

Cropping
The image can then be cropped to avoid other text or circuits, as per the choice of the user. The user selects the start and endpoint using the cursor and selects the image he requiresand crops it.

Converting to Binary
Then, they've converted the image from RGB to grayscale and further the image is converted into binary form to reduce the data for easier processing. Since, they have different lighting conditions on our images on different areas, for such varying illuminations on our images they've used Adaptive thresholding method for better results.

Noise Removal
Thresholding results in a binary image, but it consists of lotsof noise that needs to be removed to not lead to confusionin ratio and cuts during feature extraction. Some of the foreground bright pixels from the edges and unimportant regions of bright pixels were removed by applying opening morphology. It preserves the circuit while removing the noise. They've also tried erosion but it was destructive and had the disadvantage that if affect all regions with bright pixels (including the circuit) indiscriminately. The results are shown, the effect of the opening is easily visible and they see that all pixels which can be covered with structuring element within the bright region will be preserved but those that cannot be covered will be eroded.

Dilation
Opening morphology thus left the authors with some broken circuit lines and thin joins that got eroded as noise. It becomes very important to join these lines to not confuse them with components and a ground to be confused as a diode. They've use dilation to increase the circuit lines area so it joins the broken parts of the circuit and retaining the circuit while the noise is gone.

Image Thinning
The dilated image is too wide and may cause joining of two lines such as between capacitor which would cause confusion and reduce the efficiency of the classifier. The dilated imageis then thinned, giving them a noiseless, connected circuit with thin lines

Skeletonization
Ideally, the final image should have the minimum and most important data for better feature extraction. By using skeletonization, we convert the image into a simple yet compact representation of the circuit while capturing its essential features. This process converts the circuit lines in single-pixel width with high density, so they get a bright circuit and also reduce the size and unnecessary data away. By doing this they've created better data and got the exact points where the circuit changes direction and also got the endpoints of the other components. Endpoints are extremely important as features during feature extraction for classification. Finally,with this step, they've created the right dataset to foreground regions. The small regions with thresholding contours are ignored using a threshold T by region area. As these small regions are probably noise due to illumination differences or remaining of connection lines. The regions remaining can be potentially circuit components that can be recognized with the recognition procedure.

Feature Extraction
After pre-processing and segmentation on the image of the circuit, features of every element are extracted. This step is the heart of the system as this step has a larger impact on the detection rate. This step helps to classify the elements according to their features. Feature extraction is that the name was given to a bunch of procedures for the measurement of the relevant form data contained during apattern so the task of classifying the pattern is created simply by a proper procedure. ii) HOG divides the cells into 2*2-pixel cells.
iii) For a vector with x and yMagnitude is calculated as give as input for segmentation.

Segmentation
"Segmentation is the method of breaking apart the image into items that measure sufficiently small to be detected" [1]. Endpoints from pre-processing take us to the segment The equation can also be expressed as capacitor, voltage source and ground symbols as they contain open lines. The capacitor, voltage source, ground components vary in two properties -the length ratio of lines, the number of lines they have. Hence, they do not require a trained recognizer for these components. They can be identified using the below unique properties: 1. The length ratio of the two lines in a capacitor is 1.
detected with the help of the line segment detector algorithm [4]. These connection lines according to the assumption are only horizontal and vertical. Then, the detected connection lines are removed and components are segmented using adaptive thresholding which is already done in the pre-processing stage. They've applied the morphological closing operation to fit the image for the contour detection [5]. It produces separated dx and dy = differentiation factors of x and y; fx = function of x; fy = function of y; It is a rotation and scale invariant feature description algorithm. Histogram Oriented Gradients [HOG] feature vector received and the training sample label was taken for training the Support Vector Machine (SVM). The features extracted by HOG for the various components are given below. The authors have studied that the features for resistor are continuous curved lines and for resistor differ as they are sharped hill continuous lines. Similarly, the magnitude and direction for capacitor is two lines having ratio 1.0 and for voltage source a ratio of about 0.5 units.
The features extracted for ground are three small lines and the diode can be classified having a closed triangular shape feature. As these images may have cuts, noise and the lines may be slant, they have trained the extractor by giving it a number of circuits for it to better understand and identify the lengths of the ratio.

Classification
Classification is the process of labelling of objects into one of a number of predefined categories. The authors have a supervised data. Thus, they can classify using supervised learning algorithms. As analyzed in the literature survey CNN also seem to be competitive with SVM. But they see the benefits of SVM and see it could solve their problem. So they try this classification model. Support Vector Machine (SVM) minimizes error in the empirical classification and maximizes the geometrical margin.
Originally, Vladimir N. Vapnik and Alexey Ya. Chervonenkis, in 1963, invented SVM algorithm. Learning algorithms which analyze data used for classification and analysis of regression are compatible supervised learning models (such as SVM-support vector machine) that relies on support-vector networks. A set of hyperplanes or single hyperplane inside a high-or infinite-dimensional space makes up as support vector machine. Processes like classification, regression and tasks like outlier's detection use these hyperplanes. Experimental test results only after three to four relevance feedback rounds have shown that SVMs attain significantly higher search accuracy as compared to traditional queries. For image segmentation systems and for systems using modified version SVM, this holds true. Also, it benefits from proper feature selection and extraction techniques.

Detection and Redrawing
The detection goal is to interpret the circuit taken from the scanner. In the identification of the same sequence of operations the circuit is detected by comparing the extracted features with simulation of the trained classifier. Then, the components are identified and redrawn based on the Support Vector Machine (SVM) classifier.

Results and Discussion
The system working on parameters depending on features would provide the result indicating the separation of components and wired nodes from the circuits. All the processes from image acquisition to classification of circuit and redrawing a digital circuit will be in a same place. The resultant data will be the product of duly trained Support Vector Machine (SVM) which is trained under several similar data to provide precise accurate results more than 90%. Hence, a system is developed to detect the components, nodes and gates of the provided drawn circuit.

Confusion between Components
T h e y ' v e observed that a few components are confused by their SVM trainer and results in wrong detection.

1.
The resistor gets confused as inductor due to the unclear round curves of the inductor and the lines of the resistor and vice-versa.

2.
Similarly, the resistor and ground are confused in some cases due to the three continuous lines and the spaces not being accurately understood and hence recognizing them as the resistor's up and down lines.

3.
The diode is a vertical line with a triangle, this triangle gets confused as the resistor's hill peak line.
Hence, these confusions get reduced and the results keep getting accurate as the author's SVM trainer gets more experience.

Conclusion
The Automation of circuit component recognition and generating the whole circuit for further processing using simulators to test them is a challenging task. In this paper we attempted to recognize the various components with good accuracy. The future work includes identification of many more components and the generation of the whole circuit with confidence.

Reference Papers
Resistor