Code generation method, code generation device, visualization platform and electronic device
By using a visual platform in the machine vision industry to generate description data of data processing application solutions, and using predefined code snippets and engineering templates to automatically generate corresponding source code and engineering code, the problem of low code generation efficiency is solved and rapid Respond to the need to detect scene changes.
Patent Information
- Application Number
- CN202310573985.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-18
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2043-05-18
AI Technical Summary
In the machine vision industry, as the detection scenario changes, it is necessary to frequently replace and write code for image processing methods, resulting in low code generation efficiency.
Provide a code generation method, which generates description data of the target data processing application solution through a visual platform, and uses predefined code snippets and engineering templates to automatically generate corresponding source code and engineering code.
It reduces the amount of manual code writing, improves the efficiency of code generation, and when data processing scenarios change, you only need to modify the application scheme in the visualization platform to generate new engineering code.
Smart Images

Figure CN116643755B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine vision technology, and in particular to a code generation method, a code generation device, a visualization platform and an electronic device. Background Art
[0002] In the machine vision industry, different image processing methods are used for different detection scenarios. In addition, the processing logic and module calling order of each image processing method are different, so different codes need to be written for different image processing methods.
[0003] In the actual production process, when the detection scene changes, the image processing method needs to be changed and the code of the image processing method suitable for the new detection scene needs to be generated. In this way, when there are multiple detection scenes, the technicians need to write and debug a large amount of code, and for each detection scene, the code generation cycle of the image processing method suitable for the scene is long, which makes the code generation efficiency low. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a code generation method, a code generation device, a visualization platform and an electronic device to improve the efficiency of code generation. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a code generation method, which is applied to a code generation device in a code generation system, wherein the system also includes a visualization platform for building a data processing application solution, and the method includes:
[0006] Acquire description data of a target data processing application solution; wherein the target data processing application solution is generated by the visualization platform based on a user's designated operation on each designated algorithm module of a preset data processing method in the visualization platform; the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0007] Parsing the description data to obtain a parsing result;
[0008] Based on the parsing results, predefined code snippets and predefined engineering templates, source code of the target data processing application solution is generated, and based on the source code, engineering code for the target data processing application solution is generated.
[0009] Optionally, in a specific implementation, the method is applied to an implementation layer of the code generation device; the code generation device further includes an interface layer and a data layer;
[0010] The step of obtaining the description data of the target data processing application solution includes:
[0011] Acquire description data of the target data processing application solution sent by the visualization platform through the interface layer;
[0012] The method further comprises:
[0013] Storing the analysis result in the data layer;
[0014] The step of generating source code of the target data processing application solution based on the parsing result, the predefined code snippet and the predefined engineering template, and generating engineering code for the target data processing application solution based on the source code includes:
[0015] The parsing result is read from the data layer, and based on the parsing result, predefined code snippets and predefined engineering templates, the source code of the target data processing application solution is generated, and based on the source code, the engineering code for the target data processing application solution is generated.
[0016] Optionally, in a specific implementation, the implementation layer includes a source code generator, an engineering code generator, and predefined code snippets; the data layer stores an engineering template file, and the parsing result includes a process topology structure, an algorithm module description, an SDK interface description, and a mapping between an algorithm module and an SDK;
[0017] The step of reading the parsing result from the data layer, generating source code of the target data processing application solution based on the parsing result, predefined code snippets, and predefined engineering templates, and generating engineering code for the target data processing application solution based on the source code includes:
[0018] Read the parsing result and the engineering template file from the data layer; call the source code generator to generate source code for the target data processing application solution using the algorithm module and SDK mapping, the algorithm module description, the SDK interface description, the predefined code snippets, the predefined engineering templates in the engineering template file, and the process topology structure; call the engineering code generator to generate engineering code for the target data processing application solution using the source code.
[0019] Optionally, in a specific implementation, before parsing the description data to obtain a parsing result, the method further includes:
[0020] Verifying the description data to obtain a verification result;
[0021] If the verification result indicates that the description data has passed the verification, the result data is parsed to obtain a parsing result.
[0022] Optionally, in a specific implementation, the method further includes:
[0023] The engineering code is stored in a designated storage space.
[0024] In a second aspect, an embodiment of the present application provides a code generation method, which is applied to a visualization platform for building an engineering solution in a code generation system, wherein the system also includes a code generation device, and the method includes:
[0025] Generate a target data processing application solution based on the user's designated operations on each designated algorithm module of the preset data processing method in the visualization platform;
[0026] When the code generation instruction is detected, description data of the target data processing application is generated according to the target data processing application solution; wherein the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0027] The description data is sent to the code generation device so that the code generation device parses the description data to obtain a parsing result, generates the source code of the target data processing application solution based on the parsing result, predefined code snippets and predefined engineering templates, and generates engineering code for the target data processing application solution based on the source code.
[0028] Optionally, in a specific implementation, the method further includes:
[0029] The target data processing application solution is displayed on a preset display interface.
[0030] In a third aspect, an embodiment of the present application provides a code generation device in a code generation system, wherein the system further includes a visualization platform for building a data processing application solution, and the device includes:
[0031] A data acquisition module, which acquires description data of a target data processing application scheme; wherein the target data processing application scheme is generated by the visualization platform based on a user's designated operation on each designated algorithm module of a preset data processing device in the visualization platform; the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0032] A parsing module, used for parsing the description data to obtain a parsing result;
[0033] A code generation module is used to generate source code of the target data processing application solution based on the parsing results, predefined code snippets and predefined engineering templates, and to generate engineering code for the target data processing application solution based on the source code.
[0034] Optionally, in a specific implementation, the device includes: an interface layer, an implementation layer and a data layer; the functions of the data acquisition module, the parsing module and the code generation module are all implemented by the implementation layer;
[0035] The data acquisition module is specifically used to acquire the description data of the target data processing application solution sent by the visualization platform by calling the interface layer;
[0036] The analysis module is further used to store the analysis result in the data layer;
[0037] The code generation module is specifically used to read the parsing results from the data layer, and generate the source code of the target data processing application solution based on the parsing results, predefined code snippets and predefined engineering templates, and generate engineering code for the target data processing application solution based on the source code.
[0038] Optionally, in a specific implementation, the implementation layer includes a source code generator, an engineering code generator, and predefined code snippets; the data layer stores an engineering template file, and the parsing result includes a process topology structure, an algorithm module description, an SDK interface description, and a mapping between an algorithm module and an SDK;
[0039] The code generation module is specifically used to read the parsing results and the engineering template file from the data layer; call the source code generator to generate source code for the target data processing application solution using the algorithm module and SDK mapping, the algorithm module description, the SDK interface description, the predefined code snippets, the predefined engineering templates in the engineering template file, and the process topology structure; call the engineering code generator to generate engineering code for the target data processing application solution using the source code.
[0040] Optionally, in a specific implementation, the device further includes:
[0041] The verification module is used to verify the description data and obtain a verification result before parsing the description data to obtain a parsing result; if the verification result indicates that the description data has passed the verification, the parsing module is triggered.
[0042] Optionally, in a specific implementation, the device further includes:
[0043] The storage module is used to store the engineering code in a designated storage space.
[0044] In a fourth aspect, an embodiment of the present application provides a visualization platform, which is applied to a code generation system, wherein the system further includes a code generation device, and the visualization platform is used to build an engineering solution, and the platform includes:
[0045] A solution generation module, used to generate a target data processing application solution based on a user's specified operation on each specified algorithm module of a preset data processing device in the visualization platform;
[0046] A data generation module, configured to generate description data of the target data processing application according to the target data processing application solution when a code generation instruction is detected; wherein the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0047] A data sending module is used to send the description data to the code generating device so that the code generating device parses the description data to obtain a parsing result, generates the source code of the target data processing application solution based on the parsing result, predefined code snippets and predefined engineering templates, and generates engineering code for the target data processing application solution based on the source code.
[0048] Optionally, in a specific implementation, the platform further includes:
[0049] The display module is used to display the target data processing application solution in a preset display interface.
[0050] In a fifth aspect, an embodiment of the present application provides an electronic device, including:
[0051] Memory, used to store computer programs;
[0052] The processor is used to implement any method described in the first aspect or the second aspect when executing the program stored in the memory.
[0053] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in either the first aspect or the second aspect is implemented.
[0054] In a seventh aspect, an embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps of any of the above method embodiments.
[0055] Beneficial effects of the embodiments of the present application:
[0056] As can be seen from the above, an embodiment of the present application provides a code generation method, which is applied to a code generation device in a code generation system, and the above system also includes a visualization platform for building a data processing application solution. The visualization platform can generate a target data processing application solution based on the user's specified operations on each specified algorithm module of the preset data processing method in the visualization platform, and then the code generation device can obtain the description data of the above target data processing application solution, which may include the module parameters of each specified algorithm module and the interaction parameters that characterize the interaction relationship between each specified algorithm module. Then, the code generation device can parse the above description data to obtain the parsing result, and based on the above parsing result, predefined code snippets and predefined engineering templates, generate the source code of the target data processing application solution, and based on the source code, generate the engineering code for the target data processing application solution.
[0057] Based on this, by applying the solution provided in the embodiment of the present application, code snippets and project templates can be pre-defined. In this way, using the above-mentioned code snippets and project templates, the code generation device can generate engineering code based on the description data of the target data processing application solution built on the visualization platform, without the need to manually write the engineering code of the target data processing application solution, thereby reducing the amount of code writing and improving code generation efficiency.
[0058] In addition, since the data processing application solution is generated by the visualization platform, when the data processing scenario changes, a new data processing application solution can be generated by simply modifying the data processing application solution in the visualization platform. Then, the code generation device can generate the corresponding engineering code based on the description data of the new data processing application solution, without the need to rewrite new engineering code every time the data processing scenario changes. This can further improve the code generation efficiency.
[0059] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0061] Figure 1 A schematic diagram of the structure of a code generation system provided in an embodiment of the present application;
[0062] Figure 2A flowchart of a code generation method applied to a code generation device provided in an embodiment of the present application;
[0063] Figure 3 A flowchart of another code generation method applied to a code generation device provided in an embodiment of the present application;
[0064] Figure 4 A flowchart of another code generation method applied to a code generation device provided in an embodiment of the present application;
[0065] Figure 5 A flowchart of another code generation method applied to a code generation device provided in an embodiment of the present application;
[0066] Figure 6 A schematic diagram of the software architecture of the code generation device provided in an embodiment of the present application;
[0067] Figure 7 A schematic diagram of a file directory of a code generation device provided in an embodiment of the present application;
[0068] Figure 8 A schematic diagram of the mapping relationship between the algorithm module and the SDK function operator provided in the embodiment of the present application;
[0069] Fig. 9 A schematic diagram of a script directory provided in an embodiment of the present application;
[0070] Fig.10 A schematic diagram of a template directory provided in an embodiment of the present application;
[0071] Fig.11 A flowchart of a code generation method applied to a visualization platform provided in an embodiment of the present application;
[0072] Fig.12 A flowchart of another code generation method applied to a visualization platform provided in an embodiment of the present application;
[0073] Fig.13 An example diagram of a code generation method provided in an embodiment of the present application;
[0074] Fig.14 A flowchart of an example of a code generation method provided in an embodiment of the present application;
[0075] Fig.15 A schematic diagram of another example of a code generation method provided in an embodiment of the present application;
[0076] Fig.16 A schematic diagram of the structure of a code generation device in a code generation system provided in an embodiment of the present application;
[0077] Fig.17 A schematic diagram of the structure of a visualization platform provided in an embodiment of the present application;
[0078] Fig.18 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0079] Fig.19 A schematic diagram of the structure of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0080] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0081] In the actual production process, when the detection scene changes, the image processing method needs to be changed and the code of the image processing method suitable for the new detection scene needs to be generated. In this way, when there are multiple detection scenes, the technicians need to write and debug a large amount of code, and for each detection scene, the code generation cycle of the image processing method suitable for the scene is long, which makes the code generation efficiency low.
[0082] In order to solve the above technical problems, the embodiment of the present application provides a code generation method, which is applied to a code generation system, such as Figure 1 As shown, the code generation system may include a code generation device 100 and a visualization platform 200, wherein the visualization platform 200 may be used to build a data processing application solution.
[0083] The visualization platform 200 integrates multiple algorithm modules, and the visualization platform may include a UI (User Interface), and the UI may be provided with multiple algorithm module logos. When building a data processing application solution, the user can perform specified operations on each algorithm module on the UI based on a preset data processing flow, so that the visualization platform can combine each algorithm module into a data processing application solution based on the user's specified operations on each algorithm module.
[0084] Optionally, when the operation interface set by the above-mentioned visualization platform 200 is different, the above-mentioned specified operations may be different. For example, when the operation interface of the above-mentioned visualization platform 200 is an interface for dragging modules to build a data processing application solution, the data processing application solution can be constructed by dragging each algorithm module to a specified position; when the above-mentioned visualization platform 200 displays the identification of each algorithm module, the data processing application solution can be constructed by inputting the identification of each algorithm module into the specified position of the data processing application solution. This is all reasonable and is not specifically limited in the embodiments of the present application.
[0085] After generating the data processing application solution, the visualization platform 200 can generate description data about the data processing application solution when receiving the code generation instruction, and send the description data to the code generation device 100. In this way, the code generation device 100 can obtain the description data, and then, based on the description data, generate the engineering code about the data processing application solution using the preset SDK (Software Development Kit).
[0086] Among them, the solution provided by the embodiment of the present application can be applicable to various scenarios where it is necessary to generate engineering codes for executing data processing processes. For example, when performing image preprocessing, object recognition and feature extraction processing, engineering codes for implementing the above processing processes can be generated; when performing the process of positioning and identifying numbers in an image, engineering codes for implementing the above positioning and identification processes can be generated, etc.
[0087] The visualization platform and the code generation device in the system can be set in various electronic devices, such as mobile phones, computers, etc.; and the above-mentioned visualization platform and the above-mentioned code generation device can be set in the same electronic device or in different electronic devices.
[0088] Based on this, the embodiments of the present application do not specifically limit the application scenarios and execution entities of the method.
[0089] A code generation method for a code generation device in a code generation system provided by an embodiment of the present application may include the following steps:
[0090] Acquire description data of a target data processing application solution; wherein the target data processing application solution is generated by the visualization platform based on a user's designated operation on each designated algorithm module of a preset data processing method in the visualization platform; the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0091] Parsing the description data to obtain a parsing result;
[0092] Based on the parsing results, predefined code snippets and predefined engineering templates, source code of the target data processing application solution is generated, and based on the source code, engineering code for the target data processing application solution is generated.
[0093] As can be seen from the above, an embodiment of the present application provides a code generation method, which is applied to a code generation device in a code generation system, and the above system also includes a visualization platform for building a data processing application solution. The visualization platform can generate a target data processing application solution based on the user's specified operations on each specified algorithm module of the preset data processing method in the visualization platform, and then the code generation device can obtain the description data of the above target data processing application solution, which may include the module parameters of each specified algorithm module and the interaction parameters that characterize the interaction relationship between each specified algorithm module. Then, the code generation device can parse the above description data to obtain the parsing result, and based on the above parsing result, predefined code snippets and predefined engineering templates, generate the source code of the target data processing application solution, and based on the source code, generate the engineering code for the target data processing application solution.
[0094] Based on this, by applying the solution provided in the embodiment of the present application, code snippets and project templates can be pre-defined. In this way, using the above-mentioned code snippets and project templates, the code generation device can generate engineering code based on the description data of the target data processing application solution built on the visualization platform, without the need to manually write the engineering code of the target data processing application solution, thereby reducing the amount of code writing and improving code generation efficiency.
[0095] In addition, since the data processing application solution is generated by the visualization platform, when the data processing scenario changes, a new data processing application solution can be generated by simply modifying the data processing application solution in the visualization platform. Then, the code generation device can generate the corresponding engineering code based on the description data of the new data processing application solution, without the need to rewrite new engineering code every time the data processing scenario changes. This can further improve the code generation efficiency.
[0096] Below, in conjunction with the accompanying drawings, a code generation method for a code generation device in a code generation system provided in an embodiment of the present application is specifically described.
[0097] Figure 2 A flowchart of a code generation method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method may include the following steps S201-S203:
[0098] S201: Acquire description data of a target data processing application solution;
[0099] The target data processing application solution is generated by the visualization platform based on the user's designated operations on each designated algorithm module of the preset data processing method in the visualization platform; the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0100] In actual work, when data needs to be processed, the data processing flow for processing the data can be determined based on the data type of the data to be processed and the various steps required to process the data. Furthermore, based on the above data processing flow, the algorithm modules used to implement the various steps in the above data processing flow can be subjected to specified operations in the visualization platform. In this way, the above visualization platform can generate a data processing application solution corresponding to the data processing flow based on the specified operations for each algorithm module. Furthermore, based on the various algorithm modules included in the data processing solution, the execution order of each algorithm module and the connection relationship between each algorithm module, the description data of the data processing scenario application solution can be generated.
[0101] Based on this, in order to process the target data, the user can first determine the target data processing flow for processing the target data, and then perform specified operations on each specified algorithm module in the visualization platform based on the target data processing flow. In this way, the visualization platform can generate a target data processing application solution based on the specified operation, and generate description data of the target data processing application solution.
[0102] Among them, each algorithm module has module parameters, for example, the running operation of the algorithm module, the area of interest processed by the algorithm module and the shielded area not processed, the module name of the algorithm module, the module number and other parameters; thus, the description data of the above-mentioned target data processing application scheme may include the module parameters of each specified algorithm module; in addition, there is a connection order, input data and output data interaction relationship and other process topology and subscription information between the algorithm modules constituting the same target data processing application scheme, thus, the description data of the above-mentioned target data processing application scheme may also include interaction parameters that characterize the interaction relationship between each specified algorithm module.
[0103] Based on this, the description data of the above-mentioned target data processing application solution may include module parameters of each specified algorithm module and interaction parameters that characterize the interaction relationship between each specified algorithm module, and the module parameters of each specified algorithm module may include module information, ROI (Region Of Interest) and shielding area, module operation parameters, etc., and the above-mentioned interaction parameters may include process topology and subscription information, etc.
[0104] In this way, when generating engineering code for a target data processing application solution, the code generation device can first obtain the description data of the target data processing application solution generated by the visualization platform, and then generate engineering code for the target data processing application solution based on the above description data.
[0105] S202: parse the description data to obtain a parsing result;
[0106] After acquiring the description data of the target data processing application solution, the code generation device may parse the description data, thereby obtaining the parsing result of the description data of the target data processing application solution.
[0107] Optionally, the above analysis results may include the process topology structure, algorithm module ROI and shielding area, module operation parameters and subscription information in the description data of the target data processing application solution dynamically generated during the analysis process, as well as the predefined algorithm module description, the predefined SDK interface description and the mapping between the predefined algorithm module and the SDK;
[0108] Among them, the above-mentioned process topology structure and subscription information are used to characterize the connection order, input data and output data and other interactive relationships between various algorithm modules in the target data processing application solution; the above-mentioned algorithm module ROI and shielding area, as well as module operation parameters are used to characterize the operation operations of each specified algorithm module, the area of interest for processing and the shielding area not for processing, module name, module number and other module parameters; the above-mentioned predefined algorithm module description is used to describe the input data, output data and other description information of each algorithm module; the above-mentioned predefined SDK interface description is a collection of multiple SDK function operators; the above-mentioned predefined algorithm module and SDK mapping is used to characterize the mapping information between each algorithm module and each SDK function operator in the above-mentioned target data processing application solution.
[0109] S203: Generate source code of the target data processing application solution based on the parsing result, the predefined code snippet and the predefined engineering template, and generate engineering code for the target data processing application solution based on the source code.
[0110] The code generation device is pre-set with predefined code snippets and predefined engineering templates for various application solutions that can be generated by the visualization platform. In this way, after parsing the description data of the above-mentioned target data processing application solution and obtaining the parsing result, the source code of the target data processing application solution can be generated according to the process topology structure between each algorithm module in the target data processing application solution using the above-mentioned predefined code and predefined engineering template, and then, based on the above-mentioned source code, the engineering code for the target data processing application solution is generated.
[0111] Optionally, the above-mentioned engineering template may include a script implementation of the engineering code. When the code generation device generates the engineering code of the target data processing application solution, it may use the script implementation to generate the corresponding engineering code.
[0112] Among them, the above script implementation can be a Python script or other scripts, which is reasonable and is not specifically limited in the embodiments of the present application.
[0113] Optionally, in a specific implementation, such as Figure 3 As shown, a code generation method provided in an embodiment of the present application may further include the following step S204:
[0114] S204: Storing the engineering code in a designated storage space.
[0115] In this specific implementation, after generating the engineering code, the code generation device may store the engineering code in a preset designated storage space, so that the user can obtain the engineering code in the designated storage space and perform subsequent operations on the engineering code.
[0116] For example, the user can obtain the above engineering code in the designated storage space, compile and run the engineering code;
[0117] For another example, the user may obtain the above-mentioned engineering code in the designated storage space, compile the engineering code, and debug the engineering code to detect whether there is an error in the engineering code;
[0118] For another example, the user can obtain the above-mentioned engineering code in the designated storage space, compile the engineering code when secondary development is needed, and perform secondary development based on the engineering code, thereby eliminating the need to perform the complete code writing work again and shortening the code writing time.
[0119] It can be seen from the above that by applying the solution provided in the embodiment of the present application, code snippets and project templates can be pre-defined. In this way, using the above code snippets and project templates, the code generation device can generate engineering code based on the description data of the target data processing application solution built on the visualization platform, without the need to manually write the engineering code of the target data processing application solution, thereby reducing the amount of code writing and improving code generation efficiency.
[0120] In addition, since the data processing application solution is generated by the visualization platform, when the data processing scenario changes, a new data processing application solution can be generated by simply modifying the data processing application solution in the visualization platform. Then, the code generation device can generate the corresponding engineering code based on the description data of the new data processing application solution, without the need to rewrite new engineering code every time the data processing scenario changes. This can further improve the code generation efficiency.
[0121] When the versions of the visualization platform and the code generation device do not match, the predefined SDK interface description included in the code generation device may not be able to support the functions of some algorithm modules in the target data processing application solution generated by the visualization platform, and thus, the corresponding source code cannot be generated. For example, the visualization platform is an open structure, and users can customize some algorithm modules on the visualization platform. Since the implementation logic of the user-defined algorithm module cannot be obtained, the code generation device cannot support the functions of the user-defined algorithm module. Based on this, when the description data of the description data of the target data processing application solution is obtained, the description data can be first verified, and after the verification of the above description data is successful, the above description data can be parsed.
[0122] Optionally, in a specific implementation, such as Figure 4 As shown, a code generation method provided in an embodiment of the present application may further include the following step S205:
[0123] S205: Verify the description data and obtain the verification result;
[0124] Accordingly, in this specific implementation, the above step S202, parsing the description data to obtain the parsing result, may include the following step S2021:
[0125] S2021: If the verification result indicates that the description data has passed the verification, the description data is parsed to obtain a parsing result.
[0126] In this specific implementation, after obtaining the above-mentioned description data, the code generation device can first verify whether the various algorithm modules in the above-mentioned description data are all predefined algorithm modules in the code generation device, that is, determine whether the predefined SDK interface description included in the code generation device supports the implementation of the functions of each algorithm module in the description data, thereby obtaining the verification result of the above-mentioned description data.
[0127] If the above verification result indicates that the above description data has passed the verification, the above description data can be parsed to obtain the parsing result; conversely, if the above verification result indicates that the above description data has failed the verification, a notification message indicating that the above description data has failed the verification can be output to prompt relevant staff that the above description data has failed the verification, and the code generation process for the target data processing application solution is terminated.
[0128] Optionally, if the verification result indicates that the description data verification fails, an API (Application Programming Interface) is called to output a notification message indicating that the description data verification fails, and the code generation process is terminated.
[0129] Optionally, when the code generation device includes multiple sets of predefined SDK interface descriptions, if any one of the multiple sets of predefined SDK interface descriptions included in the code generation device can support the implementation of the functions of each algorithm module in the above description data, the above description data verification passes; if none of the above multiple sets of predefined SDK interface descriptions support the implementation of the functions of each algorithm module in the above description data, the above description data verification fails.
[0130] Optionally, the code generation methods applied to the code generation device in the code generation system provided in the embodiment of the present application are all applied to the implementation layer in the code generation device, that is, the code generation methods applied to the code generation device in the code generation system are all implemented by the implementation layer in the code generation device. In addition, the code generation device may also include an interface layer and a data layer, and the hierarchical order of the above three layers in the code generation device is from top to bottom: interface layer, implementation layer and data layer.
[0131] Among them, the interface layer of the code generation device can be used to provide various service interfaces to the outside for other devices or platforms to call; and the data layer of the code generation device can be used to store various types of data.
[0132] Optionally, in a specific implementation, the code generation method of the code generation device applied to the code generation system provided in the embodiment of the present application is applied to the implementation layer in the code generation device, such as Figure 5As shown, the above step S201, obtaining description data of the target data processing application solution, may include the following step S2011:
[0133] S2011: Acquire description data of the target data processing application solution sent by the visualization platform through the calling interface layer;
[0134] A code generation method provided in an embodiment of the present application may further include the following step S206:
[0135] S206: storing the analysis result in the data layer;
[0136] Accordingly, in this specific implementation, the above step S203, based on the parsing result, the predefined code snippet and the predefined engineering template, generates the source code of the target data processing application solution, and based on the source code, generates the engineering code for the target data processing application solution, which may include the following step S2031:
[0137] S2031: Read the parsing results from the data layer, and generate source code of the target data processing application solution based on the parsing results, predefined code snippets and predefined engineering templates, and generate engineering code for the target data processing application solution based on the source code.
[0138] In this specific implementation, the code generation method of the code generation device applied to the code generation system is applied to the implementation layer of the code generation device, and the code generation device may also include an interface layer and a data layer. After generating the description data of the target data processing application solution, the visualization platform may call the interface layer to transmit the description data to the implementation layer. In this way, the implementation layer may obtain the description data of the target data application solution sent by the visualization platform by calling the interface layer, parse the description data, obtain the parsing result, and then store the parsing result in the data layer.
[0139] Furthermore, the implementation layer can read the above analysis results from the data layer, and then generate the source code of the target data processing application solution based on the above analysis results, predefined code snippets and predefined engineering templates, and then generate engineering code for the target data processing application solution based on the source code.
[0140] Optionally, the code generation device software architecture is as follows Figure 6 As shown, the above interface layer may include an external API interface;
[0141] Optionally, the interface layer may include an API; then the step S2011 of obtaining the description data of the target data processing application solution sent by the visualization platform by calling the interface layer may include the following step 11:
[0142] Step 11: Obtain description data of the target data processing application solution sent by the visualization platform by calling the API.
[0143] In this specific implementation, in order to interact with each device or platform, the code generation device can provide an API to each device or platform. After generating the description data of the target data processing application solution, the visualization platform can call the above API to transmit the description data of the above target data processing application solution to the implementation layer through the API, so that the above implementation layer can receive the description data of the above target data processing application solution sent by the visualization platform by calling the above API.
[0144] Optional, such as Figure 6 As shown, the above-mentioned data layer can store the analysis results of the description data of the engineering template file and the target data processing application solution, and the above-mentioned analysis results can include the process topology structure, algorithm module description, SDK interface description, algorithm module and SDK mapping, ROI and shielding area, and module operation parameters. Thus, the above-mentioned data layer can store the engineering template file, process topology structure, algorithm module description, SDK interface description, algorithm module and SDK mapping, ROI and shielding area, and module operation parameters.
[0145] Optional, such as Figure 6 As shown, the above implementation layer is used for the implementation of engineering code, and may include an engineering code generator, a source code generator, predefined code snippets, a data parser and manager, a module object manager, an SDK object manager, a ROI and shielding area manager, a process topology manager, and a subscription information manager.
[0146] Optionally, in a specific implementation, the code generation method of the code generation device in the code generation system provided in the embodiment of the present application is applied to the implementation layer in the code generation device, and the above step S202, parsing the description data to obtain the parsing result, may include the following step 21:
[0147] Step 21: Utilize the data analysis and management to analyze the description data and obtain the analysis result.
[0148] In this specific implementation, after acquiring the description data of the target data processing application solution, the implementation layer may utilize the data parser and manager to parse the description data, thereby obtaining the parsing result of the description data of the target data processing application solution.
[0149] Optionally, in a specific implementation,
[0150] The above step S2031, reading the parsing result from the data layer, and generating the source code of the target data processing application solution based on the parsing result, the predefined code snippet and the predefined engineering template, and generating the engineering code for the target data processing application solution based on the source code, may include the following steps 31-33:
[0151] Step 31: Read the parsing results and project template file from the data layer;
[0152] Step 32: calling a source code generator to generate source code for a target data processing application solution by using the algorithm module and SDK mapping, the algorithm module description, the SDK interface description, the predefined code snippet, the predefined project template in the project template file, and the process topology structure;
[0153] Step 33: Call the engineering code generator and use the source code to generate engineering code for the target data processing application solution.
[0154] In this specific implementation, the implementation layer can read the parsing results and the engineering template file from the data layer, and then the implementation layer can call the source code generator to generate the source code for the target data processing application solution using the process topology between the algorithm modules in the parsing results, the SDK interface description, the algorithm module description, the mapping between the algorithm module and the SDK, the predefined code snippets, and the predefined engineering templates in the engineering template file. Furthermore, the implementation layer can continue to call the engineering code generator to generate the engineering code for the target data processing application solution using the source code for the target data processing application solution.
[0155] Optionally, when the data layer includes multiple sets of predefined SDK interface descriptions, for each set of predefined SDK interface descriptions included in the data layer, the implementation layer can generate source code of the target data processing application solution based on the set of SDK interface descriptions.
[0156] For example, if the data layer includes two sets of predefined SDK interface descriptions, the implementation layer can call the source code generator to use the description data of the target data processing application solution and the two sets of SDK interface descriptions to generate the source code of the target data processing application solution corresponding to each set of SDK interface descriptions. Furthermore, the implementation layer can continue to call the engineering code generator to generate the engineering code of the target data processing application solution, so that two sets of engineering codes can be generated in the end.
[0157] Optionally, when the data layer includes multiple sets of predefined SDK interface descriptions, the implementation layer can select a target SDK interface description from the multiple sets of SDK interface descriptions based on preset selection rules, and call the source code generator to generate the source code of the target data processing application solution using the target SDK interface description.
[0158] Among them, the above-mentioned preset selection rules can be to select the target SDK interface description based on user operations, or to use the SDK interface description with the least programming amount as the target SDK interface description, or to randomly select any SDK interface description as the target SDK interface description. These are all reasonable and are not specifically limited in the embodiments of the present application.
[0159] Exemplarily, the implementation layer can select any set of SDK interface descriptions from the above SDK interface descriptions as the target SDK interface description. Afterwards, the implementation layer can call the source code generator to generate the source code of the target data processing application solution using the target SDK interface description. Furthermore, the implementation layer can continue to call the engineering code generator to generate the engineering code of the target data processing application solution, that is, finally generate a set of engineering codes corresponding to the target SDK interface description.
[0160] When the above-mentioned code generation device is installed in any electronic device, the electronic device may include a file directory of the code generation device. Based on this, optionally, Figure 7 Generate device file directory for code, such as Figure 7 As shown, the code generation device file directory may include two parts: components directory and c_api.dll. c_api.dll is the external API of the code generation device, and the components directory may include data directory, script directory and template (function template and class template) directory.
[0161] The above-mentioned data directory is used to store various predefined information of the code generation device, for example, predefined SDK interface descriptions, algorithm module and SDK mappings, and algorithm module descriptions, etc.; among them, since the functions corresponding to each algorithm module are different, the mapping relationship between each algorithm module and its uniquely corresponding SDK function operator can be established in advance, and the above-mentioned mapping relationship can be stored in the code generation device.
[0162] For example, Figure 8 It is a schematic diagram of the mapping relationship between the above algorithm modules and SDK function operators, as shown in Figure 8As shown, each algorithm module can include a module name, a module input list, a ROI, a shielding area, and a module output list, and multiple algorithm modules can be grouped into an algorithm module description; each function operator can implement the algorithm function of an algorithm module, and each function operator can include an operator name, a namespace, a dependent header file, a dependent header library file, an instance object name, a result object name, a creation interface, and a destruction interface, and multiple SDK function operators can be grouped into an SDK interface description. By establishing a mapping relationship between the above algorithm module description and the above SDK interface description, the algorithm module and SDK interface mapping can be obtained. The algorithm module and SDK interface mapping includes multiple mapping information pairs, and each mapping information pair can record the mutually mapped algorithm module name and SDK function operator name.
[0163] The script directory is used to store various script files in the code generation device, such as API script files, application solution engineering code generation scripts, application solution source code generation scripts, SDK function operator scripts, algorithm module scripts, data analysis and management scripts, and process topology management scripts. The above script files can be various script implementations, such as Python scripts, etc., which are all reasonable, and the specific script implementations of the above script files are not limited in the embodiments of the present application.
[0164] For example, Fig. 9 As shown, the script directory can include API script files and subdirectories.
[0165] The API script may include an initialization file and an API interface file to provide API scripts to different devices or platforms. When providing the API script to the outside, c_api.dll calls the API script file in the script directory, and different visualization platforms and description files in different programming languages generated by each visualization platform call different APIs;
[0166] The above-mentioned subdirectory may contain specific implementation scripts for generating engineering codes, such as generating application solution engineering code scripts, generating application solution source code scripts, SDK function operator scripts, algorithm module scripts, data analysis and management scripts, and process topology management scripts, etc. Each file in this subdirectory can be dynamically replaced to fix problems and expand functions.
[0167] The template directory is used to store predefined engineering templates to support the engineering software using the engineering template to run the engineering code generated by the engineering template, and the engineering code is the code about the target data processing application solution.
[0168] like Fig.10As shown, the template directory may include two parts: a process code template and an application solution engineering template. The process code template defines the basic code format of the source code of the generated data processing application solution, and the process code template may include a template interface 1 for creating an SDK function operator instance, a template interface 2 for calling the SDK function operator execution according to the topological relationship within the process, and a template interface 3 for destroying the SDK function operator instance; the application solution engineering template may include a file 1 for storing the application solution engineering configuration, a file 2 for storing the public function implementation source code, and a file 3 for storing the public data structure definition;
[0169] Among them, the above-mentioned application solution engineering configuration can define the configuration options when generating engineering code; the above-mentioned public function implementation source code can define the implementation of public basic functions; and the above-mentioned public data structure definition can define basic data interfaces, such as the interface of image objects, the interface of graphic objects, etc.
[0170] Fig.11 A visual platform code generation method for building an engineering solution in a code generation system provided in an embodiment of the present application; the above-mentioned code generation system may also include: a code generation device; such as Fig.11 As shown, the method may include the following steps S1101-S1103:
[0171] S1101: generating a target data processing application solution based on a user's designated operation on each designated algorithm module of a preset data processing method in a visualization platform;
[0172] S1102: When a code generation instruction is detected, description data of the target data processing application is generated according to the target data processing application solution; wherein the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0173] S1103: Send the description data to the code generation device so that the code generation device parses the description data to obtain a parsing result, generates source code of the target data processing application solution based on the parsing result, predefined code snippets and predefined engineering templates, and generates engineering code for the target data processing application solution based on the source code.
[0174] The visualization platform includes a plurality of algorithm modules, and when receiving a designated operation for each calibration algorithm module, the visualization platform can generate a data processing application solution including each calibration algorithm module.
[0175] Based on this, after determining the target data processing method, the user can perform specified operations on each designated algorithm module used to implement each step included in the above-mentioned target data processing method in the above-mentioned visualization platform. In this way, the above-mentioned visualization platform can generate a target data processing application solution based on the above-mentioned user's specified operations on each designated algorithm module.
[0176] After the target data processing application scheme is generated using the visualization platform, the user can send a code generation instruction for the target data processing application scheme to the visualization platform, so that the code generation system generates engineering code for the target data processing application scheme. In this way, when the visualization platform detects the code generation instruction, it can generate description data of the target data processing application according to the target data processing application scheme.
[0177] The description data may include module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module.
[0178] Afterwards, the above-mentioned visualization platform can send the description data to the code generation device, so that the code generation device parses the description data to obtain the parsing results, and generates the source code of the target data processing application solution based on the parsing results, predefined code snippets and predefined engineering templates, and generates engineering code for the target data processing application solution based on the source code.
[0179] It can be seen from the above that by applying the solution provided in the embodiment of the present application, code snippets and project templates can be pre-defined. In this way, using the above code snippets and project templates, the code generation device can generate engineering code based on the description data of the target data processing application solution built on the visualization platform, without the need to manually write the engineering code of the target data processing application solution, thereby reducing the amount of code writing and improving code generation efficiency.
[0180] In addition, since the data processing application solution is generated by the visualization platform, when the data processing scenario changes, a new data processing application solution can be generated by simply modifying the data processing application solution in the visualization platform. Then, the code generation device can generate the corresponding engineering code based on the description data of the new data processing application solution, without the need to rewrite new engineering code every time the data processing scenario changes. This can further improve the code generation efficiency.
[0181] Optionally, in a specific implementation, such as Fig.12 As shown, a code generation method provided in an embodiment of the present application may further include the following step S1104:
[0182] S1104: Display the target data processing application solution on a preset display interface.
[0183] In this specific implementation, after generating the above-mentioned target data processing application solution, the visualization platform can display the above-mentioned target data processing application solution to the user in a preset display interface, so that the user can check the target data processing application solution more intuitively, and when there is an error in the target data processing application solution, modify the above-mentioned target data processing application solution on the visualization platform.
[0184] For example, Fig.13 As shown in the example process, the user can drag the image acquisition, high-precision matching, position correction, circle search and line search algorithm modules on the visualization platform. In this way, the above visualization platform generates an example process of the target data processing application solution based on the user's dragging operation and various operation parameters such as the dragging order of each algorithm module and the end position of each algorithm module, and displays the above example process on the UI. Afterwards, the user can send an instruction to generate engineering code for the target data processing application solution to the above visualization platform. In this way, an export project dialog box can appear on the UI of the visualization platform. The user can select the language of the engineering code to be generated in the above export project dialog box, such as C++; select the compilation platform, such as platform A; enter the name of the export project; select the storage directory of the export project, and export the engineering code generated by the code generation device for the above target data processing application solution by clicking the export button.
[0185] In order to facilitate understanding of the code generation method provided in the embodiment of the present application, Fig.14 , Fig.15 The specific example diagram of the code generation method is described in detail.
[0186] Fig.14 A flowchart of the code generation method is shown in FIG. Fig.14 As shown, the visual application platform UI in the figure is the UI of the visualization platform in the embodiment of the present application, the solution in the figure is the target data processing application solution in the embodiment of the present application, and the code generation component device in the figure is the code generation device in the embodiment of the present application. The specific process of the code generation method may include the following steps S1401-S1411:
[0187] S1401: Build solutions;
[0188] S1402: Start generating solution engineering code;
[0189] S1403: Build solutions;
[0190] S1404: storing solution description data;
[0191] S1405: Read and parse solution description data;
[0192] S1406: Generate source code files;
[0193] S1407: Generate engineering code files;
[0194] S1408: Write to the directory specified by the user;
[0195] S1409: Open and edit engineering code;
[0196] S1410: Compile the project;
[0197] S1411: Operation.
[0198] The visual application platform UI builds solutions based on the user's specified operations for each specified algorithm module. Afterwards, when it detects that the user clicks the button to start generating solution engineering code, the visual application platform can generate visual solution description data including intermediate data such as process topology, module information, subscription information, ROI and shielding area, and module operation parameters, and store the above solution description data.
[0199] Then, the code generation component device can read the solution description data, parse the solution description data, and generate a source code file for the solution based on the solution description data. Then, the code generation component device can generate an engineering code file for the solution based on the source code file, and write the engineering code file to a user-specified directory.
[0200] In this way, the user can obtain the project code in the specified directory, and then, can open and edit the project code, and when it is necessary to run the project code, compile the project, compile and run the project code.
[0201] The specific process of generating engineering codes by the above-mentioned code generating device is introduced below.
[0202] Fig.15 A schematic diagram of an example of an engineering code method for generating a solution for a code generation device, such as Fig.15 As shown, the user may first initialize the UI of the visualization platform, and then perform specified operations on each specified algorithm module on the visualization platform, so that the visualization platform generates a solution and generates description data about the solution.
[0203] The visualization platform calls the interface layer of the code generation device to send the above-mentioned description data to the code generation device, so that the above-mentioned code generation device can receive the above-mentioned description data, verify the description data, and obtain the verification result.
[0204] When the verification result indicates that the description data has passed the verification, the implementation layer of the code generation device can receive the description data, parse the description data using the data parser and manager, obtain parsed data including the description data of the solution, and store the parsed data in the data layer.
[0205] Next, the implementation layer of the code generation device can read the above-mentioned process topology, SDK interface data and algorithm module data from the data layer; wherein the above-mentioned process topology includes the process topology structure and subscription information; the above-mentioned SDK interface data includes the SDK interface description and the SDK and algorithm module mapping; and the above-mentioned algorithm module data includes the algorithm module ROI and shielding area, algorithm module description and operating parameters.
[0206] Afterwards, the code generation device can call the source code generator, use the above parsed data to combine the predefined code fragments, and parse the predefined project template to generate the source code of the above solution. Furthermore, the implementation layer of the code generation device can call the project code generator, use the above source code to generate the project code of the solution, and save the project code file storing the above project code in a specified location, so that the user can open the project file, edit the project, and then execute the compilation project.
[0207] Based on the same inventive concept, corresponding to the above-mentioned embodiment of the present application Figure 2 The shown embodiment is a code generation method applied to a code generation device in a code generation system. The embodiment of the present application also provides a code generation device in a code generation system.
[0208] Fig.16 A schematic diagram of the structure of a code generation device in a code generation system provided in an embodiment of the present application, such as Fig.16 As shown, the device may include the following modules:
[0209] The data acquisition module 1610 acquires description data of a target data processing application solution; wherein the target data processing application solution is generated by the visualization platform based on a user's designated operation on each designated algorithm module of a preset data processing device in the visualization platform; the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0210] The parsing module 1620 is used to parse the description data and obtain a parsing result;
[0211] The code generation module 1630 is used to generate the source code of the target data processing application solution based on the parsing results, predefined code snippets and predefined engineering templates, and to generate engineering code for the target data processing application solution based on the source code.
[0212] It can be seen from the above that by applying the solution provided in the embodiment of the present application, code snippets and project templates can be pre-defined. In this way, using the above code snippets and project templates, the code generation device can generate engineering code based on the description data of the target data processing application solution built on the visualization platform, without the need to manually write the engineering code of the target data processing application solution, thereby reducing the amount of code writing and improving code generation efficiency.
[0213] In addition, since the data processing application solution is generated by the visualization platform, when the data processing scenario changes, a new data processing application solution can be generated by simply modifying the data processing application solution in the visualization platform. Then, the code generation device can generate the corresponding engineering code based on the description data of the new data processing application solution, without the need to rewrite new engineering code every time the data processing scenario changes. This can further improve the code generation efficiency.
[0214] Optionally, in a specific implementation, the device includes: an interface layer, an implementation layer and a data layer; the functions of the data acquisition module 1610, the parsing module 1620 and the code generation module 1630 are all implemented by the implementation layer;
[0215] The data acquisition module 1610 is specifically used to acquire the description data of the target data processing application solution sent by the visualization platform by calling the interface layer;
[0216] The analysis module 1620 is further used to store the analysis result in the data layer;
[0217] The code generation module 1630 is specifically used to read the parsing results from the data layer, and generate the source code of the target data processing application solution based on the parsing results, predefined code snippets and predefined engineering templates, and generate engineering code for the target data processing application solution based on the source code.
[0218] Optionally, in a specific implementation, the implementation layer includes a source code generator, an engineering code generator, and predefined code snippets; the data layer stores an engineering template file, and the parsing result includes a process topology structure, an algorithm module description, an SDK interface description, and a mapping between an algorithm module and an SDK;
[0219] The code generation module 1630 is specifically used to read the parsing results and the engineering template file from the data layer; call the source code generator to generate source code for the target data processing application solution using the algorithm module and SDK mapping, the algorithm module description, the SDK interface description, the predefined code snippets, the predefined engineering templates in the engineering template file, and the process topology structure; call the engineering code generator to generate engineering code for the target data processing application solution using the source code.
[0220] Optionally, in a specific implementation, the device further includes:
[0221] The verification module is used to verify the description data and obtain a verification result before parsing the description data to obtain a parsing result; if the verification result indicates that the description data has passed the verification, the parsing module is triggered.
[0222] Optionally, in a specific implementation, the device further includes:
[0223] The storage module is used to store the engineering code in a designated storage space.
[0224] Based on the same inventive concept, corresponding to the above-mentioned embodiment of the present application Fig.11 A code generation method for a visualization platform in a code generation system is shown. The embodiment of the present application also provides a visualization platform in a code generation system for generating a data processing application solution.
[0225] Fig.17 A schematic diagram of a visualization platform provided in an embodiment of the present application is shown in FIG. Fig.17 As shown, the platform may include the following modules:
[0226] A solution generation module 1710, for generating a target data processing application solution based on a user's designated operation on each designated algorithm module of a preset data processing device in the visualization platform;
[0227] The data generation module 1720 is used to generate description data of the target data processing application according to the target data processing application solution when the code generation instruction is detected; wherein the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module;
[0228] The data sending module 1730 is used to send the description data to the code generating device so that the code generating device parses the description data to obtain a parsing result, generates the source code of the target data processing application solution based on the parsing result, predefined code snippets and predefined engineering templates, and generates engineering code for the target data processing application solution based on the source code.
[0229] It can be seen from the above that by applying the solution provided in the embodiment of the present application, code snippets and project templates can be pre-defined. In this way, using the above code snippets and project templates, the code generation device can generate engineering code based on the description data of the target data processing application solution built on the visualization platform, without the need to manually write the engineering code of the target data processing application solution, thereby reducing the amount of code writing and improving code generation efficiency.
[0230] In addition, since the data processing application solution is generated by the visualization platform, when the data processing scenario changes, a new data processing application solution can be generated by simply modifying the data processing application solution in the visualization platform. Then, the code generation device can generate the corresponding engineering code based on the description data of the new data processing application solution, without the need to rewrite new engineering code every time the data processing scenario changes. This can further improve the code generation efficiency.
[0231] Optionally, in a specific implementation, the platform further includes:
[0232] The display module is used to display the target data processing application solution in a preset display interface.
[0233] The present application also provides an electronic device, such as Fig.18 As shown, including:
[0234] Memory 1801, used for storing computer programs;
[0235] The processor 1802 is used to implement the steps of the code generation method in the code generation device applied to the code generation system provided in any of the above-mentioned embodiments of the present application when executing the program stored in the memory 1801.
[0236] In addition, the electronic device may further include a communication bus and / or a communication interface, and the processor 1802, the communication interface, and the memory 18001 communicate with each other via the communication bus.
[0237] The present application also provides an electronic device, such as Fig.19 As shown, including:
[0238] Memory 1901, used for storing computer programs;
[0239] The processor 1902 is used to implement the steps of any code generation method for a visualization platform in a code generation system provided in the above-mentioned embodiments of the present application when executing the program stored in the memory 1901.
[0240] In addition, the electronic device may further include a communication bus and / or a communication interface, and the processor 1902, the communication interface, and the memory 1901 communicate with each other via the communication bus.
[0241] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0242] The communication interface is used for communication between the above electronic device and other devices.
[0243] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0244] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0245] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above code generation methods are implemented.
[0246] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any code generation method in the above embodiments.
[0247] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), etc.
[0248] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0249] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the code generation device embodiment, the visualization platform embodiment, the electronic device embodiment, the computer-readable storage medium embodiment, and the computer program product embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0250] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A code generation method, characterized in that: A code generation device applied to a code generation system, the system also includes a visualization platform for building a data processing application solution, and the method includes: Acquire description data of a target data processing application scheme; wherein the target data processing application scheme is a visual scheme generated by the visualization platform based on a user's designated operation on each designated algorithm module of a preset data processing method in the visualization platform; the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module, the interaction parameters including: the interaction relationship between input data and output data, connection order, and subscription information between each designated algorithm module; Parsing the description data to obtain a parsing result; Based on the parsing results, predefined code snippets and predefined engineering templates, the source code of the target data processing application solution is generated, and based on the source code, the engineering code for the target data processing application solution is generated, wherein the predefined engineering template is used to support the software using the predefined engineering template to run the engineering code.
2. The method according to claim 1, characterized in that The method is applied to the implementation layer of the code generation device; the code generation device also includes an interface layer and a data layer; The step of obtaining the description data of the target data processing application solution includes: Acquire description data of the target data processing application solution sent by the visualization platform through the interface layer; The method further comprises: Storing the analysis result in the data layer; The step of generating source code of the target data processing application solution based on the parsing result, the predefined code snippet and the predefined engineering template, and generating engineering code for the target data processing application solution based on the source code includes: The parsing result is read from the data layer, and based on the parsing result, predefined code snippets and predefined engineering templates, the source code of the target data processing application solution is generated, and based on the source code, the engineering code for the target data processing application solution is generated.
3. The method according to claim 2, characterized in that The implementation layer includes a source code generator, an engineering code generator and predefined code snippets; the data layer stores engineering template files, and the parsing results include a process topology structure, an algorithm module description, an SDK interface description, and an algorithm module and SDK mapping; The step of reading the parsing result from the data layer, generating source code of the target data processing application solution based on the parsing result, predefined code snippets, and predefined engineering templates, and generating engineering code for the target data processing application solution based on the source code includes: Read the parsing result and the engineering template file from the data layer; call the source code generator to generate source code for the target data processing application solution using the algorithm module and SDK mapping, the algorithm module description, the SDK interface description, the predefined code snippets, the predefined engineering templates in the engineering template file, and the process topology structure; call the engineering code generator to generate engineering code for the target data processing application solution using the source code.
4. The method according to claim 1, characterized in that: Before parsing the description data to obtain the parsing result, the method further includes: Verifying the description data to obtain a verification result; If the verification result indicates that the description data has passed the verification, the description data is parsed to obtain a parsing result.
5. The method according to claim 1, characterized in that The method further comprises: The engineering code is stored in a designated storage space.
6. A code generation method, characterized in that: A visualization platform for building an engineering solution applied to a code generation system, the system also includes a code generation device, and the method includes: Based on the user's designated operations on each designated algorithm module of the preset data processing method in the visualization platform, a target data processing application solution is generated, wherein the target data processing application solution is a visual solution; When a code generation instruction is detected, description data of the target data processing application is generated according to the target data processing application solution; wherein the description data includes: module parameters of each specified algorithm module and interaction parameters characterizing the interaction relationship between each specified algorithm module, and the interaction parameters include: the interaction relationship between input data and output data, the connection order and subscription information between each specified algorithm module; The description data is sent to the code generation device so that the code generation device parses the description data to obtain a parsing result, generates source code of the target data processing application solution based on the parsing result, a predefined code fragment and a predefined engineering template, and generates engineering code for the target data processing application solution based on the source code, wherein the predefined engineering template is used to support the software using the predefined engineering template to run the engineering code.
7. The method according to claim 6, characterized in that The method further comprises: The target data processing application solution is displayed on a preset display interface.
8. A code generation device in a code generation system, characterized in that: The system also includes a visualization platform for building a data processing application solution, and the device includes: A data acquisition module, which acquires description data of a target data processing application scheme; wherein the target data processing application scheme is a visual scheme generated by the visualization platform based on a user's designated operation on each designated algorithm module of a preset data processing device in the visualization platform; the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module, and the interaction parameters include: the interaction relationship between input data and output data, connection sequence and subscription information between each designated algorithm module; A parsing module, used for parsing the description data to obtain a parsing result; A code generation module is used to generate source code of the target data processing application solution based on the parsing results, predefined code snippets and predefined engineering templates, and to generate engineering code for the target data processing application solution based on the source code, wherein the predefined engineering template is used to support the software using the predefined engineering template to run the engineering code.
9. The device according to claim 8, characterized in that The device comprises: an interface layer, an implementation layer and a data layer; the functions of the data acquisition module, the parsing module and the code generation module are all implemented by the implementation layer; The data acquisition module is specifically used to acquire the description data of the target data processing application solution sent by the visualization platform by calling the interface layer; The analysis module is further used to store the analysis result in the data layer; The code generation module is specifically used to read the parsing result from the data layer, and generate the source code of the target data processing application solution based on the parsing result, the predefined code snippet and the predefined engineering template, and generate the engineering code for the target data processing application solution based on the source code; and / or, The implementation layer includes a source code generator, an engineering code generator and predefined code snippets; the data layer stores engineering template files, and the parsing results include a process topology structure, an algorithm module description, an SDK interface description, and an algorithm module and SDK mapping; The code generation module is specifically used to read the parsing result and the engineering template file from the data layer; call the source code generator to generate source code for the target data processing application solution using the mapping between the algorithm module and the SDK, the algorithm module description, the SDK interface description, the predefined code snippet, the predefined engineering template in the engineering template file, and the process topology structure; call the engineering code generator to generate engineering code for the target data processing application solution using the source code; and / or, The device also includes: A verification module, used for verifying the description data to obtain a verification result before parsing the description data to obtain a parsing result; if the verification result indicates that the description data has passed the verification, the parsing module is triggered; and / or, The device also includes: The storage module is used to store the engineering code in a designated storage space.
10. A visualization platform, characterized in that: Applied to a code generation system, the system also includes a code generation device, the visualization platform is used to build an engineering solution, and the platform includes: A solution generation module, used to generate a target data processing application solution based on a user's specified operation on each specified algorithm module of a preset data processing device in the visualization platform, wherein the target data processing application solution is a visual solution; A data generation module, configured to generate description data of the target data processing application according to the target data processing application solution when a code generation instruction is detected; wherein the description data includes: module parameters of each designated algorithm module and interaction parameters characterizing the interaction relationship between each designated algorithm module, and the interaction parameters include: the interaction relationship between input data and output data, connection sequence and subscription information between each designated algorithm module; A data sending module is used to send the description data to the code generating device so that the code generating device parses the description data to obtain a parsing result, generates the source code of the target data processing application solution based on the parsing result, a predefined code fragment and a predefined engineering template, and generates engineering code for the target data processing application solution based on the source code, wherein the predefined engineering template is used to support the software using the predefined engineering template to run the engineering code.
11. The platform according to claim 10, characterized in that The platform also includes: The display module is used to display the target data processing application solution in a preset display interface.
12. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing the method described in any one of claims 1-5 or 6-7 when executing a program stored in a memory.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of claims 1-5 or 6-7 is implemented.
Citation Information
Patent Citations
Platform code generation method and device and server
CN109614097A
Code generation method and device, electronic equipment and computer storage medium
CN115857946A