Circuit diagram generation method and device for physical and chemical student experiment teaching, and medium
By using circuit component detection models and circuit terminal detection models in electrical experimental teaching, combined with image processing and depth-first search algorithms, circuit diagrams are generated, which solves the problem that teachers find it difficult for students to check the circuit diagrams in a timely and accurate manner, and improves the efficiency and accuracy of circuit identification and graph generation.
Patent Information
- Application Number
- CN202510166769.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-02-14
AI Technical Summary
In electrical experimental teaching, it is difficult for teachers to check the circuit diagrams connected to multiple students in a timely and accurate manner, which makes them time-consuming and labor-intensive and prone to human errors.
The circuit component detection model and the circuit terminal detection model are used to extract the category and position frame information of the circuit components from the circuit connection image, identify the connection status of the circuit component terminals, and generate the circuit diagram through image processing and depth-first search algorithm.
It improves the accuracy of circuit identification and the efficiency of circuit diagram generation, reduces the time and workload of manual inspection by teachers, and ensures the standardization and readability of the generated circuit diagrams.
Smart Images

Figure CN119991864A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a circuit diagram generation method, device and medium for physics, chemistry and biology experiment teaching. Background Art
[0002] Electricity is an important part of junior high school physics experiments. In the process of electrical experiment teaching, it is often difficult for teachers to check whether the circuit diagrams connected by multiple students are correct in time. This process is not only time-consuming and laborious, but may also lead to inaccurate inspections due to human factors. Therefore, there is an urgent need for a method that can automatically identify the circuits connected by students and generate the corresponding circuit diagrams, providing a reliable basis for subsequent judgment of whether the circuit diagrams meet the requirements. Summary of the invention
[0003] The present invention aims to provide a circuit diagram generation method, device and medium for physics, chemistry and biology experiment teaching, so as to solve at least one technical problem in the background technology.
[0004] In order to achieve the above object, the present invention provides the following technical solutions:
[0005] In a first aspect, an embodiment of the present invention provides a circuit diagram generation method for physical, chemical and biological experiment teaching, the method comprising the following steps:
[0006] Acquire a circuit connection image in which the circuit connection has been completed, extract the category and position frame information of the circuit element from the circuit connection image using a circuit element detection model, and identify the connection status of the circuit element terminal using a circuit terminal detection model; bind the identified circuit element terminal to the circuit element to which it belongs;
[0007] Performing image processing on the circuit connection image, and obtaining a binary image of the wire segmentation result based on the position frame information of the circuit element; obtaining wire-component connection information of all wires based on the binary image of the wire segmentation result;
[0008] 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 a circuit drawing path, an electrical symbol drawing method library is constructed using OpenCV, and a final circuit diagram is generated based on the circuit drawing path.
[0009] Preferably, the method of using a circuit terminal detection model to identify the connection status of a circuit element terminal includes:
[0010] The circuit terminal detection model is used to detect the terminals of the circuit elements in the circuit connection image. When the terminals of the circuit elements are not connected to the U-shaped fork or the alligator clip of the wire, the terminals are regarded as the background and no results are output; when the terminals of the circuit elements are connected to the wire, the location box information of the terminals is used as the output result.
[0011] Preferably, obtaining a binary image of the wire segmentation result includes:
[0012] Performing threshold segmentation on the wires of a specific color in the circuit connection image to obtain a first wire segmentation result;
[0013] Gaussian blur is used to smooth the circuit connection image, and then a Canny edge detection algorithm is applied to obtain a second wire segmentation result;
[0014] Performing 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 position frame information of the circuit element, in the preliminary wire segmentation result binary image, all pixel values in the circuit element position frame information are assigned to 0 to obtain the final wire segmentation result binary image;
[0016] Among them, a pixel value of 1 represents a wire pixel, and a pixel value of 0 represents a background pixel.
[0017] Preferably, performing threshold segmentation on the wires of a specific color in the circuit connection image to obtain a first wire segmentation result includes:
[0018] Predefined wire colors including red, black and blue;
[0019] Applying the HSV color space threshold segmentation method of the wire color to perform threshold segmentation on the circuit connection image to obtain a binary image of the segmentation result with different colors;
[0020] An OR operation is performed on all the segmentation result binary images to obtain the first wire segmentation result.
[0021] Preferably, the obtaining of the wire-component connection information of all wires based on the wire segmentation result binary image comprises the following steps:
[0022] S11, obtaining a point set of each wire based on the wire segmentation result binary image;
[0023] S12, performing convex hull detection on the point set of each wire to obtain a convex point set of each wire; wherein the convex point represents a point or an end point where the wire is bent;
[0024] S13, performing principal component analysis on the set of convex points of each wire to obtain the principal component direction of the wire, and taking a pair of convex points that are farthest apart along the principal component direction as two endpoints of the wire;
[0025] S14, expanding the position boxes of all circuit elements at a custom ratio, traversing the bumps of each wire and searching whether there is a bump in the position box of a circuit element, if not, it means that the wire has no connection relationship with the circuit element, if yes, it means that there is a potential connection relationship between the wire and the circuit element;
[0026] S15, when there is a potential connection relationship between the wire and a certain circuit element, check whether there is a terminal for this circuit element, if so, find the closest pair of bumps and terminals, and determine the distance between the pair of bumps and terminals and the preset distance threshold; if not, proceed to determine the next circuit element;
[0027] S16, traverse all wires and repeat the operation of step S15, so as to obtain wire-component connection information at both ends of all wires.
[0028] Preferably, in step S15, the determining of the distance between the pair of bumps and the terminal and a preset distance threshold is specifically as follows:
[0029] Determine whether the distance between the bump and the terminal exceeds a preset distance threshold, if so, filter it, otherwise bind the wire to the terminal of this circuit element;
[0030] The calculation formula of the preset distance threshold thr is:
[0031] x represents a custom ratio, 0<x<100; w represents the width of the location box of the circuit element; h represents the height of the location box of the circuit element.
[0032] Preferably, in the component connection information dictionary, key represents the current circuit component, and value represents a list of component sets connected to the current circuit component by wires;
[0033] Among them, if the circuit elements connected by wires are connected in parallel, then the circuit elements connected by wires exist twice in the element set list; if the circuit elements connected by wires are connected in series, then the circuit elements connected by wires exist once in the element set list.
[0034] Preferably, applying a depth-first search algorithm to the component connection information dictionary to obtain a circuit drawing path comprises:
[0035] Determining the circuit elements of the initial position in the element connection information dictionary;
[0036] Sort the connection order of circuit elements;
[0037] checking whether the component connection information dictionary forms a closed circuit;
[0038] The circuit drawing path is output.
[0039] In a second aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is electrically connected to the processor, and the memory stores a computer program, and when the computer program is executed by the processor, the processor implements the method described above.
[0040] In a third aspect, an embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program. When the computer program is executed by a processor, the processor implements the method as described above.
[0041] The beneficial effects of the present invention are as follows: the present invention improves the accuracy of circuit recognition by extracting the connection between the end point of the wire and the terminal of the identification component, binding the end point of the wire with the connected terminal, filtering a large number of false component connection conditions; and also parses the connection information of the circuit recognition, checks the integrity of the circuit and uses a circuit diagram renderer to generate a circuit diagram corresponding to the circuit connection image. Therefore, the present invention significantly improves the accuracy of circuit recognition and the efficiency of circuit diagram generation by combining computer vision and deep learning technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0043] Figure 1 A flowchart of the steps of a method for generating a circuit diagram for physics, chemistry and biology experiment teaching provided in an embodiment of the present application;
[0044] Figure 2 A schematic diagram of a circuit connection image provided by an embodiment of the present application;
[0045] Figure 3 A schematic diagram of a binary image of a wire segmentation result provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of wire-component connection information provided in an embodiment of the present application;
[0047] Figure 5A schematic diagram of the structure of the circuit diagram provided in the embodiment of the present application
[0048] Figure 6 A schematic diagram of the structure of a circuit diagram generation system for physics, chemistry and biology experiment teaching provided in an embodiment of the present application;
[0049] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The following will be combined with the embodiments and drawings to clearly and completely describe the concept, specific structure and technical effects of the present invention, so as to fully understand the purpose, scheme and effect of the present invention. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other without conflict.
[0051] In the related technologies, in scenarios such as access control and attendance that require user identity authentication, most of them use access cards, facial recognition and other methods to authenticate identity. The access card method has the possibility of fraudulent use, while the facial recognition method often only collects the user's facial information, which has the problem of incomplete personal information.
[0052] See also Figure 1 The present application embodiment provides a circuit diagram generation method for physical, chemical and biological experiment teaching, comprising the following steps:
[0053] S100, obtaining a circuit connection image in which circuit connection has been completed, extracting the category and position frame information of the circuit element from the circuit connection image using a circuit element detection model, and identifying the connection status of the circuit element terminal using a circuit terminal detection model; and binding the identified circuit element terminal with the circuit element to which it belongs;
[0054] S200, performing image processing on the circuit connection image, and obtaining a binary image of the wire segmentation result based on the position frame information of the circuit element; and obtaining wire-component connection information of all wires based on the binary image of the wire segmentation result;
[0055] S300, converting the wire-component connection information into a component connection information dictionary between circuit components, applying a depth-first search algorithm to the component connection information dictionary to obtain a circuit drawing path, using OpenCV to build an electrical symbol drawing method library and generating a final circuit diagram based on the circuit drawing path.
[0056] Specifically, since there are two main problems with the current method of identifying circuit diagrams, the first is how to extract the pixels of the wires in the video screen and determine the components connected at both ends and extract the connection information of all components in the circuit through computer vision methods; the second is 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 circuit diagram generation method for physics, chemistry and biology experiment teaching, which specifically includes three parts, namely, a circuit recognition part, a circuit information analysis part and a circuit diagram generation part.
[0057] Regarding the circuit recognition part: first, obtain the circuit connection image of the completed circuit connection; then use the circuit component detection model to extract the category and position box information of the circuit component from the circuit connection image; then use the circuit terminal detection model to identify the connection status of the circuit component terminal, and then bind the identified circuit component terminal to the circuit component to which it belongs.
[0058] Regarding the circuit information analysis part: firstly, the circuit connection image is processed, and a binary image of the wire segmentation result is obtained based on the position frame 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 component connection information dictionary between circuit components; then a depth-first search algorithm is applied to the component connection information dictionary to obtain a circuit drawing path; finally, OpenCV is used to build an electrical symbol drawing method library and the final circuit diagram is generated based on the circuit drawing path.
[0060] This application improves the accuracy of circuit recognition by extracting the connection between the end point of the wire and the terminal of the identification component, binding the end point of the wire to the connected terminal, filtering out a large number of false component connections; it also analyzes the connection information of the circuit recognition, checks the integrity of the circuit and uses the circuit diagram renderer to generate a circuit diagram corresponding to the circuit connection image. Therefore, this application significantly improves the accuracy of circuit recognition and the efficiency of circuit diagram generation by combining computer vision and deep learning technology.
[0061] It is understandable that the method for obtaining the above circuit connection image includes but is not limited to: obtaining the circuit connection image of the completed circuit connection from the video stream, or obtaining the circuit connection image from the actual circuit of the completed circuit connection submitted by the experimenter. Figure 2 As shown, it is a circuit connection image obtained from the video stream.
[0062] It should be noted that the above-mentioned image acquisition methods are only two possible ways listed in this application and are not limited to the above-mentioned two acquisition methods. This application does not specifically limit the method for acquiring circuit connection images. Any other method that can obtain a circuit connection image of a completed circuit connection is within the protection scope of this application.
[0063] In an embodiment provided in the present application, the method of using a circuit terminal detection model to identify the connection status of a circuit element terminal includes:
[0064] The circuit terminal detection model is used to detect the terminals of the circuit elements in the circuit connection image. When the terminals of the circuit elements are not connected to the U-shaped fork or the alligator clip of the wire, the terminals are regarded as the background and no results are output; when the terminals of the circuit elements are connected to the wire, the location box information of the terminals is used as the output result.
[0065] In an embodiment provided in the present application, the step of obtaining a binary image of a wire segmentation result includes:
[0066] Performing threshold segmentation on the wires of a specific color in the circuit connection image to obtain a first wire segmentation result;
[0067] Gaussian blur is used to smooth the circuit connection image, and then a Canny edge detection algorithm is applied to obtain a second wire segmentation result;
[0068] Performing 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 position frame information of the circuit element, in the preliminary wire segmentation result binary image, all pixel values in the circuit element position frame information are assigned to 0 to obtain the final wire segmentation result binary image;
[0070] Among them, a pixel value of 1 represents a wire pixel, and a pixel value of 0 represents a background pixel.
[0071] Specifically, this embodiment uses Gaussian blur to smooth the circuit connection image to eliminate subtle noise, and then applies the Canny edge detection algorithm to obtain the second wire segmentation result. At this time, the second wire segmentation result will contain more edge contours of non-wire areas, so further processing is required. The first wire segmentation result and the second wire segmentation result are operated, and the results that meet the wire color and wire body edge segmentation can be retained, and a preliminary wire segmentation result binary map can be obtained. At this time, the wire segmentation result will effectively filter out the non-linear shape of the same color area and the line body contour that does not match the color; wherein, a pixel value of 1 represents that the pixel is a wire pixel, and a pixel value of 0 represents that it is a background pixel. At this time, the segmentation result may contain the outline of the circuit element, so that the wires may not be independent; and in the preliminary wire segmentation result binary map, the pixel values in all circuit element position box information are assigned to 0. This operation can truncate the wire and make the wires become 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 an embodiment provided in the present application, performing threshold segmentation on wires of a specific color in the circuit connection image to obtain a first wire segmentation result includes:
[0074] Predefined wire colors including red, black and blue;
[0075] Applying the HSV color space threshold segmentation method of the wire color to perform threshold segmentation on the circuit connection image to obtain a binary image of the segmentation result with different colors;
[0076] An OR operation is performed on all the segmentation result binary images to obtain the first wire segmentation result.
[0077] Specifically, this embodiment performs threshold segmentation on wires of specific colors in the 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 of different colors, and an OR operation is performed on all the binary images of the segmentation results to obtain a first wire segmentation result. At this time, the first wire segmentation result will contain relatively more non-wire area contours.
[0078] It should be noted that the above-mentioned "AND operation" and "OR operation" refer to the basic logical operations applied when processing binary images or masks. In the image processing of the present application, the "AND operation" (AND) is used to combine two images or masks, retaining the positions where both are "1" (white or True). That is, the result is "1" only when both images are "1" at the same position, and in other cases, the result is "0". In the image processing of the present application, the "OR operation" (OR) is used to merge two images or masks, retaining the position where at least one of the two images is "1" (white or True). That is, as long as any one of the images is "1" at the same position, the result will be "1".
[0079] In an embodiment provided in the present application, the step of obtaining the wire-component connection information of all wires based on the wire segmentation result binary image includes the following steps:
[0080] S11, obtaining a point set of each wire based on the wire segmentation result binary image;
[0081] S12, performing convex hull detection on the point set of each wire to obtain a convex point set of each wire; wherein the convex point represents a point or an end point where the wire is bent;
[0082] S13, performing principal component analysis on the set of convex points of each wire to obtain the principal component direction of the wire, and taking a pair of convex points that are farthest apart along the principal component direction as two endpoints of the wire;
[0083] S14, expanding the position boxes of all circuit components at a custom ratio, traversing the bumps of each wire and searching whether there is a bump in the position box of a certain circuit component, if not, it means that there is no connection relationship between the wire and the circuit component, if yes, it means that there is a potential connection relationship between the wire and the circuit component; it should be noted that at this time, it may be that only some wires cross the components instead of having a real connection relationship;
[0084] S15, when there is a potential connection relationship between the wire and a certain circuit element, check whether there is a terminal for this circuit element, if so, find the closest pair of bumps and terminals, and determine the distance between the pair of bumps and terminals and the preset distance threshold; if not, proceed to determine the next circuit element;
[0085] S16, traverse all wires and repeat the operation of step S15, so as to obtain 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 an embodiment provided in the present application, in step S15, the determination of the distance between the pair of bumps and the terminal and a preset distance threshold is specifically as follows:
[0088] Determine whether the distance between the bump and the terminal exceeds a preset distance threshold, if so, filter it, otherwise bind the wire to the terminal of this circuit element;
[0089] The calculation formula of the preset distance threshold thr is:
[0090] x represents a custom ratio, 0<x<100; w represents the width of the location box of the circuit element; h represents the height of the location box of the circuit element.
[0091] In an embodiment provided by the present application, in the component connection information dictionary, key represents the current circuit component, and value represents a list of component sets connected to the current circuit component by wires;
[0092] Among them, if the circuit elements connected by wires are connected in parallel, then the circuit elements connected by wires exist twice in the element set list; if the circuit elements connected by wires are connected in series, then the circuit elements connected by wires exist once in the element set list.
[0093] Specifically, this embodiment analyzes whether the circuit elements are connected in parallel or in series based on the wire-element connection information. If they are connected in parallel, the circuit element will appear twice in the element set list, and if they are connected in series, it will appear only once.
[0094] In an embodiment provided in the present application, applying a depth-first search algorithm to the component connection information dictionary to obtain a circuit drawing path includes:
[0095] Determining the circuit elements of the initial position in the element connection information dictionary;
[0096] Sort the connection order of circuit elements;
[0097] checking whether the component connection information dictionary forms a closed circuit;
[0098] The circuit drawing path is output.
[0099] Specifically, this embodiment performs a depth-first search algorithm on the component connection information dictionary, starting with the "battery pack" as the circuit diagram, first sorting the series order of the components in the circuit diagram (the parallel components are regarded as one element at this time), then checking whether the component connection information dictionary can form a closed circuit diagram, and finally outputting the path drawn by the circuit. Figure 5 As shown, this application is based on Figure 1The generated circuit diagram is Figure 5 For example, the final output path is: {'battery pack', 'switch-disconnect', 'sliding resistor', 'ammeter', ['resistance', 'voltmeter']}.
[0100] It should be noted that the above-mentioned electrical symbol drawing method library built with OpenCV defines a variety of drawing methods for common circuit elements, including drawing methods when elements are connected in parallel. Each method will draw the corresponding circuit element image on a blank canvas of a specified size; and in the process of generating the final circuit diagram based on the circuit drawing path, the circuit diagram is first initialized, the "battery pack" is set as the beginning of the circuit diagram, and the appropriate number of elements are arranged for the four sides of the circuit diagram according to the number of circuit elements, and the intervals between the elements are calculated; then the circuit element symbols are drawn in sequence 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 identification component terminals, 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] Check circuit integrity: parse the extracted circuit connection information, check the circuit integrity, and ensure that the generated circuit diagram conforms to the actual connection situation.
[0105] (2) Generate high-quality circuit diagrams:
[0106] Automatic generation of circuit diagrams: Using the circuit diagram renderer, a circuit symbol diagram corresponding to the actual screen is generated based on the extracted circuit connection information, ensuring the standardization and readability of the generated circuit diagram.
[0107] (3) Improve the efficiency and quality of experimental teaching:
[0108] Automated grading: Automatically generated circuit diagrams can be used as the basis for subsequent grading, reducing the time and workload of teachers' manual checking and improving the efficiency and consistency of grading.
[0109] Instant feedback: Students can get instant feedback on the generated circuit diagram and the scoring feedback, which helps them find and correct errors in time and improve learning effects.
[0110] In summary, this application effectively solves the problems existing in traditional circuit recognition and circuit diagram generation by combining computer vision and deep learning technology, and provides an efficient, accurate and reliable solution for physics, chemistry and biology experimental teaching. It has important application value and broad development prospects.
[0111] like Figure 6 As shown, the embodiment of the present application provides a circuit diagram generation system for physical, chemical and biological experiment teaching, which applies the circuit diagram generation method as described above, including:
[0112] Circuit recognition module: obtains a circuit connection image in which the circuit connection has been completed; uses a circuit element detection model to extract the category and position frame information of the circuit element from the circuit connection image; uses a circuit terminal detection model to identify the connection status of the circuit element terminal; binds the identified circuit element terminal to the circuit element to which it belongs;
[0113] Circuit information analysis module: performs image processing on the circuit connection image, and obtains a binary image of the wire segmentation result based on the position frame information of the circuit element; obtains wire-component connection information of all wires based on the binary image of the wire segmentation result;
[0114] Circuit diagram generation module: convert the wire-component connection information into a component connection information dictionary between circuit components; apply a depth-first search algorithm to the component connection information dictionary to obtain a circuit drawing path; use OpenCV to build an electrical symbol drawing method library and generate a final circuit diagram based on the circuit drawing path.
[0115] and Figure 1 Corresponding to the method, refer to Figure 7 An embodiment of the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory is electrically connected to the processor, and the memory stores a computer program, and when the computer program is executed by the processor, the processor implements the method described above.
[0116] It can be seen that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0117] An embodiment of the present application also provides a computer-readable storage medium, which stores 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 experiment teaching as described in any one of the above embodiments. The specific execution process can be found in the specific description of the above embodiments, which will not be repeated here.
[0118] It can be seen that the contents of the above method embodiments are all applicable to the present medium embodiments, the functions specifically implemented by the present medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0119] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0120] It will be appreciated by those skilled in the art that all or some of the methods disclosed above, the system can be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, and the computer-readable medium can include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium 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 include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0121] The above is a specific description of the preferred implementation of the present disclosure, but the present disclosure is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions without violating the spirit of the present disclosure. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present disclosure.
Claims
1. A circuit diagram generation method for physical, chemical and biological experimental teaching, characterized by: The steps include: Acquire a circuit connection image in which the circuit connection has been completed, extract the category and position frame information of the circuit element from the circuit connection image using a circuit element detection model, and identify the connection status of the circuit element terminal using a circuit terminal detection model; bind the identified circuit element terminal to the circuit element to which it belongs; Performing image processing on the circuit connection image, and obtaining a binary image of the wire segmentation result based on the position frame information of the circuit element; obtaining wire-component connection information of all wires based on the binary image of the 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 a circuit drawing path, an electrical symbol drawing method library is constructed using OpenCV, and a final circuit diagram is generated based on the circuit drawing path.
2. The circuit diagram generation method for physical, chemical and biological experiment teaching according to claim 1 is characterized by: The method of using a circuit terminal detection model to identify the connection status of a circuit element terminal includes: The circuit terminal detection model is used to detect the terminals of the circuit elements in the circuit connection image. When the terminals of the circuit elements are not connected to the U-shaped fork or the alligator clip of the wire, the terminals are regarded as the background and no results are output; when the terminals of the circuit elements are connected to the wire, the location box information of the terminals is used as the output result.
3. The circuit diagram generation method for physical, chemical and biological experiment teaching according to claim 1 is characterized by: The step of obtaining a binary image of a wire segmentation result includes: Performing threshold segmentation on the wires of a specific color in the circuit connection image to obtain a first wire segmentation result; Gaussian blur is used to smooth the circuit connection image, and then a Canny edge detection algorithm is applied to obtain a second wire segmentation result; Performing 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 position frame information of the circuit element, in the preliminary wire segmentation result binary image, all pixel values in the circuit element position frame information are assigned to 0 to obtain the final wire segmentation result binary image; Among them, 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 physical, chemical and biological experiment teaching according to claim 3 is characterized by: Performing threshold segmentation on the wires of a specific color in the circuit connection image to obtain a first wire segmentation result, comprising: Predefined wire colors including red, black and blue; Applying the HSV color space threshold segmentation method of the wire color to perform threshold segmentation on the circuit connection image to obtain a binary image of the segmentation result with different colors; An OR operation is performed on all the segmentation result binary images to obtain the first wire segmentation result.
5. The circuit diagram generation method for physical, chemical and biological experiment teaching according to claim 1 is characterized by: The method of obtaining the wire-component connection information of all wires based on the wire segmentation result binary image comprises the following steps: S11, obtaining a point set of each wire based on the wire segmentation result binary image; S12, performing convex hull detection on the point set of each wire to obtain a convex point set of each wire; wherein the convex point represents a point or an end point where the wire is bent; S13, performing principal component analysis on the set of convex points of each wire to obtain the principal component direction of the wire, and taking a pair of convex points that are farthest apart along the principal component direction as two endpoints of the wire; S14, expanding the position boxes of all circuit elements at a custom ratio, traversing the bumps of each wire and searching whether there is a bump in the position box of a circuit element, if not, it means that the wire has no connection relationship with the circuit element, if yes, it means that there is a potential connection relationship between the wire and the circuit element; S15, when there is a potential connection relationship between the wire and a certain circuit element, check whether there is a terminal for this circuit element, if so, find the closest pair of bumps and terminals, and determine the distance between the pair of bumps and terminals and the preset distance threshold; if not, proceed to determine the next circuit element; S16, traverse all wires and repeat the operation of step S15, so as to obtain wire-component connection information at both ends of all wires.
6. The circuit diagram generation method for physical, chemical and biological experiment teaching according to claim 5 is characterized by: In step S15, the distance between the pair of bumps and the terminal is determined to be greater than a preset distance threshold, specifically: Determine whether the distance between the bump and the terminal exceeds a preset distance threshold, if so, filter it, otherwise bind the wire to the terminal of this circuit element; The calculation formula of the preset distance threshold thr is: x represents a custom ratio, 0<x<100; w represents the width of the location box of the circuit element; h represents the height of the location box of the circuit element.
7. The circuit diagram generation method for physical, chemical and biological experiment teaching according to claim 1 is characterized by: In the component connection information dictionary, key represents the current circuit component, and value represents a list of component sets connected to the current circuit component by wires; Among them, if the circuit elements connected by wires are connected in parallel, then the circuit elements connected by wires exist twice in the element set list; if the circuit elements connected by wires are connected in series, then the circuit elements connected by wires exist once in the element set list.
8. The circuit diagram generation method for physical, chemical and biological experiment teaching according to claim 1 is characterized by: The step of applying a depth-first search algorithm to the component connection information dictionary to obtain a circuit drawing path comprises: Determining the circuit elements of the initial position in the element connection information dictionary; Sort the connection order of circuit elements; checking whether the component connection information dictionary forms a closed circuit; The circuit drawing path is output.
9. An electronic device, comprising a memory and a processor, wherein the memory is electrically connected to the processor, and the memory stores a computer program, wherein: When the computer program is executed by the processor, the processor is caused to implement the method according to any one of claims 1 to 8.
10. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Simplified circuit diagram generation method and device, equipment and storage medium
CN113255260A
Physical circuit experiment automatic identification method
CN114677586A
Circuit diagram detection method, system and device and readable storage medium
CN114882520A
Generation method, device and equipment of electric power circuit diagram and medium
CN116305697A
Circuit connection relation identification method, system, equipment and medium
CN118135294A