Hand-Drawn Electrical Circuit Recognition Using Object Detection and Node Recognition

Rohith Rachala, Mahesh Raveendranatha PanickerSN 2022 · DOI

TL;DR

This paper presents a novel end-to-end system for automatically converting hand-drawn electrical circuit diagrams into digital schematics. By leveraging the YOLOv5 object detection model for component identification and a combination of Hough transform and k-means clustering for node recognition, the system achieves an 80% accuracy in schematic reconstruction with near real-time performance.

What Problem Does This Paper Address?

Designing electronic circuits often begins with hand-drawn sketches. To move these designs into simulation or further automation, they must be digitized. While existing research has focused on classifying individual circuit components, few have tackled the more complex problem of reconstructing the entire circuit schematic from a hand-drawn image. This is challenging due to variations in drawing styles, image quality, and the need to accurately identify both components and their interconnections (nodes). The paper aims to bridge this gap by providing an automated, efficient, and robust method for this conversion.

Methods

The proposed approach is an end-to-end system comprising three main stages:

  • Component Detection: The paper utilizes the You Only Look Once version 5 (YOLOv5) algorithm for detecting electrical components within the hand-drawn circuit images. YOLOv5 is chosen for its speed and accuracy, allowing for near real-time performance without requiring extensive preprocessing of the input images. It outputs bounding boxes and class labels for each detected component.
  • Terminal and Node Recognition:
    • Terminal Recognition: This stage identifies the connection points on each detected component. It involves generating two binary images: one from the component bounding boxes and another using adaptive thresholding of the original image. The intersection of these images helps identify potential terminal points. K-means clustering is then employed to refine these points, using a number of centroids equal to twice the number of detected components.
  • Node Recognition: To identify nodes (where components connect), the components are first removed from the image using their bounding box coordinates. A Hough Transform is then applied to detect horizontal and vertical lines, which are segmented based on their slopes. The intersection points of these lines are identified as potential nodes. A line intersection algorithm is used to calculate these points, and criteria are applied to ensure these intersections lie within the line segments. Contour detection is used to estimate the number of nodes, and k-means clustering refines their precise locations.
  • Schematic Generation: Once components, terminals, and nodes are identified, the system reconstructs the circuit schematic. It assumes that each terminal connects to its nearest node. A distance-based algorithm maps terminals to nodes, and then any remaining unconnected nodes are connected to each other.

Datasets

The paper introduces a custom dataset for training and evaluation. This dataset consists of 154 hand-drawn circuit images created by five different individuals, focusing on common components like voltage sources, resistors, capacitors, inductors, and diodes. For training, 103 images were used, with data augmentation techniques (rotation, flipping) applied to create a training set of 388 images. The remaining 51 images were used for validation and testing.

Key Insights and Ideas

  • Leveraging YOLOv5 for Robust Component Detection: The paper highlights the effectiveness of modern deep learning object detection models like YOLOv5 in handling the variability and noise inherent in hand-drawn images, eliminating the need for traditional, often brittle, image preprocessing steps like thinning.
  • Combined Hough Transform and K-Means for Node Detection: The novel combination of Hough transform for line detection and k-means clustering for precise node localization offers a robust approach to identifying connection points, even with imperfect line drawings.
  • End-to-End Automation: The system's ability to go from a raw hand-drawn image to a reconstructed schematic in a single pipeline is a significant step towards automating the circuit design workflow.
  • Near Real-Time Performance: The achieved inference time of 0.33 seconds per schematic generation makes the system practical for real-time applications.

Key Results

  • Component Detection: YOLOv5 achieved a mean Average Precision (mAP0.5) of 98.2% for component detection.
  • Node Recognition: The proposed method achieved an accuracy of 92% for node recognition.
  • Schematic Reconstruction: The overall accuracy for rebuilding the circuit schematic from hand-drawn images was 80%.
  • Inference Time: The average inference time complexity on 20 images was found to be 0.33 seconds.

Limitations and Future Work

The authors acknowledge several limitations and suggest future directions:

  • Component-Only Branches: The current algorithm is designed for branches containing a single component. Future work could extend this to handle more complex branches.
  • Accuracy of Training: The 80% accuracy in schematic reconstruction means some components might be missed or misidentified, potentially disrupting node detection and leading to complete recognition failure.
  • Distance-Based Mapping: The reliance on distance for mapping terminals to nodes might fail in cases where the drawing is significantly different from expected layouts.
  • Handwriting Variability: Challenges remain in handling the inherent variability of handwriting, including straightness, force, speed, and paper quality. Lighting conditions and camera resolution also pose issues.
  • Dataset Diversity: A more diverse dataset is needed to enable a fully end-to-end deep learning approach, potentially incorporating neural networks for node and terminal recognition as well.

Summary updated

BibTeX
@inproceedings{rachala2022hand,
  author = {Rohith Rachala and Mahesh Raveendranatha Panicker},
  title = {{Hand-Drawn Electrical Circuit Recognition Using Object Detection and Node Recognition}},
  booktitle = {SN},
  year = {2022},
  doi = {10.1007/s42979-022-01159-0},
}
Figure