Vector character recognition and reconstruction method and device for CAD drawing

By analyzing and recognizing the vector lines of CAD drawings, and combining single characters and language models to restore text semantics, the difficulties of recognition in PDF format of CAD drawings by traditional OCR technology have been solved, and efficient text recovery and editing capabilities have been achieved.

CN121861689APending Publication Date: 2026-04-14CHENGDU PENGYE SOFTWARE
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-25
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Traditional bitmap-based OCR technology suffers from problems such as loss of detail, high computational cost, and poor anti-interference ability when processing CAD drawings in PDF format. This results in text that cannot be directly searched, copied, or edited, affecting the reuse of drawings and data extraction.

Method used

By parsing, connecting, and spatial density clustering the vector lines of CAD drawings, potential text regions are identified, and text semantics are recovered by combining single-character recognition models and language models to generate editable CAD text objects.

Benefits of technology

It achieves end-to-end automatic conversion from PDF vector lines to editable CAD text objects, improving recognition accuracy and speed, reducing computational costs, and supporting the searchability and reusability of drawings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121861689A_ABST
    Figure CN121861689A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for recognizing and reconstructing vector characters of a CAD drawing, and relates to the technical field of data processing. The method comprises the steps that a PDF file is analyzed, and vector elements and attribute information of the vector elements are extracted; character stroke candidate lines are screened out according to attribute grouping; carrying out connectivity analysis and density-based spatial clustering on the lines, and identifying a text region; rendering the vector lines of the text region into an image with high resolution, carrying out single character segmentation, and recognizing characters by combining drawing-level font library template matching with a single character recognition model; combining the single characters into word groups according to the positions and the context information, and performing word order correction by adopting a language model; the recognition result is written back into an editable CAD text object; according to the method, vector geometric information is directly utilized, distortion of bitmap sampling is avoided, the small character recognition rate and the anti-jamming capability are effectively improved, and end-to-end semantic recovery from vector lines to searchable and editable texts is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, specifically to a method and apparatus for vector text recognition and reconstruction in CAD drawings. Background Technology

[0002] In the fields of engineering design and manufacturing, CAD drawings are the core carrier of technical information. To facilitate distribution and viewing, CAD drawings (such as DWG and DXF formats) are often exported or converted to PDF format. During this process, due to font embedding limitations, differences in software compatibility, or specific export strategies, the text information in PDF drawings is often converted into pure vector outlines (i.e., lines composed of polylines, Bézier curves, etc.), losing its original character encoding semantics.

[0003] The aforementioned processing methods prevent the text in PDF drawings from being directly searched, copied, edited, or subjected to deeper semantic understanding and automated processing, posing significant challenges to the reuse, modification, and data extraction of these drawings. Currently, the mainstream approach to solving this problem is to employ Optical Character Recognition (OCR) technology. However, traditional bitmap-based OCR techniques suffer from issues such as detail loss, high computational costs, and poor interference resistance when handling these problems. Summary of the Invention

[0004] In view of the above problems, the present invention provides a method and apparatus for vector text recognition and reconstruction in CAD drawings, which can directly recognize and reconstruct text from vector lines in PDF files, avoid the distortion problem of bitmap sampling, make full use of the contextual information of the drawings, and finally write the recognition results back to the CAD file as editable text objects to restore their semantic attributes.

[0005] In a first aspect, embodiments of the present invention provide a method for vector text recognition and reconstruction in CAD drawings, the method comprising: The input PDF file is parsed to extract all vector elements and their attribute information. The vector elements are grouped according to their attribute information to filter out candidate lines for character strokes; Connectivity analysis was performed on the filtered lines, and potential text regions were identified based on a spatial density clustering algorithm; The vector lines within the text area are rendered into an image, single-character detection and segmentation are performed, and the characters are identified using a single-character recognition model. The identified individual characters are merged into phrases based on their position and context information, and word order is corrected to restore the semantics of the text; The finally identified text and its location information are used to generate a CAD text object, which is then written back to the target CAD file.

[0006] In some embodiments, the attribute information includes at least one of line width, color, line type, layer information, and drawing order.

[0007] In some embodiments, the step of performing connectivity analysis on the filtered lines and identifying potential text regions based on a spatial density clustering algorithm includes: Calculate the geometric dimensional features of each connected component; Based on a preset size threshold, connected components that are too large or too small are filtered out. The remaining connected components are projected onto a plane, and a density-based clustering algorithm is used to generate one or more candidate regions for text blocks.

[0008] In some embodiments, rendering the vector lines within the text area into an image, performing single-character detection and segmentation, and recognizing characters using a single-character recognition model includes: Each candidate text region is rendered at high resolution to generate a binary or grayscale bitmap; Locate the word boundaries on the rendered image and segment the vector strokes into individual characters; Extract at least one of the geometric features, statistical features, topological features, and shape descriptors from each single character stroke set to construct a drawing-level font library.

[0009] In some embodiments, the single-character recognition employs a combination of direct matching and visual recognition, wherein: the direct matching is used to compare the features of the single character to be recognized with the template in the drawing-level font library; and the visual recognition uses an OCR model finely tuned from engineering drawing text samples for recognition.

[0010] In some embodiments, the method for vector text recognition and reconstruction in CAD drawings further includes: The high-confidence recognition results or manually confirmed recognition results and their stroke features are updated to the drawing-level character library for template matching in subsequent recognition tasks.

[0011] In some embodiments, merging the identified single characters into phrases based on their position and context information, and performing word order correction to restore text semantics, includes: Based on the alignment of individual characters, character spacing, and engineering dictionary, heuristic rules are used to merge adjacent characters into word groups; Statistical language models or pre-trained language models are used to sort and correct the merged candidate word groups in order to correct word order and spelling errors.

[0012] Secondly, embodiments of the present invention provide a device for vector text recognition and reconstruction in CAD drawings, comprising: The parsing module is used to parse the input PDF file and extract all vector elements and their attribute information. The filtering module is used to group the vector elements according to their attribute information in order to filter out candidate lines for text strokes. The detection module is used to perform connectivity analysis on the filtered lines and identify potential text regions based on the spatial density clustering algorithm. The recognition module is used to render the vector lines in the text area into an image, perform single character detection and segmentation, and recognize the characters using a single character recognition model; The semantic reconstruction module is used to merge the identified single characters into phrases based on their position and context information, and to perform word order correction in order to restore the semantics of the text; The write-back module is used to generate CAD text objects from the finally recognized text and its location information, and write them back to the target CAD file.

[0013] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor, wherein the memory stores program code that can run on the processor, and when the program code is executed by the processor, it implements the method for vector text recognition and reconstruction of CAD drawings as described in any embodiment of the first aspect.

[0014] Fourthly, embodiments of this application provide a computer storage medium storing one or more programs, which can be executed by an electronic device as described in the third aspect to implement the method for vector text recognition and reconstruction of CAD drawings as described in any embodiment of the first aspect.

[0015] The present invention provides a method and apparatus for vector text recognition and reconstruction in CAD drawings. By directly utilizing the geometric information of vectors for analysis, it avoids the loss and distortion of details caused by bitmap rendering. It has good recognition effect on fine strokes and small-sized text, and can effectively overcome the interference of overlapping primitives. It can quickly eliminate a large number of non-text primitives through attribute grouping and size filtering, and perform high-resolution rendering and recognition only on candidate areas, which greatly reduces the computational cost.

[0016] By leveraging the high repetition of text within drawings, template matching reduces OCR calls and improves overall processing speed; through contextual word combination and language model correction, complete phrases and terms that conform to engineering semantics are recovered, improving the usability of the results.

[0017] This invention enables end-to-end automatic conversion from PDF vector lines to editable CAD text objects, restoring the searchable and reusable value of drawings. Through parameter adaptive adjustment and incremental learning mechanisms, it can adapt to PDF drawings from different sources and standards, exhibiting good scalability and robustness.

[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0019] The invention will now be described in more detail with reference to embodiments and the accompanying drawings.

[0020] Figure 1 The diagram illustrates an exemplary method for vector text recognition and reconstruction in CAD drawings, as proposed in one embodiment of the present invention. Figure 2 This diagram shows a structural block diagram of a device for vector text recognition and reconstruction in CAD drawings according to an embodiment of the present invention. Figure 3 This diagram illustrates a structural block diagram of an electronic device proposed in an embodiment of the present application for performing a method for vector text recognition and reconstruction of CAD drawings according to an embodiment of the present application; Figure 4 An exemplary computer-readable storage medium for storing or carrying a method for vector text recognition and reconstruction of CAD drawings according to an embodiment of the present invention is shown. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.

[0022] According to the inventors' research, traditional bitmap-based OCR technology has significant limitations when dealing with this type of problem: Loss of detail: OCR processes pixel images, while vector lines are rendered as bitmaps, especially small-sized, fine-stroke text at high resolution. Due to sampling and anti-aliasing processing, stroke details are easily blurred or lost, which seriously affects recognition accuracy.

[0023] High computational cost: To ensure recognition results, the entire high-resolution drawing needs to be rendered, which consumes a lot of computational resources.

[0024] Poor anti-interference ability: When text vector lines overlap with other graphic elements (such as center lines and borders), bitmap OCR has difficulty distinguishing them effectively and is easily interfered with, resulting in misrecognition.

[0025] In addition, text in CAD drawings often has characteristics such as concentrated style, frequent repetition, and stable color / line type information. Traditional OCR methods have failed to make full use of this valuable prior information.

[0026] To address the aforementioned issues, the applicant proposes a method and apparatus for vector text recognition and reconstruction in CAD drawings. This method analyzes the original geometric information of strokes and lines, avoiding detail loss due to bitmap sampling and improving the recognition rate of small characters. It also avoids interference from overlapping primitives and text. Through drawing-level character library and template matching, it utilizes highly repetitive text information to reduce recognition costs and improve accuracy. The results are written back to CAD text objects, supporting editable and searchable semantic recovery and end-to-end write-back capabilities. Parameter adaptiveness (based on DPI and average character scale) and incremental learning mechanisms adapt to different sources and versions of CAD / PDFs. The modular design supports offline, local, or cloud-based batch processing and provides a manual verification interface to further improve quality.

[0027] The method for vector text recognition and reconstruction in CAD drawings will be described in detail in subsequent embodiments. The application scenarios of the vector text recognition and reconstruction method for CAD drawings provided in this embodiment are described below: Please see Figure 1 , Figure 1 This is a schematic diagram of a method for vector text recognition and reconstruction in CAD drawings provided in an embodiment of the present invention. In this embodiment, the method for vector text recognition and reconstruction in CAD drawings can be applied to, for example... Figure 2 The device shown is a vector text recognition and reconstruction device 300 for CAD drawings. Figure 3 In the electronic device 200 shown, the following is specifically for... Figure 1 The process shown is described in detail. This method for vector text recognition and reconstruction in CAD drawings may include steps S110 to S160.

[0028] S110: Parse the input PDF file and extract all vector elements and their attribute information.

[0029] In this embodiment, a corresponding open-source library or commercial PDF parsing engine is used to perform deep parsing on the input PDF file. The parsing process includes traversing the page content stream of the PDF, identifying and extracting all path construction and path drawing operation instructions. These instructions correspond to vector primitives that make up the drawing, such as line segments, polylines, Bézier curves, and arcs. For each vector element, its key graphic attributes are extracted simultaneously, including but not limited to: line width, stroke color and fill color, line style (such as solid line, dashed line, dotted line, etc.), and the layer name or ID of the element. In addition, the drawing order of the primitives on the page is recorded, and all extracted vector data and its attributes are converted into a structured data format and stored in memory for subsequent module processing.

[0030] S120: Grouping based on the attribute information of vector elements to filter out candidate lines for text strokes.

[0031] In this embodiment of the application, the purpose of this step is to take advantage of the fact that the strokes of text in CAD drawings usually have a unified visual attribute that is different from other graphic elements (such as thick borders and thin center lines) to perform rapid pre-screening and group line graphic elements with the same line width, color, line type and layer.

[0032] S130: Perform connectivity analysis on each filtered line group and identify potential text regions based on spatial density clustering algorithm.

[0033] In this embodiment of the application, by finding areas that are spatially clustered and may constitute text from the pre-screened set of lines, a topological analysis is first performed based on the endpoint coordinates of the primitives, and primitives that are connected to each other or whose endpoints are very close are merged into connected components.

[0034] S130 includes S131 to S133, wherein: S131: Calculate the geometric dimensional features of each connected component.

[0035] In this step, for each connected component, its minimum bounding rectangle is calculated, thereby obtaining the component's width, height, aspect ratio, and pixel density or geometric density (i.e., the ratio of effective stroke length to area).

[0036] S132: Filter out connected components that are too large or too small based on a preset size threshold.

[0037] In this step, size filtering thresholds are set. For example, the maximum side length threshold L_max and the minimum side length threshold L_min of the MBR are set, as well as the maximum area threshold A_max.

[0038] Specifically, connected components with MBR side lengths greater than L_max or areas greater than A_max (such as table frames and large symbols), as well as isolated small points or short line segments with side lengths less than L_min (such as noise), will be filtered out. These thresholds can be adaptively calculated based on the global scale of the drawing or DPI information.

[0039] S133: Project the remaining connected components onto the plane and use a density-based clustering algorithm to generate one or more candidate regions for text blocks.

[0040] In this step, the centroid or MBR center point of each retained connected component is projected onto a two-dimensional plane. Then, density-based spatial clustering algorithms, such as DBSCAN or OPTICS, are used to identify regions where strokes cluster. Key parameters of the algorithm, such as the neighborhood radius eps (representing the typical distance between characters) and the minimum number of points min_samples (representing the minimum number of characters a text block must contain), are dynamically adjusted based on the estimated font size and layout density of the drawing. Finally, each region identified by the density clustering algorithm becomes a potential candidate region for a text line or text block.

[0041] S140: Render the vector lines within the text area into an image, perform single-character detection and segmentation, and use a single-character recognition model to identify the characters.

[0042] In this embodiment of the application, since the morphological features of characters are clearer on local high-resolution images, this step combines vector information with image recognition technology to improve the accuracy of single-character recognition.

[0043] S140 includes S141 to S143, wherein: S141: Render each candidate text region at high resolution to generate a binary or grayscale bitmap.

[0044] In this step, for each candidate text region obtained by S133, its bounding box is calculated and extended outward by several pixels to ensure the integrity of the strokes. Then, using a graphics rendering engine, only the original vector lines within the bounding box are rendered as binary bitmaps or grayscale bitmaps at extremely high resolution (e.g., 600 DPI-2400 DPI). The high resolution ensures that even small strokes have enough pixels to represent their shape.

[0045] S142: Locate the word boundaries on the rendered image and segment the vector strokes into individual characters.

[0046] In this step, the bounding box of each character is accurately located on the rendered local high-resolution image using projection, connected component analysis, or a deep learning-based object detection model. Based on the character bounding boxes in the image, they are back-mapped to the original vector line data, merging vector strokes belonging to the same character together, thus completing the vector stroke segmentation from text blocks to individual characters.

[0047] S143: Extract at least one of the geometric features, statistical features, topological features, and shape descriptors of each character stroke set to construct a drawing-level character library.

[0048] In this step, for each segmented character corresponding to a set of vector strokes, a set of multi-dimensional feature vectors is extracted. These features include: geometric features (such as aspect ratio, area-to-perimeter ratio); statistical centrality features (such as centroid, second-order central moment, principal direction); topological features (such as stroke connectivity graph, number of intersections / endpoints); and higher-level shape descriptors, such as Hu moments and Zernike moments. These features together constitute the character for subsequent template matching and character library construction.

[0049] In some implementations, single-character recognition combines direct matching with visual recognition, wherein: direct matching is used to compare the features of the single character to be recognized with templates in the drawing-level character library; visual recognition uses an OCR model finely tuned from engineering drawing character samples for recognition.

[0050] In this embodiment, single-character recognition employs a dual-path parallel strategy. One path is direct matching: calculating the similarity (such as cosine similarity or reciprocal Euclidean distance) between the feature vector of the character to be recognized and the feature vectors of all templates in the character library already constructed in the current drawing. If the highest similarity exceeds a preset threshold, the character corresponding to that template is directly adopted as the recognition result. The other path is visual recognition: inputting the single-character image rendered in S141 into a deep learning OCR model that has undergone extensive data fine-tuning for small-sized, engineering fonts for recognition. Finally, a decision is made based on the confidence levels of the two paths, typically prioritizing the direct matching result with higher confidence to improve efficiency and accuracy.

[0051] In some implementations, the method for vector character recognition and reconstruction in CAD drawings further includes: updating the high-confidence recognition results or manually confirmed recognition results and their stroke features to the drawing-level character library for template matching in subsequent recognition tasks.

[0052] In this embodiment, as a key incremental learning mechanism, for characters recognized with high confidence by the OCR model, or characters confirmed correctly through a manual correction interface, the system adds their corresponding vector stroke set, extracted feature vectors, and rendered image as new templates to the character library of the current drawing. When processing other parts of the same drawing or drawings with similar styles, newly appearing identical characters are more likely to be recognized through an efficient direct matching path, thereby reducing reliance on computationally intensive OCR models and achieving faster and more accurate recognition with each iteration.

[0053] S150: The identified words are merged into phrases based on their position and context information, and word order is corrected to restore the semantics of the text.

[0054] In this embodiment of the application, the problem of character order being disordered after single-character recognition is solved, and the characters are combined into phrases with engineering significance.

[0055] S150 includes S151 to S152, wherein: S151: Based on the alignment of individual characters, character spacing, and engineering dictionary, heuristic rules are used to merge adjacent characters into phrases.

[0056] In this step, characters located in the same row or column are initially sorted based on the center point coordinates and main direction (e.g., horizontal or vertical) of all identified characters using clustering or scanline algorithms. Then, based on heuristic rules such as the ratio of character spacing (horizontal or vertical distance between adjacent character MBRs) to the average character width and the alignment of character baselines, the closest and best-aligned adjacent characters are merged into candidate word groups. Simultaneously, a pre-built dictionary of commonly used engineering terms (e.g., containing diameter, radius, centerline, etc.) is used for priority merging and verification.

[0057] S152: Use statistical language models or pre-trained language models to sort and correct the merged candidate word groups in order to correct word order and spelling errors.

[0058] In this step, for candidate results with multiple possible segmentations or rankings, a language model is used for disambiguation and correction. For example, a statistical model can be used to calculate the probability of candidate word groups, or a language model pre-trained on engineered text can be fine-tuned to score and rank candidate word groups. Language models can leverage contextual semantic information to significantly improve the accuracy and readability of the final output text.

[0059] In practical applications, this embodiment provides a method for vector text recognition and reconstruction in CAD drawings, which may include the following steps: S1, PDF Vector Parsing. This process loads a PDF file using an open-source or commercial PDF parsing library, iterates through its page objects, and extracts all vector elements (including line segments, curve segments, etc.) corresponding to path drawing instructions, along with the precise attributes of each element, including line width (w), color (RGB or CMYK values), line type (solid line, dashed line, etc.), layer, and drawing order. This information is then stored in a structured manner.

[0060] S2, Line Attribute Grouping and Pre-filtering. All parsed vector elements are quickly clustered based on their physical attributes. A rapid pre-filter is then performed, grouping line elements with similar line widths, colors, line types, and layers together. A reasonable line width threshold can be set to remove excessively thick border lines, axis lines, etc. This step significantly reduces the amount of data processed subsequently.

[0061] S3, Connectivity Analysis and Size Filtering. For each group of lines, perform topological connectivity analysis based on their endpoint coordinates to construct connected components. Calculate the minimum bounding rectangle (MBR) of each connected component and its area, aspect ratio, and other features. Set a size threshold to filter out primitives that clearly do not conform to text characteristics.

[0062] S4, density-based spatial clustering. It projects the center points of all retained connected components or MBR center points onto a two-dimensional plane. Employing the DBSCAN clustering algorithm, it dynamically sets the neighborhood radius (eps) and minimum number of points (min_samples) based on the estimated character spacing of the drawing, clustering spatially aggregated connected components together. Each cluster is considered a potential text line or text block.

[0063] S5, Candidate Region Rendering and Single Character Processing. For each text candidate region, its bounding box is appropriately expanded, and the vector lines within the region are rendered as a binary image at high resolution. Then, the image is segmented into single characters using projection or connected component analysis to obtain the image region of each individual character. Simultaneously, the original vector stroke set corresponding to each character is recorded.

[0064] S6, Stroke Feature Extraction and Single Character Recognition. For each single character, multiple features are extracted from its vector stroke set, such as shape descriptions and topological features like the number of stroke endpoints and intersections. First, the extracted features are matched against a character template already constructed in this drawing for similarity. If the similarity is higher than a threshold, the recognition result of the template is directly used. If the match fails or the confidence level is low, the rendered image of the character is fed into a pre-trained deep learning OCR model for recognition. The character encoding, confidence level, and position are recorded in the recognition result.

[0065] S7, Word combination merging and word order correction. Sort the recognized single characters according to their center point positions. Merge adjacent single characters into candidate phrases based on heuristic rules such as character spacing and baseline alignment. Then, use a language model fine-tuned on an engineering term library to verify and reorder these candidate phrases. For example, the recognized "径直" may be automatically corrected to "直径".

[0066] S8, CAD backwriting and index building. Package the finally determined text strings, positions, rotation angles, and layer information into text entities in the target CAD format by following the layer where the original vector lines are located or creating a specific new layer. Write these entities into a new or existing CAD file through the CAD operation library. At the same time, an index file can be generated to record all recognized texts and their positions for easy searching.

[0067] S9, Incremental learning. During the processing, for the recognition results that have been manually confirmed or have extremely high confidence, store their corresponding single-character vector features and image templates in the character library. When processing the same batch or drawings with similar styles, the continuous enrichment of the character library will significantly improve the recognition speed and accuracy.

[0068] Please refer to Figure 2 , Figure 2 FIG. is a structural block diagram of a device for vector text recognition and reconstruction of CAD drawings provided by the present invention, including: an analysis module 310, a screening module 320, a detection module 330, a recognition module 340, a semantic reconstruction module 350, and a backwriting module 360, where:

[0069] The analysis module 310 is used to analyze the input PDF file and extract all vector elements and their attribute information therein.

[0070] The screening module 320 is used to group according to the attribute information of the vector elements to screen out candidate lines for text strokes.

[0071] The detection module 330 is used to perform connectivity analysis on the screened lines and identify potential text regions based on the spatial density clustering algorithm.

[0072] The recognition module 340 is used to render the vector lines in the text region into an image, perform single-character detection and segmentation, and use a single-character recognition model to recognize characters.

[0073] The semantic reconstruction module 350 is used to merge the recognized single characters into phrases based on their positions and context information and perform word order correction to restore text semantics.

[0074] It should be noted that the device embodiments in this invention correspond to the aforementioned method embodiments. The specific principles in the device embodiments can be found in the content of the aforementioned method embodiments, and will not be repeated here.

[0075] In the several embodiments provided in this example, the coupling between modules can be electrical, mechanical, or other forms of coupling.

[0076] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0077] Please see Figure 3 , Figure 3 The present application provides a structural block diagram of an electronic device 200 that can perform the above-described method for vector text recognition and reconstruction of CAD drawings. The electronic device 200 may be a smartphone, tablet computer, computer, or portable computer.

[0078] The electronic device 200 also includes a processor 202 and a memory 204. The memory 204 stores programs that can execute the contents of the foregoing embodiments, and the processor 202 can execute the programs stored in the memory 204.

[0079] The processor 202 may include one or more cores for data processing and message matrix units. The processor 202 connects to various parts within the electronic device 200 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 204, and by calling data stored in the memory 204. Optionally, the processor 202 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 202 may integrate one or more of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem / decoder. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem / decoder handles wireless communication. It is understood that the modem / decoder may also be implemented separately as a communication chip, without being integrated into the processor.

[0080] Memory 204 may include random access memory (RAM) or read-only memory (ROM). Memory 204 can be used to store instructions, programs, code, code sets, or instruction sets. Memory 204 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (e.g., instructions for a user to obtain random numbers), instructions for implementing the various method embodiments described below, etc. The data storage area may also store data (e.g., random numbers) created by the terminal during use.

[0081] Electronic device 200 may also include a network module and a screen. The network module is used to receive and transmit electromagnetic waves, converting electromagnetic waves into electrical signals, thereby enabling communication with communication networks or other devices, such as audio playback devices. The network module may include various existing circuit elements used to perform these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, SIM cards, memory, etc. The network module can communicate with various networks such as the Internet, corporate intranets, and wireless networks, or communicate with other devices via wireless networks. The aforementioned wireless networks may include cellular telephone networks, wireless local area networks, or metropolitan area networks. The screen can display interface content and facilitate data interaction.

[0082] Please refer to Figure 4 , Figure 4 This diagram illustrates a structural block diagram of a computer-readable storage medium according to an embodiment of this application. The computer-readable storage medium 400 stores program code 410, which can be called by a processor to execute the methods described in the above method embodiments.

[0083] The computer-readable storage medium 400 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium 400 has storage space for program code 410 that performs any of the method steps described above. This program code 410 can be read from or written to one or more computer program products. The program code 410 may be compressed, for example, in a suitable form.

[0084] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform a method for intelligent collection and deduplication of network data as described in the various optional implementations above.

Claims

1. A method for vector text recognition and reconstruction in CAD drawings, characterized in that, The method includes: The input PDF file is parsed to extract all vector elements and their attribute information. The vector elements are grouped according to their attribute information to filter out candidate lines for character strokes. Connectivity analysis was performed on the filtered lines, and potential text regions were identified based on a spatial density clustering algorithm; The vector lines within the text area are rendered into an image, single-character detection and segmentation are performed, and the characters are identified using a single-character recognition model. The identified individual characters are merged into phrases based on their position and context information, and word order is corrected to restore the semantics of the text; The finally identified text and its location information are generated into a CAD text object, which is then written back to the target CAD file.

2. The method for vector text recognition and reconstruction in CAD drawings according to claim 1, characterized in that, The attribute information includes at least one of the following: line width, color, line type, layer information, and drawing order.

3. The method for vector text recognition and reconstruction in CAD drawings according to claim 1, characterized in that, The process of performing connectivity analysis on the filtered lines and identifying potential text regions based on a spatial density clustering algorithm includes: Calculate the geometric dimensional features of each connected component; Based on a preset size threshold, connected components that are too large or too small are filtered out. The remaining connected components are projected onto a plane, and a density-based clustering algorithm is used to generate one or more candidate regions for text blocks.

4. The method for vector text recognition and reconstruction in CAD drawings according to claim 1, characterized in that, The step of rendering the vector lines within the text area into an image, performing single-character detection and segmentation, and recognizing characters using a single-character recognition model includes: Each candidate text region is rendered at high resolution to generate a binary or grayscale bitmap; Locate the word boundaries on the rendered image and segment the vector strokes into individual characters; Extract at least one of the geometric features, statistical features, topological features, and shape descriptors from each single character stroke set to construct a drawing-level font library.

5. The method for vector text recognition and reconstruction in CAD drawings according to claim 4, characterized in that, The single-character recognition adopts a combination of direct matching and visual recognition, wherein: the direct matching is used to compare the features of the single character to be recognized with the template in the drawing-level font library; the visual recognition adopts an OCR model finely adjusted by engineering drawing text samples for recognition.

6. The method for vector text recognition and reconstruction in CAD drawings according to claim 5, characterized in that, The method further includes: The high-confidence recognition results or manually confirmed recognition results and their stroke features are updated to the drawing-level character library for template matching in subsequent recognition tasks.

7. The method for vector text recognition and reconstruction in CAD drawings according to claim 1, characterized in that, The process of merging identified single characters into phrases based on their position and context information, and performing word order correction to restore text semantics, includes: Based on the alignment of individual characters, character spacing, and engineering dictionary, heuristic rules are used to merge adjacent characters into word groups; Statistical language models or pre-trained language models are used to sort and correct the merged candidate word groups in order to correct word order and spelling errors.

8. A device for vector text recognition and reconstruction in CAD drawings, characterized in that, The device includes: The parsing module is used to parse the input PDF file and extract all vector elements and their attribute information. The filtering module is used to group the vector elements according to their attribute information in order to filter out candidate lines for text strokes. The detection module is used to perform connectivity analysis on the filtered lines and identify potential text regions based on the spatial density clustering algorithm. The recognition module is used to render the vector lines in the text area into an image, perform single character detection and segmentation, and recognize the characters using a single character recognition model; The semantic reconstruction module is used to merge the identified single characters into phrases based on their position and context information, and to perform word order correction in order to restore the semantics of the text; The write-back module is used to generate CAD text objects from the finally recognized text and its location information, and write them back to the target CAD file.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores program code that can run on the processor. When the program code is executed by the processor, it implements the method for vector text recognition and reconstruction of CAD drawings as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program code that can be invoked by one or more processors to execute the method for vector text recognition and reconstruction of CAD drawings as described in any one of claims 1-7.