Circuit diagram generation method and device for physics, chemistry and biology experiment teaching, and medium
By combining circuit component detection and terminal identification models with a depth-first search algorithm to generate circuit diagrams, the problem of accuracy and efficiency in circuit diagram checking in electrical experiment teaching is solved, and efficient and accurate circuit diagram generation and real-time feedback are achieved.
Patent Information
- Application Number
- CN202510166769.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-02-14
AI Technical Summary
In electrical experiment teaching, it is difficult for teachers to quickly and accurately check the circuit diagrams connected by students, which is time-consuming, laborious, and prone to errors.
The circuit element detection model is used to extract the category and location bounding box information of the circuit elements. Combined with the circuit terminal detection model, the connection status is identified. The wire segmentation results are obtained through image processing, and the depth-first search algorithm is applied to generate the circuit diagram.
It improves the accuracy and efficiency of circuit identification, ensures that the generated circuit diagrams match the actual connection situation, reduces the teacher's inspection time, and provides immediate feedback.
Smart Images

Figure CN119991864B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, specifically to a method, device, and medium for generating circuit diagrams for physics, chemistry, and biology experimental teaching. Background Technology
[0002] Electricity is an important component of junior high school physics experiments. During electricity experiment teaching, teachers often find it difficult to promptly check the correctness of circuit diagrams connected by multiple students. This process is not only time-consuming and laborious but can also be inaccurate due to human error. Therefore, there is an urgent need for a method that can automatically identify the circuits connected by students and generate corresponding circuit diagrams, providing a reliable basis for subsequent judgment on whether the circuit diagrams meet the requirements. Summary of the Invention
[0003] The purpose of this invention is to provide a method, device, and medium for generating circuit diagrams for physics, chemistry, and biology experimental teaching, so as to solve at least one technical problem in the background art.
[0004] To achieve the above objectives, the present invention provides the following technical solution:
[0005] In a first aspect, embodiments of the present invention provide a method for generating circuit diagrams for physics, chemistry, and biology experimental teaching, the method comprising the following steps:
[0006] Obtain a circuit connection image with completed circuit connections; use a circuit element detection model to extract the category and location box information of the circuit elements from the circuit connection image; use a circuit terminal detection model to identify the connection status of the circuit element terminals; and bind the identified circuit element terminals to their respective circuit elements.
[0007] The circuit connection image is processed, and a binary image of wire segmentation result is obtained based on the position box information of the circuit elements; the wire-element connection information of all wires is obtained based on the binary image of wire segmentation result.
[0008] The wire-component connection information is converted into a dictionary of component connection information between circuit components. A depth-first search algorithm is applied to the component connection information dictionary to obtain the circuit drawing path. An electrical symbol drawing method library is built using OpenCV, and the final circuit diagram is generated based on the circuit drawing path.
[0009] Preferably, the step of using a circuit terminal detection model to identify the connection status of circuit element terminals includes:
[0010] The circuit terminal detection model is used to detect the terminals of circuit elements in the circuit connection image. When the terminal of the circuit element is not connected to the U-shaped fork or alligator clip of the wire, the terminal is regarded as background and no result is output. When the terminal of the circuit element is connected to the wire, the position box information of the terminal is used as the output result.
[0011] Preferably, obtaining the binary image of the conductor segmentation result includes:
[0012] Threshold segmentation is performed on wires of a specific color in the circuit connection image to obtain a first wire segmentation result;
[0013] The circuit connection image is smoothed by Gaussian blurring, and then the Canny edge detection algorithm is applied to obtain the second wire segmentation result;
[0014] Perform an AND operation on the first wire segmentation result and the second wire segmentation result to obtain a preliminary wire segmentation result binary image;
[0015] Based on the location box information of the circuit elements, the pixel values within the location box information of all circuit elements are set to 0 in the preliminary wire segmentation result binary image to obtain the final wire segmentation result binary image.
[0016] In this context, a pixel value of 1 represents a wire pixel, and a pixel value of 0 represents a background pixel.
[0017] Preferably, thresholding is performed on wires of a specific color in the circuit connection image to obtain a first wire segmentation result, including:
[0018] Predefine wire colors, including red, black, and blue;
[0019] The circuit connection image is segmented using the HSV color space thresholding method based on the wire color to obtain binary images of different color segmentation results.
[0020] Perform an OR operation on all the segmented binary images to obtain the first wire segmentation result.
[0021] Preferably, obtaining the wire-component connection information of all wires based on the binary image of the wire segmentation result includes the following steps:
[0022] S11, obtain the point set of each wire based on the binary image of the wire segmentation result;
[0023] S12, Perform convex hull detection on the point set of each wire to obtain the convex point set of each wire; where a convex point represents a point or endpoint where the wire bends;
[0024] S13, perform principal component analysis on the set of convex points of each wire to obtain the principal component direction of the wire, and take the pair of convex points that are farthest apart along the principal component direction as the two endpoints of the wire.
[0025] S14, expand the position box of all circuit elements by a custom ratio, traverse the bumps of each wire and check if there is a bump in the position box of a certain circuit element. If there is no bump, it means that the wire is not connected to this circuit element. If there is a bump, it means that there is a potential connection between the wire and this circuit element.
[0026] S15, when there is a potential connection between the wire and a certain circuit element, check whether there is a terminal block in this circuit element. If there is, find the nearest pair of bump-terminal blocks and determine the distance between the pair of bump-terminal blocks and the preset distance threshold. If there is no connection, proceed to the next circuit element.
[0027] S16, Traverse all wires and repeat the operation of step S15 to obtain the wire-component connection information at both ends of all wires.
[0028] Preferably, in step S15, determining the distance between the pair of protrusions and terminals and the preset distance threshold specifically involves:
[0029] Determine whether the distance between the protrusion and the terminal exceeds a preset distance threshold. If it does, filter it out; otherwise, bind the wire to the terminal of this circuit element.
[0030] The formula for calculating the preset distance threshold thr is as follows:
[0031] x represents a custom scale, 0 < x < 100; w represents the width of the circuit element's location box; h represents the height of the circuit element's location box.
[0032] Preferably, in the component connection information dictionary, the key represents the current circuit component, and the value represents a list of components that are connected to the current circuit component by wires.
[0033] If the circuit elements connected by the wire are in parallel, then there are circuit elements in the element set list that are connected by the wire twice; if the circuit elements connected by the wire are in series, then there are circuit elements in the element set list that are connected by the wire once.
[0034] Preferably, applying a depth-first search algorithm to the component connection information dictionary to obtain the circuit drawing path includes:
[0035] The circuit element whose initial position is determined in the component connection information dictionary;
[0036] Sort the connection order of the circuit components;
[0037] Check whether the component connection information dictionary forms a closed circuit;
[0038] Output the circuit drawing path.
[0039] Secondly, embodiments of this application provide an electronic device, including a memory and a processor, wherein the memory is electrically connected to the processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the method described above.
[0040] Thirdly, embodiments of this application provide a storage medium storing a computer program, which, when executed by a processor, implements the method described above.
[0041] The beneficial effects of this invention are as follows: By extracting the connection between the endpoints of wires and the terminals of identification components, and binding the wire endpoints to the connected terminals, a large number of false component connections are filtered out, improving the accuracy of circuit identification. Furthermore, the connection information of the identified circuits is analyzed to check the integrity of the circuit and a circuit diagram renderer is used to generate a circuit diagram corresponding to the circuit connection image. Therefore, by combining computer vision and deep learning technologies, this invention significantly improves the accuracy of circuit identification and the efficiency of circuit diagram generation. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 A flowchart illustrating the steps of a circuit diagram generation method for physics, chemistry, and biology experimental teaching, provided in this application embodiment;
[0044] Figure 2 A schematic diagram of circuit connection images provided for embodiments of this application;
[0045] Figure 3 A schematic diagram of the binary image of the wire segmentation result provided in the embodiments of this application;
[0046] Figure 4 This is a schematic diagram of wire-component connection information provided in an embodiment of this application;
[0047] Figure 5A schematic diagram of the circuit diagram provided in the embodiments of this application.
[0048] Figure 6 A schematic diagram of a circuit diagram generation system for physics, chemistry, and biology experimental teaching provided in this application embodiment;
[0049] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0050] The following will provide a clear and complete description of the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, solution, and effects of the present invention. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of the present invention can be combined with each other.
[0051] In related technologies, in scenarios requiring user identity verification such as access control and attendance, access cards and facial recognition are mostly used for identity verification. However, access cards are susceptible to fraudulent use, while facial recognition often only collects the user's facial information, resulting in incomplete personal information.
[0052] Please see Figure 1 This application provides a method for generating circuit diagrams for physics, chemistry, and biology experimental teaching, including the following steps:
[0053] S100: Obtain a circuit connection image with completed circuit connections; use a circuit element detection model to extract the category and location box information of circuit elements from the circuit connection image; use a circuit terminal detection model to identify the connection status of circuit element terminals; and bind the identified circuit element terminals to their respective circuit elements.
[0054] S200, perform image processing on the circuit connection image, and obtain a binary image of wire segmentation results based on the position box information of the circuit elements; obtain wire-element connection information of all wires based on the binary image of wire segmentation results;
[0055] S300, the wire-component connection information is converted into a component connection information dictionary between circuit components, a depth-first search algorithm is applied to the component connection information dictionary to obtain the circuit drawing path, an electrical symbol drawing method library is built using OpenCV, and the final circuit diagram is generated based on the circuit drawing path.
[0056] Specifically, current methods for identifying circuit diagrams mainly have two problems: first, how to extract the pixels of wires and determine the components connected at both ends, as well as extract the connection information of all components in the circuit, using computer vision methods; and second, how to generate a circuit symbol diagram corresponding to the actual screen from the extracted circuit connection information. Therefore, in response to the above two problems, this application proposes the above-mentioned circuit diagram generation method for physics, chemistry, and biology experimental teaching, which includes three parts: circuit identification, circuit information analysis, and circuit diagram generation.
[0057] Regarding the circuit identification part: First, an image of the completed circuit connection is acquired; then, a circuit element detection model is used to extract the category and location box information of the circuit elements from the circuit connection image; next, a circuit terminal detection model is used to identify the connection status of the circuit element terminals, and then the identified circuit element terminals are bound to their respective circuit elements.
[0058] Regarding the circuit information parsing section: First, image processing is performed on the circuit connection image, and a binary image of the wire segmentation result is obtained based on the position box information of the circuit components; then, the wire-component connection information of all wires is obtained based on the binary image of the wire segmentation result.
[0059] Regarding the circuit diagram generation part: First, the wire-component connection information is converted into a dictionary of component connection information between circuit components; then, a depth-first search algorithm is applied to the component connection information dictionary to obtain the circuit drawing path; finally, an electrical symbol drawing method library is built using OpenCV, and the final circuit diagram is generated based on the circuit drawing path.
[0060] This application improves the accuracy of circuit identification by extracting the connection information between the endpoints of wires and the terminals of identified components, and binding the wire endpoints to the connected terminals to filter out a large number of spurious component connections. Furthermore, it analyzes the connection information of the identified circuits, checks the integrity of the circuits, and uses a circuit diagram renderer to generate a circuit diagram corresponding to the circuit connection image. Therefore, this application, by combining computer vision and deep learning technologies, significantly improves the accuracy of circuit identification and the efficiency of circuit diagram generation.
[0061] It is understood that the methods for obtaining the above-mentioned circuit connection images include, but are not limited to: obtaining the circuit connection image with completed circuit connections from a video stream, or obtaining the circuit connection image from an actual circuit with completed circuit connections submitted by the experimenter. For example... Figure 2 As shown, it is a circuit connection image obtained from a video stream.
[0062] It should be noted that the above-mentioned methods of obtaining images are only two possible approaches listed in this application, and are not limited to the above two methods. This application does not specifically limit the method of obtaining circuit connection images, and any other method that can obtain circuit connection images that have been completed is within the protection scope of this application.
[0063] In one embodiment provided in this application, the step of identifying the connection status of circuit element terminals using a circuit terminal detection model includes:
[0064] The circuit terminal detection model is used to detect the terminals of circuit elements in the circuit connection image. When the terminal of the circuit element is not connected to the U-shaped fork or alligator clip of the wire, the terminal is regarded as background and no result is output. When the terminal of the circuit element is connected to the wire, the position box information of the terminal is used as the output result.
[0065] In one embodiment provided in this application, obtaining the binary image of the conductor segmentation result includes:
[0066] Threshold segmentation is performed on wires of a specific color in the circuit connection image to obtain a first wire segmentation result;
[0067] The circuit connection image is smoothed by Gaussian blurring, and then the Canny edge detection algorithm is applied to obtain the second wire segmentation result;
[0068] Perform an AND operation on the first wire segmentation result and the second wire segmentation result to obtain a preliminary wire segmentation result binary image;
[0069] Based on the location box information of the circuit elements, the pixel values within the location box information of all circuit elements are set to 0 in the preliminary wire segmentation result binary image to obtain the final wire segmentation result binary image.
[0070] In this context, a pixel value of 1 represents a wire pixel, and a pixel value of 0 represents a background pixel.
[0071] Specifically, in this embodiment, Gaussian blur is used to smooth the circuit connection image to eliminate minor noise. Then, the Canny edge detection algorithm is applied to obtain the second wire segmentation result. At this time, the second wire segmentation result will contain the edge contours of many non-wire regions, so further processing is required. Performing an AND operation on the first and second wire segmentation results can retain the results that simultaneously conform to the wire color and wire body edge segmentation, and thus obtain a preliminary wire segmentation result binary image. At this time, the wire segmentation result will effectively filter out non-wire body shapes of the same color and line body contours that do not match the color. Here, a pixel value of 1 represents that the pixel is a wire pixel, and a pixel value of 0 represents a background pixel. At this time, the segmentation result may contain the contours of circuit elements, making it impossible for the wires to be independent. In the preliminary wire segmentation result binary image, the pixel values in the location box information of all circuit elements are assigned to 0. This operation can truncate the wires and make the wires into mutually independent contour point sets.
[0072] like Figure 3 As shown, it is a binary image of the wire segmentation result obtained after using the circuit wire segmentation algorithm in this embodiment.
[0073] In one embodiment provided in this application, threshold segmentation is performed on wires of a specific color in the circuit connection image to obtain a first wire segmentation result, including:
[0074] Predefine wire colors, including red, black, and blue;
[0075] The circuit connection image is segmented using the HSV color space thresholding method based on the wire color to obtain binary images of different color segmentation results.
[0076] Perform an OR operation on all the segmented binary images to obtain the first wire segmentation result.
[0077] Specifically, in this embodiment, threshold segmentation is performed on wires of a specific color in a circuit connection image. First, common wire colors such as red, black, and blue are predefined. Then, the HSV color space pixel threshold segmentation method of the above colors is applied to the image to obtain binary images of segmentation results for different colors. An OR operation is performed on all the binary images of segmentation results to obtain the first wire segmentation result. At this time, the first wire segmentation result will contain a relatively large number of non-wire region contours.
[0078] It should be noted that the "AND" and "OR" operations mentioned above refer to basic logical operations applied when processing binary images or masks. The "AND" operation in this application's image processing is used to combine two images or masks, retaining positions where both are "1" (white or True). That is, the result is "1" only when both images are "1" at the same position; otherwise, the result is "0". The "OR" operation in this application's image processing is used to merge two images or masks, retaining positions where at least one of the two images is "1" (white or True). That is, the result will be "1" as long as either image is "1" at the same position.
[0079] In one embodiment provided in this application, obtaining the wire-component connection information of all wires based on the binary image of the wire segmentation result includes the following steps:
[0080] S11, obtain the point set of each wire based on the binary image of the wire segmentation result;
[0081] S12, Perform convex hull detection on the point set of each wire to obtain the convex point set of each wire; where a convex point represents a point or endpoint where the wire bends;
[0082] S13, perform principal component analysis on the set of convex points of each wire to obtain the principal component direction of the wire, and take the pair of convex points that are farthest apart along the principal component direction as the two endpoints of the wire.
[0083] S14. Expand the position boxes of all circuit elements by a custom ratio, traverse the protrusions of each wire and check if there is a protrusion within the position box of a certain circuit element. If there is no protrusion, it means that the wire is not connected to this circuit element. If there is a protrusion, it means that there is a potential connection between the wire and this circuit element. It should be noted that at this time, it may only be that some wires cross the element and there is no actual connection.
[0084] S15, when there is a potential connection between the wire and a certain circuit element, check whether there is a terminal block in this circuit element. If there is, find the nearest pair of bump-terminal blocks and determine the distance between the pair of bump-terminal blocks and the preset distance threshold. If there is no connection, proceed to the next circuit element.
[0085] S16, Traverse all wires and repeat the operation of step S15 to obtain the wire-component connection information at both ends of all wires.
[0086] like Figure 4 As shown, it is a schematic diagram of the wire-component connection information of all wires in this embodiment.
[0087] In one embodiment provided in this application, in step S15, determining the distance between the pair of protrusions and terminals and the preset distance threshold specifically involves:
[0088] Determine whether the distance between the protrusion and the terminal exceeds a preset distance threshold. If it does, filter it out; otherwise, bind the wire to the terminal of this circuit element.
[0089] The formula for calculating the preset distance threshold thr is as follows:
[0090] x represents a custom scale, 0 < x < 100; w represents the width of the circuit element's location box; h represents the height of the circuit element's location box.
[0091] In one embodiment provided in this application, in the component connection information dictionary, the key represents the current circuit component, and the value represents a list of components connected to the current circuit component by wires.
[0092] If the circuit elements connected by the wire are in parallel, then there are circuit elements in the element set list that are connected by the wire twice; if the circuit elements connected by the wire are in series, then there are circuit elements in the element set list that are connected by the wire once.
[0093] Specifically, in this embodiment, the circuit elements are analyzed to determine whether they are connected in parallel or in series based on the wire-component connection information. If they are connected in parallel, the circuit element will appear twice in the component set list; if they are connected in series, they will appear only once.
[0094] In one embodiment provided in this application, applying a depth-first search algorithm to the component connection information dictionary to obtain the circuit drawing path includes:
[0095] The circuit element whose initial position is determined in the component connection information dictionary;
[0096] Sort the connection order of the circuit components;
[0097] Check whether the component connection information dictionary forms a closed circuit;
[0098] Output the circuit drawing path.
[0099] Specifically, this embodiment performs a depth-first search algorithm on the component connection information dictionary. Starting with "battery pack" as the beginning of the circuit diagram, it first sorts the serial connection order of the components in the circuit diagram (at this time, parallel components are considered as one element), then checks whether the component connection information dictionary can form a closed circuit diagram, and finally outputs the path of the drawn circuit. Figure 5 As shown, it is the basis for this application. Figure 1The generated circuit diagram, with Figure 5 For example, the final output path is: {'Battery pack', 'Switch-Off', 'Sliding rheostat', 'Ammeter', ['Resistor', 'Voltmeter']}.
[0100] It should be noted that the electrical symbol drawing method library built using OpenCV defines various methods for drawing common circuit components, including methods for drawing components in parallel. Each method draws the corresponding circuit component image on a blank canvas of a specified size. In the process of generating the final circuit diagram based on the circuit drawing path, the circuit diagram is first initialized by setting the "battery pack" as the start of the circuit diagram. The appropriate number of components is arranged on the four sides of the circuit diagram according to the number of circuit components, and the spacing between components is calculated. Then, the circuit component symbols are drawn sequentially according to the circuit drawing path, and finally, the circuit diagram is generated.
[0101] Therefore, in summary, this application has the following beneficial effects:
[0102] (1) Improve the accuracy of circuit identification:
[0103] Accurate identification of wires and components: By extracting the connection between the wire endpoints and the terminals of the identified components, and binding the wire endpoints to the connected terminals, a large number of false component connections are effectively filtered out, improving the accuracy of circuit identification.
[0104] Circuit integrity check: The extracted circuit connection information is parsed to check the integrity of the circuit and ensure that the generated circuit diagram matches the actual connection situation.
[0105] (2) Generate high-quality circuit diagrams:
[0106] Automatic generation of circuit diagrams: Using a circuit diagram renderer, circuit symbol diagrams corresponding to the actual screen are generated based on the extracted circuit connection information, ensuring the standardization and readability of the generated circuit diagrams.
[0107] (3) Improve the efficiency and quality of experimental teaching:
[0108] Automated grading: Automatically generated circuit diagrams can serve as the basis for subsequent grading, reducing the time and workload of teachers' manual checks and improving the efficiency and consistency of grading.
[0109] Instant feedback: Students can receive the generated circuit diagrams and scoring feedback instantly, helping them to identify and correct errors in a timely manner and improve learning outcomes.
[0110] In summary, this application, by combining computer vision and deep learning technologies, effectively solves the problems existing in traditional circuit recognition and circuit diagram generation, providing an efficient, accurate, and reliable solution for physics, chemistry, and biology experimental teaching, and has significant application value and broad development prospects.
[0111] like Figure 6 As shown, this application provides a circuit diagram generation system for physics, chemistry, and biology experiment teaching, which applies the circuit diagram generation method described above, including:
[0112] Circuit recognition module: acquires a circuit connection image with completed circuit connections; extracts the category and location box information of circuit elements from the circuit connection image using a circuit element detection model; identifies the connection status of circuit element terminals using a circuit terminal detection model; and binds the identified circuit element terminals to their respective circuit elements.
[0113] Circuit information parsing module: performs image processing on the circuit connection image and obtains a binary image of wire segmentation results based on the position box information of circuit components; obtains wire-component connection information of all wires based on the binary image of wire segmentation results;
[0114] Circuit diagram generation module: converts the wire-component connection information into a dictionary of component connection information between circuit components; applies a depth-first search algorithm to the component connection information dictionary to obtain the circuit drawing path; uses OpenCV to build an electrical symbol drawing method library and generates the final circuit diagram based on the circuit drawing path.
[0115] and Figure 1 The corresponding method is referenced. Figure 7 This invention provides an electronic device, including a memory and a processor, wherein the memory is electrically connected to the processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the method described above.
[0116] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0117] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor implements the steps of a circuit diagram generation method for physics, chemistry, and biology experimental teaching as described in any of the above embodiments. The specific execution process can be found in the detailed description of the above embodiments, and will not be repeated here.
[0118] It is evident that the content of the above method embodiments is applicable to this medium embodiment. The specific functions implemented in this medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0119] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0120] Those skilled in the art will understand that all or some of the methods and systems disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0121] The above is a detailed description of the preferred embodiments of this disclosure. However, this disclosure is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this disclosure. All such equivalent modifications or substitutions are included within the scope defined by the claims of this disclosure.
Claims
1. A method for generating circuit diagrams for physics, chemistry, and biology experimental teaching, characterized in that: Includes the following steps: Obtain a circuit connection image with completed circuit connections; use a circuit element detection model to extract the category and location box information of the circuit elements from the circuit connection image; use a circuit terminal detection model to identify the connection status of the circuit element terminals; and bind the identified circuit element terminals to their respective circuit elements. The circuit connection image is processed, and a binary image of wire segmentation result is obtained based on the position box information of the circuit elements; the wire-element connection information of all wires is obtained based on the binary image of wire segmentation result. The wire-component connection information is converted into a component connection information dictionary between circuit components. A depth-first search algorithm is applied to the component connection information dictionary to obtain the circuit drawing path. An electrical symbol drawing method library is built using OpenCV, and the final circuit diagram is generated based on the circuit drawing path. The step of obtaining the wire-component connection information of all wires based on the binary image of the wire segmentation result includes the following steps: S11, obtain the point set of each wire based on the binary image of the wire segmentation result; S12, Perform convex hull detection on the point set of each wire to obtain the convex point set of each wire; where a convex point represents a point or endpoint where the wire bends; S13, perform principal component analysis on the set of convex points of each wire to obtain the principal component direction of the wire, and take the pair of convex points that are farthest apart along the principal component direction as the two endpoints of the wire. S14, expand the position box of all circuit elements by a custom ratio, traverse the bumps of each wire and check if there is a bump in the position box of a certain circuit element. If there is no bump, it means that the wire is not connected to this circuit element. If there is a bump, it means that there is a potential connection between the wire and this circuit element. S15, when there is a potential connection between the wire and a certain circuit element, check whether there is a terminal block in this circuit element. If there is, find the nearest pair of bump-terminal blocks and determine the distance between the pair of bump-terminal blocks and the preset distance threshold. If there is no connection, proceed to the next circuit element. S16, Traverse all wires and repeat the operation of step S15 to obtain the wire-component connection information at both ends of all wires.
2. The circuit diagram generation method for physics, chemistry, and biology experiment teaching according to claim 1, characterized in that: The method of using a circuit terminal detection model to identify the connection status of circuit element terminals includes: The circuit terminal detection model is used to detect the terminals of circuit elements in the circuit connection image. When the terminal of the circuit element is not connected to the U-shaped fork or alligator clip of the wire, the terminal is regarded as background and no result is output. When the terminal of the circuit element is connected to the wire, the position box information of the terminal is used as the output result.
3. The circuit diagram generation method for physics, chemistry, and biology experiment teaching according to claim 1, characterized in that: The process of obtaining the binary image of the conductor segmentation result includes: Threshold segmentation is performed on wires of a specific color in the circuit connection image to obtain a first wire segmentation result; The circuit connection image is smoothed by Gaussian blurring, and then the Canny edge detection algorithm is applied to obtain the second wire segmentation result; Perform an AND operation on the first wire segmentation result and the second wire segmentation result to obtain a preliminary wire segmentation result binary image; Based on the location box information of the circuit elements, the pixel values within the location box information of all circuit elements are set to 0 in the preliminary wire segmentation result binary image to obtain the final wire segmentation result binary image. In this context, a pixel value of 1 represents a wire pixel, and a pixel value of 0 represents a background pixel.
4. The circuit diagram generation method for physics, chemistry, and biology experiment teaching according to claim 3, characterized in that: Thresholding segmentation is performed on wires of a specific color in the circuit connection image to obtain a first wire segmentation result, including: Predefine wire colors, including red, black, and blue; The circuit connection image is segmented using the HSV color space thresholding method based on the wire color to obtain binary images of different color segmentation results. Perform an OR operation on all the segmented binary images to obtain the first wire segmentation result.
5. The circuit diagram generation method for physics, chemistry, and biology experiment teaching according to claim 1, characterized in that: In step S15, determining the distance between the pair of protrusions and terminals and the preset distance threshold specifically involves: Determine whether the distance between the protrusion and the terminal exceeds a preset distance threshold. If it does, filter it out; otherwise, bind the wire to the terminal of this circuit element. Among them, the preset distance threshold The calculation formula is: ; x represents a custom scale, 0 < x < 100; w represents the width of the circuit element's location box; h represents the height of the circuit element's location box.
6. The circuit diagram generation method for physics, chemistry, and biology experiment teaching according to claim 1, characterized in that: In the component connection information dictionary, the key represents the current circuit component, and the value represents a list of components that are connected to the current circuit component by wires. If the circuit elements connected by the wire are in parallel, then there are circuit elements in the element set list that are connected by the wire twice; if the circuit elements connected by the wire are in series, then there are circuit elements in the element set list that are connected by the wire once.
7. The circuit diagram generation method for physics, chemistry, and biology experiment teaching according to claim 1, characterized in that: The process of applying a depth-first search algorithm to the component connection information dictionary to obtain the circuit drawing path includes: The circuit element whose initial position is determined in the component connection information dictionary; Sort the connection order of the circuit components; Check whether the component connection information dictionary forms a closed circuit; Output the circuit drawing path.
8. An electronic device comprising a memory and a processor, the memory being electrically connected to the processor, the memory storing a computer program, characterized in that: When the computer program is executed by the processor, it causes the processor to implement the method as described in any one of claims 1 to 7.
9. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor implements the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Physical circuit experiment automatic identification method
CN114677586A