Research on Image Recognition Method of Class Graph Based on Deep Learning
Kai You Wang, Wei Liu, Sheng Gao, Yongan Mu, Fan Xu · 2023
Software design reuse has received significant attention, with UML class diagrams being widely used in software design, making UML class diagram reuse a focus of software design reuse research. Therefore, automatically identifying and extracting semantic elements in UML class diagrams has become a fundamental task. However, UML class diagrams exhibit diversity, with different classes presenting multiple representations based on their attributes and methods, and different relationship lines between classes being expressed in various forms. Additionally, image resolution can also impact recognition results. To address these challenges, a Class Diagram Extraction (CDE) method based on object detection and text extraction is proposed. The method utilizes grayscale processing and morphological erosion-dilation operations to preprocess distorted images and reduce image noise. The You Only Look Once-Version 5 (YOLOv5) algorithm is applied to detect every class and relationship type in the class diagram image, accurately locate, segment and extract class regions, and the EasyOCR algorithm is used to perform precise optical character recognition on each extracted block region of the class diagram image. The Probabilistic Hough Transform is used to detect and identify the relationship lines between class modules and integrate line segments into polylines, combining relationship lines with relationship types and classes to obtain the complete semantic information of the class diagram. Comparison with the Img2UML method demonstrates the feasibility and effectiveness of the proposed method in terms of recall and precision in class and relationship type recognition.