Method, device and equipment for generating laser-marked numerical control machining program

CN123011251APending Publication Date: 2026-10-30SHENZHEN XINGHAN LASER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611520490.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0005]本申请实施例提供一种激光标刻数控加工程序的生成方法、装置及设备,以解决激光标刻数控加工程序的通用性较低的技术问题

Benefits of technology

[0050]第五方面,本申请实施例提供一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现上述提供的方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011251A_ABST
    Figure CN123011251A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a kind of laser marking numerical control processing program generation method, device and equipment.The method comprises: obtaining the canvas data corresponding to the target object to be printed, canvas data includes the original graphic data corresponding to the target object, the image processing data corresponding to original graphic data and marking parameter;Original graphic data includes at least one graphic element, and marking parameter is the marking parameter corresponding to each graphic element;According to the target image type of original graphic data and the preset mapping relationship, determine target marking type, the mapping relationship of the plurality of preset image types and preset marking type is stored in preset mapping relationship;Target image type is as follows any one: plane image, inner carving three-dimensional image, embossing three-dimensional image;According to the target file generation process corresponding to target marking type and canvas data generates corresponding target SVG file (Scalable Vector Graphics, scalable vector graphics);According to the target numerical control processing program corresponding to target SVG file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image data processing technology, and in particular to a method, apparatus and equipment for generating laser marking CNC machining programs. Background Technology

[0002] Laser marking CNC machining is a processing technology that uses a laser beam to mark and engrave on the surface or interior of materials. Marking objects include planar images, internally engraved 3D images, and relief 3D images. Laser marking systems typically involve canvas editing, path parsing, program generation, and equipment control. They need to adapt to various image types, including planar, internally engraved, and relief images, and transfer marking data between modules via equipment commands or common vector formats. Vector graphics, based on mathematical formulas to describe graphic outlines, paths, and coordinate points, are a relatively ideal graphic data carrier in the field of laser marking.

[0003] Existing laser marking systems primarily employ two data transmission methods. One is a direct transmission data processing scheme, where the marking software, after completing the graphic drawing in the canvas editing module, directly converts the original canvas editing data into a CNC machining program recognizable by the galvanometer device and transmits it point-to-point to the galvanometer control system. The other scheme uses Scalable Vector Graphics (SVG) as an intermediate data carrier. After presetting laser process parameters, the graphic data is converted into SVG format for transmission, and the laser processing trajectory is controlled based on the SVG shape data.

[0004] However, existing technical solutions have weak adaptability to different galvanometer systems and lack functional customization for laser marking. They not only fail to effectively carry the marking parameters corresponding to each graphic element, resulting in the separation of processing parameters from graphic data, but also the native multi-level nested structure of SVG increases the complexity of data parsing and has limited capacity to carry 3D images. It is difficult to transmit the data required for 3D processing in a unified vector file, making it difficult to form a unified and efficient data generation link when facing various marking needs. Consequently, the universality of laser marking CNC machining programs is low. Summary of the Invention

[0005] This application provides a method, apparatus, and equipment for generating laser marking CNC machining programs to solve the technical problem of low versatility of laser marking CNC machining programs.

[0006] In a first aspect, embodiments of this application provide a method for generating a laser marking CNC machining program, comprising:

[0007] Obtain the canvas data corresponding to the target object to be printed. The canvas data includes the original graphic data corresponding to the target object, the image processing data corresponding to the original graphic data, and the labeling parameters. The original graphic data includes at least one graphic element, and the labeling parameters are the labeling parameters corresponding to each graphic element.

[0008] The target marking type is determined based on the target image type and preset mapping relationship of the original graphic data. The preset mapping relationship stores multiple preset image types and preset marking types. The target image type can be any one of the following: planar image, internally carved 3D image, or relief 3D image.

[0009] Following the target file generation process corresponding to the target labeling type, and based on the original graphic data, the initial vector graphic label is determined. The initial vector graphic label is used to represent the structured description information of the original graphic data. Following the target file generation process, and based on the image processing data, the transformation matrix corresponding to the original graphic data is determined. The transformation matrix is ​​used to represent the geometric transformation information of the original graphic data in the canvas. Based on the initial vector graphic label, transformation matrix, and labeling parameters, the target vector graphic label is generated. The target vector graphic label is then converted into a target scalable vector SVG file.

[0010] Generate the corresponding target CNC machining program based on the target SVG file.

[0011] In one possible embodiment, the target image type is a planar image, and the original graphic data includes: graphic element type identifier, graphic geometric data, and rendering style;

[0012] Following the target file generation process corresponding to the target labeling type and determining the initial vector graphic labels corresponding to the original graphic data based on the original graphic data, including:

[0013] If the original graphic data is determined to contain combined graphic elements based on the graphic element type identifier, then the combined graphic elements are decombined to obtain a single graphic element.

[0014] Based on the graphic geometry data and rendering style, determine the structured description information of each individual graphic element, and based on the structured description information of each individual graphic element, determine the corresponding initial vector graphic label;

[0015] Following the target file generation process and determining the transformation matrix corresponding to the original graphic data based on the image processing data, including:

[0016] The transformation matrix corresponding to the original graphic data is determined based on the image processing data of each individual graphic element.

[0017] In one possible embodiment, the planar image is an SVG image or a DXF image; the SVG image or DXF image includes group elements;

[0018] When a single graphic element is grouped with other graphic elements, the corresponding initial vector graphic label is determined based on the structured description information of each individual graphic element, including:

[0019] The group elements are flattened based on the structured description information, image processing data, and calibration parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and calibration parameters of any sub-element in the group elements.

[0020] Determine the initial vector sub-label of any child element based on the structured description information of any child element;

[0021] The initial vector sub-labels are concatenated to obtain the initial vector sub-labels.

[0022] In one possible embodiment, determining the transformation matrix corresponding to the original graphic data based on the image processing data of each individual graphic element includes:

[0023] Determine the image processing data of any one of the sub-elements based on the image processing data of the group elements;

[0024] Determine the initial transformation matrix corresponding to any one of the sub-elements based on the image processing data of any one of the sub-elements;

[0025] Multiply the initial transformation matrix of any sub-element by the transformation matrix of the corresponding group element to obtain the final transformation matrix of any sub-element.

[0026] The final transformation matrix of any sub-element and the transformation matrix corresponding to the basic graphic element are concatenated to obtain the transformation matrix corresponding to the original graphic data. The basic graphic element is a single graphic element other than the group element.

[0027] In one possible embodiment, the group elements are flattened based on the structured description information, image processing data, and calibration parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and calibration parameters of any sub-element in the group elements, including:

[0028] Iterate through the child elements in the group, and perform the following operation on any child element;

[0029] If the current sub-element encountered is not a group element, then extract the structured description information of the current sub-element from the structured description information of the group element, extract the labeling parameters of the group element as the labeling parameters of the current sub-element, extract the image processing data of the current sub-element from the image processing data of the group element, and determine the transformation matrix of the current sub-element based on the image processing data.

[0030] If the current child element encountered during traversal is a nested group element, then the nested group element is recursively flattened to obtain the structured description information, transformation matrix, and marking parameters of any child element under the nested group element.

[0031] In one possible embodiment, the target image type is an internally sculpted 3D image;

[0032] Following the target file generation process corresponding to the target labeling type and determining the initial vector graphic labels corresponding to the original graphic data based on the original graphic data, including:

[0033] The original graphic data is compressed using a preset compression algorithm to obtain compressed data;

[0034] The compressed data is encoded using a preset encoding algorithm to obtain the first plain text data. The initial vector graphic label is the first plain text data.

[0035] In one possible embodiment, the target image type is a relief 3D image;

[0036] Following the target file generation process corresponding to the target labeling type and determining the initial vector graphic labels corresponding to the original graphic data based on the original graphic data, including:

[0037] The original graphic data is converted into a depth image, and the depth image is then converted into a grayscale image.

[0038] The grayscale image is encoded using a preset encoding algorithm to obtain the second plain text data. The initial vector graphic label is the second plain text data.

[0039] In one possible embodiment, generating target vector labels corresponding to the original graphic data based on the initial vector label, transformation matrix, and labeling parameters includes:

[0040] Add the transformation matrix and labeling parameters to the initial vector graphic labels to obtain the target vector graphic labels.

[0041] Secondly, embodiments of this application provide an apparatus for generating laser marking CNC machining programs, comprising:

[0042] The acquisition module is used to acquire the canvas data corresponding to the target object to be printed. The canvas data includes the original graphic data corresponding to the target object, the image processing data corresponding to the original graphic data, and the labeling parameters. The original graphic data includes at least one graphic element, and the labeling parameters are the labeling parameters corresponding to each graphic element.

[0043] The determination module is used to determine the target marking type based on the target image type and preset mapping relationship of the original graphic data. The preset mapping relationship stores multiple preset image types and preset marking types. The target image type can be any one of the following: planar image, internally carved 3D image, or relief 3D image.

[0044] The first generation module is used to determine the initial vector graphic label corresponding to the original graphic data according to the target file generation process corresponding to the target label type and based on the original graphic data. The initial vector graphic label is used to represent the structured description information of the original graphic data. The module is used to determine the transformation matrix corresponding to the original graphic data according to the target file generation process and based on the image processing data. The transformation matrix is ​​used to represent the geometric transformation information of the original graphic data in the canvas. The module generates the target vector graphic label corresponding to the original graphic data based on the initial vector graphic label, the transformation matrix, and the labeling parameters. The module converts the target vector graphic label into a target scalable vector graphic SVG file.

[0045] The second generation module is used to generate the corresponding target CNC machining program based on the target SVG file.

[0046] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;

[0047] The memory stores the instructions that the computer executes;

[0048] The processor executes computer execution instructions stored in memory, causing the processor to perform the methods described above.

[0049] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided above.

[0050] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the method described above.

[0051] The laser marking CNC machining program generation method, apparatus, and device provided in this application acquire canvas data containing original graphic data, image processing data, and marking parameters corresponding to each graphic element. Based on the mapping relationship between the target image type of the original graphic data and a preset marking type, the target marking type is determined. This allows for automatic matching of corresponding file generation processes for different image types, avoiding the need to develop separate processing links for different image types. Furthermore, a target SVG file is generated based on the target file generation process corresponding to the target marking type and the canvas data. The corresponding target CNC machining program is then generated from the target SVG file. This reduces the adaptation difficulty for processing multiple types of graphics, thereby improving the universality and processing efficiency of multi-type data conversion and transmission during the laser marking CNC machining program generation process. Moreover, the marking parameters corresponding to each graphic element are placed together with the original graphic data and image processing data in the canvas data, thus including the marking parameters in the generated target CNC machining program. This eliminates the need to obtain marking parameters from other locations, reducing the possibility of mismatch between the target object and the marking parameters. Attached Figure Description

[0052] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0053] Figure 1 An application scenario diagram of the laser marking CNC machining program generation method provided in an embodiment of this application;

[0054] Figure 2 A schematic flowchart illustrating a method for generating a laser marking CNC machining program according to an embodiment of this application;

[0055] Figure 3 A schematic diagram illustrating the principle of a method for generating a laser marking CNC machining program according to an embodiment of this application;

[0056] Figure 4 A flowchart illustrating a method for generating a CNC machining program for laser marking of a planar image, provided in an embodiment of this application;

[0057] Figure 5 A flowchart illustrating a method for generating a CNC machining program for laser marking of an internally engraved three-dimensional image, provided in an embodiment of this application;

[0058] Figure 6 A flowchart illustrating a method for generating a CNC machining program for laser marking of a relief three-dimensional image, provided in an embodiment of this application;

[0059] Figure 7 A flowchart illustrating a method for generating a laser marking CNC machining program according to another embodiment of this application;

[0060] Figure 8 A schematic diagram of the structure of a laser marking CNC machining program generation device provided in an embodiment of this application;

[0061] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0062] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0063] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0064] To clearly understand the technical solution of this application, the solutions of the prior art will be described in detail first.

[0065] Laser marking CNC machining uses a laser beam to form marks or patterns on or inside a material surface. Its application scenarios have gradually expanded from traditional industrial planar marking to the field of folk creative creation. The processing mode has also been upgraded from basic two-dimensional planar carving to three-dimensional marking, and a variety of new processing techniques such as model engraving, relief carving, and rotating surface carving have emerged.

[0066] In a laser marking system, the user draws, edits, and lays out the graphic to be marked using a canvas editing module, obtaining canvas editing data. The system then determines the laser processing path based on this data and converts it into processing data that the galvanometer device can recognize and execute. Finally, the galvanometer device controls the laser beam to complete the marking on or inside the material surface based on the processing data. The conversion and transmission between canvas editing data and processing data are crucial steps affecting the efficiency and versatility of laser marking CNC machining program generation.

[0067] In existing related technologies, one approach involves using a laser marking system's canvas editing module to complete graphic drawing and editing, then directly converting the original canvas editing data to generate processing data adapted to a specific galvanometer device. Another approach uses SVG to transfer graphic content between modules. The canvas editing module saves the edited graphic as an SVG file, and the galvanometer device reads the SVG file, parses its shape data, and then combines this with pre-set marking parameters to control the laser processing trajectory.

[0068] However, existing laser marking systems require the development of data conversion and transmission interfaces that match various galvanometer devices, making it difficult to form a unified intermediate data standard. Different laser marking systems and different galvanometer devices cannot be interchanged or compatible. Marking parameters and graphic elements are stored separately, making it difficult to manage the marking parameters of different graphic elements synchronously. When processing canvas data in complex editing processes, it is necessary to parse multi-level nested structures, which increases the processing burden. Existing SVG files have insufficient capacity to carry 3D information, resulting in lengthy conversion processes and incomplete processing information, which in turn affects the universality and processing efficiency of data conversion and transmission during the generation of laser marking CNC machining programs.

[0069] In view of this, to solve the above problems, a method for generating CNC machining programs for laser marking is provided. This method uses SVG files as a unified intermediate data format to carry the original graphic data, image processing data, and marking parameters corresponding to each graphic element. During the generation process, the canvas data corresponding to the target object to be printed is first obtained. This canvas data includes the original graphic data corresponding to the target object, the image processing data corresponding to the original graphic data, and the marking parameters corresponding to each graphic element. The original graphic data includes at least one graphic element. Then, based on the target image type of the original graphic data, the corresponding target marking type is searched in a preset mapping relationship. This preset mapping relationship stores multiple preset image types and preset marking types. The target image type can be any one of a planar image, an internally etched 3D image, or a relief 3D image. After determining the target marking type, the corresponding target SVG file is generated according to the target file generation process and canvas data corresponding to that target marking type. This ensures that the original graphic data, image processing data, and marking parameters corresponding to each graphic element are uniformly carried within the target SVG file. Finally, the corresponding target CNC machining program is generated based on the target SVG file. It enables data conversion between planar images, internally etched 3D images, and relief 3D images within a unified SVG format framework, avoiding the need to develop separate processing links for different image types, and improving the efficiency of laser marking CNC machining program generation and cross-device adaptability.

[0070] Figure 1 This is an application scenario diagram of the laser marking CNC machining program generation method provided in an embodiment of this application, such as... Figure 1 As shown, the application scenario corresponding to the laser marking CNC machining program generation method provided in this application may include: a terminal device 101 and a laser marking device 102. Specifically, the target CNC machining program is generated in the terminal device 101. Specifically, canvas data corresponding to the target object to be printed is obtained. The canvas data includes the original graphic data corresponding to the target object, image processing data corresponding to the original graphic data, and marking parameters. The original graphic data includes at least one graphic element, and the marking parameters are the marking parameters corresponding to each graphic element. The target marking type is determined based on the target image type of the original graphic data and a preset mapping relationship. The preset mapping relationship stores multiple preset image types and preset marking types; the target image type can be any one of the following: a planar image, an internally carved 3D image, or a relief 3D image. Following the target file generation process corresponding to the target marking type, and based on the original graphic data, the initial vector graphic label is determined. The initial vector graphic label is used to represent the structured description information of the original graphic data. Following the target file generation process, and based on the image processing data, the transformation matrix corresponding to the original graphic data is determined. The transformation matrix is ​​used to represent the geometric transformation information of the original graphic data in the canvas. Based on the initial vector graphic label, the transformation matrix, and the marking parameters, the target vector graphic label corresponding to the original graphic data is generated. The target vector graphic label is converted into a target SVG file. Based on the target SVG file, the corresponding target CNC machining program is generated, and the data of the target CNC machining program is transmitted to the laser marking device 102.

[0071] The terminal device 101 is one form of electronic device. Electronic devices can also take other forms, and this embodiment does not limit them.

[0072] Figure 2 This is a schematic flowchart of a method for generating a laser marking CNC machining program according to an embodiment of this application, as shown below. Figure 2 As shown, the execution subject of this embodiment is a laser marking CNC machining program generation device. This device can be implemented through a computer program, through a medium storing the relevant computer program, or through a physical device integrating or installing the relevant computer program. The laser marking CNC machining program generation method provided in this embodiment includes the following steps:

[0073] S201: Obtain the canvas data corresponding to the target object to be printed. The canvas data includes the original graphic data, image processing data and labeling parameters corresponding to the target object. The original graphic data includes at least one graphic element, and the labeling parameters are the labeling parameters corresponding to each graphic element.

[0074] Among them, the canvas data serves as the input data set for the entire generation process, and is used to centrally carry the graphic content of the target object, the editing results, and the control information required for subsequent processing.

[0075] The original graphic data is used to describe the actual graphic content of the object to be processed.

[0076] Among them, graphic elements are the basic building blocks of the original graphic data, and each graphic element corresponds to a structured description record.

[0077] Image processing data is used to characterize the geometric transformation information that the original graphic data undergoes in the canvas.

[0078] The marking parameters are used to specify the processing control information associated with the graphic elements and are bound according to the granularity of the graphic elements, so that different graphic elements maintain their own independent processing attributes in the same target object.

[0079] In practice, the process of acquiring canvas data can be triggered by the canvas editing module after the user completes drawing, importing, layout, and parameter setting, or it can be received by the laser marking CNC machining program generation device after the upstream design software exports a unified data object. For example, in one possible embodiment, after the user creates the target object via mouse, keyboard, touchscreen, or external file import, the canvas editing module generates canvas data for each graphic element, recording the image processing information and marking parameters formed during the editing stage. Subsequently, the laser marking CNC machining program generation device writes the original graphic data, image processing data, and marking parameters into a unified canvas data cache or intermediate data file, using the target object identifier as an index for storage.

[0080] In one possible embodiment, the canvas data can adopt a unified data organization method to associate and store multiple graphic elements and image processing data and marking parameters corresponding to element identifiers. Subsequent steps revolve around the same canvas data object to complete target image type recognition, target SVG file generation, and target CNC machining program generation.

[0081] Based on the above analysis, it is evident that by unifying the organization of the original graphic data, image processing data, and the corresponding annotation parameters for each graphic element, a complete structural foundation can be provided for the subsequent generation of the target SVG file. This reduces the need for repeatedly parsing the relationships between each graphic element and its image processing and annotation parameters, thereby lowering the complexity of data parsing. It should be understood that the above example is merely illustrative and not limiting.

[0082] S202: Determine the target marking type based on the target image type and preset mapping relationship of the original graphic data. The preset mapping relationship stores multiple preset image types and preset marking types. The target image type can be any one of the following: planar image, internally carved 3D image, or relief 3D image.

[0083] Among them, the target image type is used to characterize the image category to which the original graphic data corresponding to the target object belongs.

[0084] The preset mapping relationship is used to determine the target marking type corresponding to the target image type based on the target image type of the original graphic data.

[0085] Among them, the target marking type is the direct basis for determining the subsequent target file generation process, and its function is to select the corresponding file generation and processing path for different types of images.

[0086] Among them, the planar image corresponds to the two-dimensional planar marking scene, the internal carving three-dimensional image corresponds to the scene of forming a dot matrix, layer matrix or volume carving inside the transparent material, and the relief three-dimensional image corresponds to the surface height change processing scene.

[0087] In practice, the laser marking CNC machining program generation device first reads the data structure information and type identification content in the original graphic data after acquiring the canvas data in order to determine the target image type.

[0088] As an optional approach, the graphic element type identifier, geometric data dimension, and data field name in the original graphic data can be read. For example, when the original graphic data contains only two-dimensional graphic elements, such as line segments, rectangles, circles, paths, text, or bitmaps, and the graphic geometric data only has two-dimensional coordinate information, the target image type is determined to be a planar image; when the original graphic data is three-dimensional point cloud data or three-dimensional mesh model data, containing three-dimensional point coordinates, triangular patch indices, or voxel data, and the above data is used to describe the position and distribution of laser burst points inside the material, the target image type is determined to be an internally sculpted three-dimensional image; when the original graphic data contains height field data, depth map data, or surface model data with depth attributes, and the data contains the height or depth value of each sampling point to describe the relief effect of the material surface, the target image type is determined to be a relief three-dimensional image.

[0089] Pre-defined mapping relationships can be stored in the system configuration table, equipment process library, or template database. These relationships must include at least an image type field and a marking type field with the mapping relationship. The laser marking CNC machining program generation device retrieves the corresponding record based on the target image type and outputs the target marking type.

[0090] In one possible embodiment, the preset mapping relationship is stored using a key-value pair structure, where the key is the image type code and the value is the marking type code. For example, a two-dimensional image code corresponds to a planar marking type code, an internally carved three-dimensional image code corresponds to an internally carved marking type code, and a relief three-dimensional image code corresponds to a relief marking type code. When the laser marking CNC machining program generation device needs to adapt to different laser marking equipment or different marking materials, the machining process control parameters associated with the preset marking type code can be adjusted based on the preset mapping relationship while keeping the image type unchanged. These machining process control parameters may include, but are not limited to, machining paths, layering parameters, parameters related to the capabilities of the laser marking equipment, and parameters related to the marking material.

[0091] Based on the above analysis, this step selects the file generation process for the original graphic data through a preset mapping relationship, so that the subsequent SVG file generation process no longer relies on temporary manual selection or repeated judgment, thus maintaining a consistent data conversion rule. It should be understood that the above example is merely illustrative and not limiting.

[0092] S203: Following the target file generation process corresponding to the target labeling type and based on the original graphic data, determine the initial vector graphic label corresponding to the original graphic data. The initial vector graphic label is used to represent the structured description information of the original graphic data. Following the target file generation process and based on the image processing data, determine the transformation matrix corresponding to the original graphic data. The transformation matrix is ​​used to represent the geometric transformation information of the original graphic data in the canvas. Generate the target vector graphic label corresponding to the original graphic data based on the initial vector graphic label, the transformation matrix, and the labeling parameters. Convert the target vector graphic label into a target scalable vector SVG file.

[0093] The structured description information of the original graphic data refers to the information obtained after standardizing the description of the geometric shape, path, coordinates, rendering style, etc. of the graphic elements. For planar images, the original graphic data contains basic graphic elements such as line segments, rectangles, circles, paths, and text; for internally sculpted 3D images, the original graphic data contains 3D point cloud or mesh model data; for relief 3D images, the original graphic data contains depth maps or height field data.

[0094] In the specific implementation, after the raw graphic data enters the target file generation process, structured description information is first generated based on the geometric contours, rendering styles, and element relationships of the graphic elements, and this structured description information is written into the corresponding initial vector graphic tag. Based on the image processing data, transformation matrices are generated for the translation, rotation, and other operations corresponding to each graphic element. Subsequently, the structured description information in the initial vector graphic tag is associated with the transformation matrix, and calibration parameters such as power, speed, frequency, or depth are written in to form the target vector graphic tag. Finally, the target vector graphic tag is serialized and output according to the SVG file format to obtain the target SVG file that can be parsed by the subsequent target CNC machining program.

[0095] In one possible implementation, generating a target vector label corresponding to the original graphic data based on the initial vector label, the transformation matrix, and the labeling parameters includes: adding the transformation matrix and the labeling parameters to the initial vector label to obtain the target vector label.

[0096] In practical implementation, the initial vector graphic label can be used as the base node. The transformation matrix is ​​written into the corresponding transformation attribute field according to the preset label syntax, and the marking parameters are written into the power, speed, frequency, or path control fields. The written label is then output as the target vector graphic label. The writing process can be completed through string concatenation, attribute replacement, or node attribute appending. When the initial vector graphic label is a path label or a graphic element label, the corresponding transformation and marking information can be added while maintaining the original structural description. In practical applications, other parsable text markup formats can also be selected; this application does not limit this choice.

[0097] In this embodiment, generating a target vector label corresponding to the original graphic data based on the initial vector label, transformation matrix, and marking parameters includes: adding the transformation matrix and marking parameters to the initial vector label to obtain the target vector label. By synchronously retaining image processing information and marking parameter information in the target vector label, information loss during label parsing can be reduced; simultaneously, the target SVG file can directly support subsequent CNC machining program generation after generation, and the program can complete parameter extraction and instruction construction based on the target vector label during program generation, thereby improving the consistency of data transmission and the efficiency of program generation.

[0098] S204: Generate the corresponding target CNC machining program based on the target SVG file.

[0099] The target CNC machining program is used to drive the laser marking equipment to perform actual machining. The program content includes at least motion trajectory instructions, laser switch instructions, and process parameter setting instructions corresponding to graphic elements.

[0100] Optionally, the target CNC machining program can adopt a special instruction format, a general CNC instruction format, or an intermediate trajectory description format supported by the laser marking equipment, as long as it can be executed by the subsequent galvanometer control board, three-axis platform, or laser control unit.

[0101] In practice, the laser marking CNC machining program generation device first reads the target SVG file and performs syntax parsing. Then, based on the original graphic data, image processing information, and marking parameter information in the target SVG file, it generates machining instructions matching the target marking type. For target SVG files corresponding to planar images, the laser marking CNC machining program generation device extracts the graphic path information and marking parameters, converting them into machining trajectories and control instructions executable by the laser marking equipment. For target SVG files corresponding to internally carved 3D images, the device extracts data and marking parameters related to 3D machining, generating corresponding multi-layer or multi-point machining instruction sequences. For target SVG files corresponding to relief 3D images, the device extracts data and marking parameters related to depth changes, generating corresponding machining trajectories and control instructions. After generating the corresponding trajectory, the laser marking CNC machining program generation device outputs a complete CNC machining program according to the command structure supported by the laser marking equipment.

[0102] In one possible embodiment, the conversion from the target SVG file to the target CNC machining program is achieved using a unified parsing interface and a type distribution mechanism. The unified parsing interface is responsible for reading the file, verifying the version, extracting the file content and common attributes; the type distribution mechanism calls the corresponding parser based on the target marking type. After parsing, the laser marking CNC machining program generation device performs format verification and boundary checks on the obtained target CNC machining program, including coordinate range checks, layer validity checks, parameter missing checks, and instruction sequence checks. After passing the verification, the program is output to the control buffer, machining task file, or communication interface of the laser marking equipment.

[0103] This step involves uniformly parsing the original graphic data, image processing information, and marking parameter information in the target SVG file to directly generate a CNC machining program that matches the target object and marking type. This ensures that the canvas data can be stably converted into a CNC machining program executable by the laser marking equipment. It eliminates the need to backfill marking parameters from an external parameter table during the CNC machining program generation process, thereby reducing the possibility of mismatch between the target object and marking parameters.

[0104] Figure 3 A schematic diagram illustrating the principle of a laser marking CNC machining program generation method provided in an embodiment of this application, as shown below. Figure 3As shown, the process acquires canvas data, including raw graphic data, image processing data, and marking parameters. The raw graphic data includes self-drawn graphics, PNG, JPG, SVG, DXF, and 3D graphic data. Image processing data includes data on combination, rotation, mirroring, and stroke. Marking parameters include line engraving, fill engraving, line cutting, inner engraving, relief engraving, and image engraving. The process identifies the marking type of the canvas data and initiates the corresponding file generation process. This process includes generating SVG files for planar images, SVG files for inner-carved 3D images, and SVG files for relief 3D images, resulting in corresponding SVG files. Finally, a corresponding CNC machining program is generated based on the SVG files.

[0105] This application provides a method for generating a laser marking CNC machining program, including acquiring canvas data corresponding to the target object to be printed, determining the target marking type based on the target image type and preset mapping relationship of the original graphic data, generating a corresponding target scalable vector graphic (SVG) file according to the target file generation process corresponding to the target marking type and the canvas data, and generating a corresponding target CNC machining program based on the target SVG file. By unifying the original graphic data, image processing data, and marking parameters corresponding to each graphic element into canvas data, and after recognizing planar images, internally carved 3D images, and relief 3D images, the corresponding target file generation process is used to write the original graphic data information, image processing information, and marking parameters together into the target SVG file, and then generating the CNC machining program accordingly. This enables a standardized data transfer relationship between canvas editing, SVG data generation, and CNC machining program generation, avoiding repeated parsing of the correlation between each graphic element during the CNC machining program generation stage. The target CNC machining program contains the marking parameters corresponding to each graphic element, eliminating the need to obtain marking parameters from other locations, and reducing the possibility of mismatch between the target object and marking parameters. Data of different image types can also be carried under a unified file framework, eliminating the need to build separate processing links for each image type. This reduces the difficulty of adapting to multiple image types and improves the universality and processing efficiency of data conversion and transmission.

[0106] Based on the aforementioned embodiments, the target image type is further defined as a planar image, and the original graphic data includes: graphic element type identifier, graphic geometric data, and rendering style. The process of generating a target file corresponding to the target label type and determining the initial vector graphic label corresponding to the original graphic data includes: if the original graphic data contains combined graphic elements based on the graphic element type identifier, then the combined graphic elements are decombined to obtain individual graphic elements; the structured description information of each individual graphic element is determined based on the graphic geometric data and rendering style, and the corresponding initial vector graphic label is determined based on the structured description information of each individual graphic element; the transformation matrix corresponding to the original graphic data is determined according to the target file generation process and based on the image processing data, including: determining the transformation matrix corresponding to the original graphic data based on the image processing data of each individual graphic element.

[0107] The graphic element type identifier is used to distinguish whether the current graphic element is a basic graphic element or a composite graphic element. It can be identified by a preset type field, label name, or enumeration value.

[0108] Among them, graphic geometric data is used to describe the geometric information of graphic elements, such as shape, position, size, and path nodes.

[0109] Among them, rendering style is used to describe the visual representation information of graphic elements, such as fill color, stroke color, line width, transparency, and dashed line style.

[0110] In practice, the laser marking CNC machining program generation device first parses the original graphic data. When the graphic element type identifier indicates the existence of combined graphic elements, the combined graphic elements are decombined to obtain independent single graphic elements, and their geometric boundaries, path parameters, rendering attributes, marking parameters and other information are extracted respectively.

[0111] Among them, a combined graphic element refers to a graphic element formed during the canvas editing process, which is a combination of multiple basic graphic elements or sub-combined graphic elements, such as an icon composed of multiple line segments and rectangles, or a group object containing multiple sub-layers.

[0112] Among them, the decomposition process is used to break down the original single graphic elements that were combined into independent graphic elements that can be processed separately while keeping the visual result unchanged, and to eliminate the coupling effect of the overall transformation of the combination on the coordinates and attributes of each single graphic element.

[0113] In practical implementation, the decomposition process may include the following steps:

[0114] (1) Check if the current graphic element is a combination type. If the graphic element type identifier indicates that the current element is not a combination type, there is no need to uncombine it, and it can be directly used as a single graphic element in the subsequent process; if it is a combination type, the subsequent uncombine steps are executed.

[0115] (2) Extract the overall transformation parameters and combination attributes of the combined graphic elements. The overall transformation parameters include the geometric transformation information such as translation, rotation, mirroring, and scaling that the combined graphic elements have undergone; the combination attributes include the rendering style and labeling parameters of the combined graphic elements.

[0116] (3) Calculate the sine and cosine values ​​of the rotation angle based on the rotation angle of the combined graphic elements. These values ​​are used for subsequent rotation calculations on the coordinates of individual graphic elements. The two-dimensional rotation matrix R corresponding to the rotation angle θ can be determined by the rotation angle θ according to the following formula:

[0117]

[0118] When the canvas data uses screen coordinates (i.e., Y-axis pointing downwards), since standard rotation formulas are usually based on mathematical coordinates (Y-axis pointing upwards), when substituting the values ​​into the rotation formula, the sine value needs to be inverted before being substituted into the 2D rotation matrix R to obtain the adjusted rotation matrix R′. This ensures that the rotation direction is consistent with the visual direction on the canvas. The formula for the adjusted rotation matrix R′ is:

[0119]

[0120] (4) Traverse each individual graphic element in the combined graphic elements. Optionally, to avoid modifying the original data, each individual graphic element can be copied to obtain a corresponding copy, and the copy can be updated with coordinates and attributes later.

[0121] (5) For each individual graphic element encountered during the traversal, process it according to its type:

[0122] For basic single graphic elements such as lines, circles, and rectangles, the absolute position of the shape's center point is first calculated based on the coordinates of the combined center and the offset of the shape's center relative to the combined center. Then, if the combined graphic element undergoes a rotation transformation, a two-dimensional rotation operation is performed on the offset of the shape's center relative to the combined center using the adjusted rotation matrix R′ to obtain the new offset after rotation. The new offset after rotation is then added to the coordinates of the combined center to obtain the final position of the shape's center point after rotation.

[0123] If the combined graphic elements also have mirror transformations, then the mirror matrix needs to be determined based on the mirror markers of the combined graphic elements. Specifically, when the combined graphic elements have horizontal mirrors, the horizontal mirror matrix... It can be represented as:

[0124]

[0125] When combined graphic elements have vertical mirrors, the vertical mirror matrix It can be represented as:

[0126]

[0127] If both horizontal and vertical mirroring exist simultaneously, it is equivalent to mirroring in two directions at the same time, resulting in a horizontal and vertical mirroring matrix. for:

[0128]

[0129] After determining the mirror matrix, the mirror matrix is ​​multiplied by the adjusted rotation matrix R′ according to the actual transformation order to obtain the composite transformation matrix. For example, if the actual transformation is mirroring followed by rotation, the composite transformation matrix is ​​the product of the rotation matrix and the mirror matrix; if it is rotation followed by mirroring, the composite transformation matrix is ​​the product of the mirror matrix and the rotation matrix. Then, the composite transformation matrix is ​​used to perform a linear transformation on the offset of the shape's center relative to the combined center to obtain the new offset. After obtaining the new offset, this new offset is added to the coordinates of the combined center; the resulting coordinates are the final position of the shape's center point after rotation and mirroring.

[0130] After obtaining the final position of the center point of the rotated and mirrored shape, it is also necessary to determine the axis-aligned circumrectangle of the rotated shape in order to update the vertex coordinates and size of the single graphic element. Specifically, obtain the half-width and half-height of the shape in its own local coordinate system; using the center point of the rotated shape as the origin, calculate the offset coordinates of the four local corner points relative to the new center using the half-width and half-height, namely the top left, top right, bottom left, and bottom right directions; perform a two-dimensional rotation operation on these four corner point offset coordinates using a composite transformation matrix; add the offset values ​​of the four corner points to the coordinates of the rotated shape's center to obtain the world coordinates of the four corner points; compare the x and y coordinates of the four corner points and find the minimum value of the x coordinate. and maximum value Minimum value of the ordinate and maximum value ,but( , )and( , This means aligning the rotated shape's axes with the two diagonal vertices of the circumscribed rectangle. Finally, update the vertex coordinates, size, and center point position of the single graphic element based on the circumscribed rectangle.

[0131] For other types of single graphic elements such as images, SVG data, and DXF data, the absolute position of its shape center point is directly calculated and its position information is updated without the need to perform outer rectangle calculation based on half width and half height.

[0132] (6) After updating the coordinates and attributes of a single graphic element, update the labeling parameters of that single graphic element. In practice, the labeling parameters of the combined graphic elements can be inherited by each single graphic element, or the parameters can be adjusted independently according to the specific situation of each single graphic element. After the update is completed, add the single graphic element to the uncombined element list.

[0133] (7) Return the list of elements after decomposition. After decomposition, all elements are independent single graphic elements, each with its own transformation information determined by its image processing data, and can be used to generate initial vector map labels and calculate transformation matrices respectively.

[0134] It should be noted that the decomposition process can be carried out layer by layer. If there are nested sub-combined graphic elements in the combined graphic elements, the sub-combined graphic elements can continue to be decomposed until an indivisible single graphic element is obtained. If the single graphic element obtained after decomposition still contains group elements, it can be further flattened in accordance with the processing method of group elements. This embodiment does not make specific limitations on this.

[0135] After obtaining each individual graphic element, the graphic geometry data and rendering style of each individual graphic element are mapped into structured description information, and the corresponding initial vector graphic label is generated based on the structured description information.

[0136] Structured descriptive information refers to textual information that can describe the geometric and rendering features of graphic elements in a standardized format. For example, for a rectangular graphic element, a corresponding initial vector graphic label can be generated based on its top-left corner coordinates, width, height, and corner radius in its geometric data; for a circular graphic element, a corresponding initial vector graphic label can be generated based on the center coordinates and radius; and for a path graphic element, a corresponding initial vector graphic label can be generated based on the path command and the sequence of coordinate points.

[0137] For image processing data, the laser marking CNC machining program generation device represents the rotation, scaling, translation, and mirroring information of individual graphic elements on the canvas in a matrix format. Specifically, each individual graphic element corresponds to a set of image processing data, which records the geometric transformation operations such as translation, scaling, rotation, mirroring, and tilting that individual graphic element undergoes on the canvas. After determining the transformation matrix of each individual graphic element, these transformation matrices can be organized according to the order of the graphic elements to obtain the transformation matrix corresponding to the original graphic data.

[0138] In this embodiment, the target image type is a planar image, and the original graphic data includes: graphic element type identifier, graphic geometric data, and rendering style; the initial vector label corresponding to the original graphic data is determined according to the target file generation process corresponding to the target label type and based on the original graphic data, including: if it is determined from the graphic element type identifier that the original graphic data contains combined graphic elements, then the combined graphic elements are decombined to obtain single graphic elements; the structured description information of each single graphic element is determined according to the graphic geometric data and rendering style, and the corresponding initial vector label is determined according to the structured description information of each single graphic element; the transformation matrix corresponding to the original graphic data is determined according to the target file generation process and based on the image processing data, including: determining the transformation matrix corresponding to the original graphic data based on the image processing data of each single graphic element. By decomposing the combined graphic elements of an SVG image, each individual graphic element can directly obtain an independent initial vector graphic label. The laser marking CNC machining program generation device associates the transformation matrix of each individual graphic element with the corresponding initial vector graphic label. This enables the combined structure in the planar image to be decomposed into individually parseable graphic elements, and the geometric data, rendering style, and transformation information of each graphic element are synchronously stored in the target SVG file. This ensures that the geometric description and machining parameters of each sub-element are stored independently in the SVG file, thereby forming a vectorized data carrier that matches the subsequent CNC machining program generation, avoiding the increase in parsing complexity caused by the combined structure.

[0139] Based on the aforementioned embodiments, the planar image is further defined as an SVG or DXF image; the SVG or DXF image includes group elements; when a single graphic element is a group element, the corresponding initial vector graphic label is determined based on the structured description information of each single graphic element, including: flattening the group element according to the structured description information, image processing data, and labeling parameters corresponding to the group element to obtain the structured description information, transformation matrix, and labeling parameters of any sub-element in the group element; determining the initial vector graphic sub-label of any sub-element based on the structured description information of any sub-element; and splicing the initial vector graphic sub-labels to obtain the initial vector graphic label.

[0140] In this context, a group element refers to a container element in the SVG format used to group multiple graphic elements together for unified management and transformation, such as the element in SVG. <g>element.

[0141] If, after the original graphic data has been decombined, there are still group elements in the resulting single graphic element, then the group element needs to be flattened to eliminate the nested relationship of the group hierarchy, so that each sub-element within the group element becomes a single graphic element that can be independently described and labeled.

[0142] In the specific implementation, the SVG file is parsed into an Extensible Markup Language (XML) Document Object Model (DOM), resulting in the corresponding DOM tree. Each group element corresponds to an element node in the DOM tree, which expresses the structured description information of the group element through its attributes and child nodes. Image processing data is generated by the canvas editing module based on user operations such as translation, scaling, rotation, and mirroring of the group elements, used to record the geometric transformation information experienced by the group element as a whole. Marking parameters can be read from a preset processing configuration table and written as custom attributes or child nodes into the corresponding DOM node of the group element.

[0143] During processing, the laser marking CNC machining program generation device first reads the hierarchical nodes of the group element, then passes the geometric transformation matrix and marking parameters from the parent node down to any child element, while simultaneously generating a corresponding local description fragment based on the child element's own structured description information. Subsequently, based on the child element's node type, path command, and rendering style parameters, initial vector graphic sub-tags are generated and arranged sequentially according to the original order of the child elements within the group element, resulting in an initial vector graphic tag containing multiple sub-tags that can directly participate in the generation of subsequent target vector graphic tags. If the group element contains nested group elements, the laser marking CNC machining program generation device flattens the layers one by one, multiplies the transformation matrices of each layer, synthesizes them, and then passes them down to the target child element. In practical applications, this processing module can also use different XML parsers or vector tag generators; this application does not limit this.

[0144] In this embodiment, the planar image is an SVG or DXF image; the SVG or DXF image includes group elements; when a single graphic element is a group element, the corresponding initial vector graphic label is determined based on the structured description information of each single graphic element, including: flattening the group element according to the structured description information, image processing data, and labeling parameters to obtain the structured description information, transformation matrix, and labeling parameters of any sub-element in the group element; determining the initial vector graphic sub-label of any sub-element based on the structured description information of any sub-element; and splicing the initial vector graphic sub-labels to obtain the initial vector graphic label. By uniformly allocating the hierarchical information, image processing information, and labeling parameter information of the group element to the sub-element level, the group element does not need to repeatedly parse its nesting relationship in subsequent steps, the graphic description and processing parameters of the sub-element can be preserved synchronously, the generated initial vector graphic label is consistent with the actual editing result in the canvas, and each sub-element has complete attribute information that can be directly used for label generation, which can provide a consistent label basis for the subsequent generation of the target SVG file, thereby improving the generation efficiency of the target SVG file.

[0145] Based on the aforementioned embodiments, further, determining the transformation matrix corresponding to the original graphic data according to the image processing data of each individual graphic element includes: determining the image processing data of any one sub-element based on the image processing data of the group elements; determining the initial transformation matrix corresponding to any one sub-element based on the image processing data of any one sub-element; multiplying the initial transformation matrix of any one sub-element with the transformation matrix of the corresponding group element to obtain the final transformation matrix of any one sub-element; and concatenating the final transformation matrix of any one sub-element with the transformation matrix corresponding to the basic graphic element to obtain the transformation matrix corresponding to the original graphic data, wherein the basic graphic element is a single graphic element other than the group elements.

[0146] The image processing data of the group element is used to record the transformation information that the group element as a whole undergoes in the canvas, and also to record the local transformation information of each sub-element within the group element.

[0147] The image processing data of the sub-element is used to describe the transformation of the sub-element in the local coordinate system of the group element and the overall impact of the transformation of the group element on the sub-element.

[0148] The initial transformation matrix corresponding to the sub-element is used to represent the local transformation relationship of the sub-element when the overall transformation of the group elements is not considered.

[0149] The transformation matrix of a group element is determined based on the overall image processing data of the group element itself, and is used to represent the transformation relationship of the group element as a whole in the canvas.

[0150] In this context, basic graphic elements are independent graphic elements that do not belong to any group of elements within a single graphic data set. The transformation matrix of a basic graphic element can be directly determined based on its respective image processing data.

[0151] In practice, the laser marking CNC machining program generation device first reads the image processing data of the group elements, extracts the overall transformation information of the group elements and the local transformation information corresponding to each sub-element in the group elements, and together they constitute the image processing data of the sub-element. Then, an initial transformation matrix is ​​generated based on the image processing data of the sub-element.

[0152] For example, following the order of the actual transformation operations of the sub-elements, each transformation operation is sequentially converted into its corresponding basic transformation matrix, and the basic transformation matrices are multiplied together according to the order of the transformations. For translation operations, a translation matrix is ​​constructed based on the horizontal and vertical translation amounts in the image processing data; for rotation operations, a rotation matrix is ​​constructed based on the rotation angle; for scaling operations, a scaling matrix is ​​constructed based on the horizontal and vertical scaling ratios; for mirroring operations, a corresponding mirror matrix is ​​constructed based on the horizontal or vertical mirroring marker. The basic transformation matrix corresponding to each transformation operation can be determined according to its operation parameters according to preset matrix construction rules. After obtaining the basic transformation matrices corresponding to each transformation operation, these basic transformation matrices are multiplied sequentially according to the order in which the actual transformation operations of the sub-elements occur. When using column vectors to represent coordinates, the matrix corresponding to the earlier transformation is usually located on the right, and the matrix corresponding to the later transformation is located on the left; the specific multiplication order can be adjusted according to the coordinate representation method and the order of transformation application, and this embodiment does not impose any restrictions on this.

[0153] Next, the initial transformation matrix is ​​multiplied by the transformation matrices of the corresponding group elements to obtain the final transformation matrix of any sub-element in the original graphic data coordinate system. Since each sub-element within a group first undergoes its own local transformation and then the overall transformation of the group, the initial transformation matrix of the sub-element is usually multiplied by the transformation matrix of the group element in the order of transformation during matrix operations. This ensures that the final transformation matrix correctly reflects the superposition effect of the local and overall transformations. When using column vectors to represent coordinates, the matrix corresponding to the earlier transformation is usually on the right, and the matrix corresponding to the later transformation is on the left. The specific multiplication order can be adjusted according to the coordinate representation method and the order of transformation application; this embodiment does not impose any restrictions on this.

[0154] For basic graphic elements that do not belong to the group elements, their corresponding transformation matrix is ​​directly read and concatenated with the final transformation matrix of any one of the child elements according to the organization relationship of the original graphic data to form the complete transformation matrix corresponding to the original graphic data.

[0155] As an alternative, the stitching process can be performed by sequentially combining the transformation matrices of the basic graphic elements with the final transformation matrices of each sub-element after the group elements have been flattened, according to the arrangement order of the individual graphic elements in the original graphic data, to form a complete set of transformation matrices. This set of transformation matrices corresponds one-to-one with each graphic element in the original graphic data and is used to represent the geometric transformation information of each graphic element on the canvas.

[0156] In a feasible implementation, the image processing data of group elements is stored in a unified intermediate data carrier. Within this carrier, an index relationship is established based on the sub-element identifiers. During parsing, the laser marking CNC machining program generation device locates the corresponding sub-element based on its identifier and inherits the translation offset and rotation reference of the group elements. The matrix multiplication order is determined according to the hierarchical nesting relationship, so that the local coordinates of the sub-elements are first converted to in-group coordinates, and then to canvas coordinates. The basic graphic elements retain their independent transformation results and participate in the final stitching. If the original graphic data contains multiple group elements and multiple basic graphic elements simultaneously, the final transformation matrices can be uniformly merged according to the element traversal order to obtain the overall transformation matrix used for subsequent vector label generation and CNC machining program generation.

[0157] In this embodiment, the transformation matrix corresponding to the original graphic data is determined based on the image processing data of each individual graphic element. This includes: determining the image processing data of any sub-element based on the image processing data of the group elements; determining the initial transformation matrix corresponding to any sub-element based on the image processing data of the sub-element; multiplying the initial transformation matrix of the sub-element with the transformation matrix of the corresponding group element to obtain the final transformation matrix of the sub-element; and concatenating the final transformation matrix of the sub-element with the transformation matrix corresponding to the basic graphic element to obtain the transformation matrix corresponding to the original graphic data. The basic graphic element is a single graphic element other than the group elements. By merging the local transformations of sub-elements, the hierarchical transformations of group elements, and the independent transformations of basic graphic elements within the same final transformation matrix system, the overall geometric relationship of the original graphic data can be accurately preserved, ensuring the consistency of the visual position and posture of the graphics before and after flattening. Simultaneously, accurate geometric transformation data is provided for subsequent SVG file generation and CNC machining program generation.

[0158] Based on the aforementioned embodiments, further, the group elements are flattened according to the structured description information, image processing data, and labeling parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and labeling parameters of any sub-element in the group elements. This includes: traversing each sub-element in the group elements and performing the following operations for any sub-element; if the current sub-element encountered is not a group element, then extracting the structured description information of the current sub-element from the structured description information of the group elements, extracting the labeling parameters of the group elements as the labeling parameters of the current sub-element, extracting the image processing data of the current sub-element from the image processing data of the group elements, and determining the transformation matrix of the current sub-element based on the image processing data; if the current sub-element encountered is a nested group element, then recursively performing flattening processing on the nested group elements to obtain the structured description information, transformation matrix, and labeling parameters of any sub-element under the nested group elements.

[0159] In practical implementation, the structured description information, image processing data, and labeling parameters of group elements can be uniformly stored in an intermediate data carrier. Each child element in the carrier is associated with an index, allowing for the retrieval of the corresponding content by index during traversal. When traversing each child element within a group element, it is first determined whether the current child element contains a next-level group structure. If not, the structured description information corresponding to the index of that child element in the group element is directly used as the structured description information of the current child element. Simultaneously, the labeling parameters bound to the group element are directly passed down to the current child element, and the image processing data corresponding to that child element is read from the image processing data of the group element. The transformation matrix of the current child element is calculated based on the image processing data corresponding to the child element. If the current child element itself is still a group structure, the same traversal and downlink processing is performed on that child element, causing its internal child nodes to inherit the structured description information fragments, labeling parameters, and image processing data carried by the upper-level group element, forming an independent description corresponding to each leaf node after layer-by-layer expansion.

[0160] As an optional approach, flattening can be achieved by traversing the child nodes of the group element node in the DOM tree. During the traversal, a current cumulative matrix and a current attribute set are maintained to record the accumulated geometric transformation information and attribute information from the root group element to the current node, respectively. The parent matrix refers to the cumulative transformation matrix corresponding to the parent node of the current node; the parent attribute set refers to the attribute set corresponding to the parent node of the current node. Initially, the parent matrix of the outermost group element is set to the identity matrix, and the parent attribute set of the outermost group element is set to an empty set or the attribute set of the group element itself.

[0161] For any child element in the group, perform the following operation:

[0162] First, the parent matrix is ​​copied to generate a copy of the current cumulative matrix, independent of the parent matrix. Then, it is checked whether the current child element carries attribute information representing geometric transformations. If the current child element carries such a transformation attribute, the transformation function string corresponding to that attribute is parsed, generating the node transformation matrix for the current child element. The current cumulative matrix copy is then multiplied left by this node transformation matrix, and the result is used to update the current cumulative matrix. If the current child element does not carry a transformation attribute, the current cumulative matrix remains a copy of the parent matrix. Therefore, the current cumulative matrix represents the cumulative geometric transformation relationship from the current child element to the global coordinate system of the canvas.

[0163] Then, the parent property set is copied to generate the current property set. The properties carried by the current child element are retrieved, and their values ​​are used to overwrite the corresponding property items in the current property set. The current property set can contain rendering style properties and properties corresponding to marked parameters. For example, if the current child element carries marked parameter properties such as fill color, stroke color, line width, laser power, or processing speed, these property values ​​are used to overwrite the corresponding items in the current property set; if the current child element does not carry a certain property, the property value inherited from the parent element in the current property set is used.

[0164] Next, determine whether the currently traversed child element is a group element. This determination can be made based on whether the current child element contains a next-level child node: if the current child element still contains a next-level child node, then the current child element is determined to be a nested group element; if the current child element no longer contains a next-level child node, then the current child element is determined to be a non-group element.

[0165] If the current child element is not a group element, then the corresponding structured description information is generated based on the child element's tag type. Specifically, if the current child element is a basic geometric shape tag, such as a rectangle tag, circle tag, ellipse tag, or polyline tag, then based on the child element's geometric parameters, the corresponding processing function is used to convert it into an equivalent path tag, obtaining the corresponding path data; if the current child element itself is already a path tag, then its existing path data is used directly. Thus, the structured description information of the flattened child element is obtained in the form of path tags and their path data.

[0166] After obtaining the path label, the updated current cumulative matrix is ​​used as the final transformation matrix for the child element and written into the transformation attribute of the path label to maintain the geometric position and orientation of the child element in the canvas consistent with before flattening. Simultaneously, the updated current attribute set is written into the path label. The laser marking data in the current attribute set can be written into the path label as custom attributes or child nodes, thus making the path label contain not only graphic geometric information but also the corresponding marking parameters. The path label carrying the final transformation matrix and marking parameters is the initial vector sub-label corresponding to the non-group element child node.

[0167] If the current child element is a nested group element (i.e., the child element itself is a group element), then the flattening process of this embodiment is recursively performed on the nested group element. Specifically, the same flattening processing logic is called, taking the nested group element as input, traversing each of its internal child elements, and performing the above judgment and processing for each child element. The recursive processing will continue until all levels of child elements under the nested group element are flattened into non-group elements, obtaining the structured description information, transformation matrix, and labeling parameters of any child element under the nested group element. During the recursion, the overall transformation and labeling parameters of each level of nested group element are passed and superimposed on the bottommost non-group element child element according to the above rules.

[0168] Through the above traversal and recursive processing, the group elements are flattened into a flat collection of multiple initial vector sub-labels. Each initial vector sub-label has independent structured description information, transformation matrix, and labeling parameters.

[0169] For example, such as Figure 4 As shown, the canvas data corresponding to the target object to be printed is obtained and decomposed to obtain single graphic elements including custom-drawn graphics, PNG, JPG, SVG, and DXF graphics. PNG and JPG graphics are uniformly converted to the same format. The data of SVG graphics is parsed to obtain an XMLDOM tree and flattened to obtain child elements and basic graphic elements. The data of DXF graphics is identified and parsed into basic graphic elements. Next, the initial vector graphic label, transformation matrix, and labeling parameters corresponding to each graphic element are obtained, and the target vector graphic label is generated accordingly.

[0170] In this embodiment, the group elements are flattened according to the structured description information, image processing data, and labeling parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and labeling parameters of any sub-element in the group elements. This includes: traversing each sub-element in the group elements and performing the following operations for any sub-element; if the current sub-element is not a group element, then extract the structured description information of the current sub-element from the structured description information of the group elements, extract the labeling parameters of the group elements as the labeling parameters of the current sub-element, extract the image processing data of the current sub-element from the image processing data of the group elements, and determine the transformation matrix of the current sub-element based on the image processing data; if the current sub-element is a nested group element, then recursively perform flattening processing on the nested group elements to obtain the structured description information, transformation matrix, and labeling parameters of any sub-element under the nested group elements. By disassembling the hierarchical structure of the group elements step by step, the image processing data and marking parameters originally recorded in the group elements are stably transferred to any child element. The resulting child element can be directly used for SVG tag generation and CNC machining program generation, reducing the repeated parsing of the nested structure in subsequent steps. This allows the hierarchical data to directly participate in SVG file generation after expansion, thereby reducing the processing burden and improving the accuracy of the correspondence between each graphic data and marking parameter.

[0171] Based on the aforementioned embodiments, the target image type is further defined as an internally sculpted 3D image; the initial vector label corresponding to the original graphic data is determined according to the target file generation process corresponding to the target label type and the original graphic data, including: compressing the original graphic data using a preset compression algorithm to obtain compressed data; and encoding the compressed data using a preset encoding algorithm to obtain first plain text data, wherein the initial vector label is the first plain text data.

[0172] Compression processing is used to reduce the amount of data in the original graphic data, remove redundant information from the data, and at the same time, try to preserve the geometric information required for subsequent processing.

[0173] The first plain text data is a text string obtained by compressing the original graphic data using a preset compression algorithm and then encoding the compressed data using a preset encoding algorithm.

[0174] In practical implementation, the preset compression algorithm can adopt a general lossless compression method applicable to 3D mesh or point cloud data, or it can adopt a compression algorithm customized for the characteristics of internally carved 3D images. The algorithm can merge and compress the repeated coordinates, repeated layer information, similar descriptions of adjacent slices and redundant attributes in the original graphic data to obtain compressed data with smaller volume and complete structure.

[0175] Subsequently, a preset encoding algorithm is used to convert the compressed data into characters, transforming the binary compressed data into plain text data that can be stored in an SVG file. During decoding, the compressed data can completely restore the original 3D model, ensuring that the location and depth information of the burst points required for internal carving are not lost during the program generation stage.

[0176] The preset encoding algorithm can be Base64 encoding or other encoding algorithms that can convert binary data into plain text representation. The advantage of choosing this type of encoding is that it is easy to transmit and parse directly in text vector files and can maintain the integrity of the compression result. In practical applications, other encoding methods can also be selected, and this application does not limit them.

[0177] As an optional approach, a preset compression algorithm is used to divide the original graphic data into blocks according to the depth dimension to obtain block graphic data. Then, each block graphic data is compressed to obtain compressed sub-data, which includes multiple compressed sub-data. A preset encoding algorithm is used to encode each compressed sub-data to obtain each first plain text sub-data. The first plain text data includes multiple first plain text sub-data, which are stored in the target vector graphic label.

[0178] Block processing refers to dividing the original graphic data into multiple depth intervals in the depth direction, with the data in each depth interval constituting a block of graphic data.

[0179] In the implementation, the original graphic data is first written to a memory cache, and block boundaries are established based on the depth value range, grouping data within adjacent depth intervals into the same block of graphic data. Each block of graphic data can be processed using Lempel-Ziv (LZ), DEFLATE compression, or a block-level compression method matching the file structure. During compression, the blocks remain independent of each other, ensuring that each compressed sub-data corresponds to a unique depth interval. The preset compression algorithm used for each block of graphic data can be the same, or a suitable compression algorithm can be selected based on the data characteristics of different depth blocks. After compression, each block of graphic data yields corresponding compressed sub-data, and all compressed sub-data together constitute the compressed data. Subsequently, each compressed sub-data is processed by character set adaptation encoding, Base64 encoding, or other plain text encoding to generate the first plain text sub-data that can be directly stored in the SVG file. Multiple first plain text sub-data are stored in the target vector graphic tag according to depth order, so that the original graphic data can be recovered by corresponding blocks during decoding.

[0180] As an optional approach, before compressing the original graphic data using a preset compression algorithm to obtain compressed data, the original graphic data undergoes grid optimization processing to remove non-interface data. After converting the compressed data using a preset encoding algorithm to obtain the first plain text data, a preset hash algorithm is used to generate a checksum corresponding to the original graphic data. The checksum is stored in the target vector graphic label and used to verify the original graphic data.

[0181] Among them, the unseen surfaces refer to the surfaces that are inside the 3D model or obscured by other surfaces and will not be processed during the laser marking process.

[0182] The checksum is used to verify the original graphic data to check whether errors or tampering have occurred during the compression, encoding, storage, transmission, decoding, and decompression processes.

[0183] In practical applications, the preset compression algorithm can adopt a lossless compression method oriented towards geometric data, and this application does not limit it in this regard.

[0184] In practical implementation, the laser marking CNC machining program generation device first performs mesh optimization processing on the original graphic data. Specifically, the laser marking CNC machining program generation device traverses each facet in the 3D mesh model, determines the data corresponding to the invisible faces through the camera viewpoint, normal vector direction, and occlusion relationship, and deletes the vertex indexes and attribute information corresponding to the invisible faces, retaining the visible faces and their associated data.

[0185] The original graphic data after grid optimization is compressed and encoded to obtain compressed data. This compressed data is then converted into first plain text data for direct embedding into the target vector graphic label. Simultaneously, the laser marking CNC machining program generation device performs a preset hash operation on the original graphic data to generate a checksum, which is then written into a reserved field of the target vector graphic label. The preset hash algorithm can be any hash algorithm capable of generating a fixed-length digest of the data, such as Message Digest Algorithm Version 5 (MD5), Secure Hash Algorithm 1 (SHA-1), or Secure Hash Algorithm 256 (SHA-256). The checksum can be calculated based on the original graphic data after grid optimization or on the original graphic data before compression; this embodiment does not specifically limit this. If the checksum matches the hash result of the subsequently parsed original graphic data, it indicates that the data remained consistent during transmission and storage. Conversely, if the checksum does not match, it indicates that the data may have been erroneous or tampered with during transmission or processing, in which case processing can be stopped and an error report can be issued.

[0186] For example, such as Figure 5 As shown, the canvas data corresponding to the target object to be printed is obtained and compressed using a preset compression algorithm to obtain compressed data. The data is then encoded using a preset encoding algorithm to obtain the initial vector graphic label. At the same time, the transformation matrix and marking parameters are obtained, and the target vector graphic label is generated accordingly.

[0187] In this embodiment, the target image type is an internally sculpted 3D image. Following the target file generation process corresponding to the target marking type and determining the initial vector graphic label based on the original graphic data, the process includes: compressing the original graphic data using a preset compression algorithm to obtain compressed data; and encoding the compressed data using a preset encoding algorithm to obtain first plain text data. The initial vector graphic label is the first plain text data. By performing compression and encoding processing on the original graphic data of the internally sculpted 3D image, the data representation is converted from structured graphic data to plain text label format, which reduces the storage footprint of intermediate data transmission and makes the data of the internally sculpted 3D image more suitable for unified storage in the target SVG file. The compressed data, after encoding, directly forms the initial vector graphic label, and the label content is consistent with the original graphic data, which improves the consistency of subsequent CNC machining program generation.

[0188] Based on the aforementioned embodiments, the target image type is further defined as a relief 3D image; the initial vector label corresponding to the original graphic data is determined according to the target file generation process corresponding to the target marking type and the original graphic data, including: converting the original graphic data into a depth image and converting the depth image into a grayscale image; encoding the grayscale image using a preset encoding algorithm to obtain second plain text data, and the initial vector label is the second plain text data.

[0189] A depth image is an image that expresses three-dimensional depth information in the form of a two-dimensional image, where the value of each pixel represents the height or depth of the corresponding location.

[0190] A grayscale image is an image that uses grayscale values ​​to represent pixel brightness information, and can linearly or non-linearly map depth values ​​to grayscale values.

[0191] The second plain text data is a text string obtained by converting the original graphic data into a depth image, converting the depth image into a grayscale image, and then encoding the grayscale image using a preset encoding algorithm.

[0192] In the specific implementation, after acquiring the original image data, a depth image is first constructed based on its three-dimensional coordinates, pixel depth values, or height field information. Each pixel in the depth image is mapped one-to-one with its corresponding position in the original image data, and different depths can correspond to preset light and dark levels. Subsequently, the depth image is converted into a grayscale image according to a unified grayscale mapping rule, so that the depth values ​​are normalized in the grayscale domain. The grayscale mapping rule is used to establish a definite mapping relationship from the depth value domain to the grayscale value domain, so that the depth information is preserved and normalized in the grayscale domain.

[0193] For example, first, the minimum and maximum depth values ​​of all pixels in the depth image are read to determine the depth value range, and the target grayscale range is determined based on the adopted grayscale bit depth. Then, a unified mapping function is used to proportionally map the depth value of each pixel to the target grayscale range. Optionally, the minimum depth value is mapped to the minimum grayscale value, the maximum depth value is mapped to the maximum grayscale value, and intermediate depth values ​​are converted to the corresponding intermediate grayscale levels in a linear proportion, thereby normalizing the depth values ​​in the grayscale domain. For cases where the depth values ​​themselves are discrete levels, a direct correspondence between each depth level and a preset grayscale level can be established; if higher depth accuracy is required, a grayscale image with a higher bit depth can be used to retain more details.

[0194] The preset encoding algorithm can employ Base64 encoding, ASCII encoding, or other encoding algorithms capable of converting binary data into plain text representation. The grayscale matrix is ​​converted into a plain text string in row and column order, and pixel values, row separators, and image boundary information are encapsulated in a preset format to form the second plain text data. This second plain text data is written into the tag area during the target file generation process and serves as the initial vector graphic tag for subsequent SVG file and CNC machining program generation. After the encoded grayscale data is embedded in the SVG file, the program generation stage can use the grayscale values ​​to infer the relief depth, adjusting the laser power according to the grayscale gradient to create a gradually deepening relief effect on the material surface.

[0195] For example, such as Figure 6 As shown, the canvas data corresponding to the target object to be printed is obtained and converted into a depth image. Next, it is converted into a grayscale image and encoded using a preset encoding algorithm to obtain the initial vector graphic label. At the same time, the transformation matrix and marking parameters are obtained, and the target vector graphic label is generated accordingly.

[0196] In this embodiment, the target image type is a relief 3D image. Following the target file generation process corresponding to the target marking type and determining the initial vector graphic label corresponding to the original graphic data based on the original graphic data, the process includes: converting the original graphic data into a depth image and then converting the depth image into a grayscale image; encoding the grayscale image using a preset encoding algorithm to obtain second plain text data, with the initial vector graphic label being the second plain text data. By converting the depth information of the relief 3D image through both depth image and grayscale image conversions, and then uniformly encoding it into the initial vector graphic label, the depth information can be preserved in a continuous and parsable text form, reducing the loss of 3D information during intermediate transmission, thereby making the SVG file more complete in preserving the relief processing content.

[0197] Figure 7 A flowchart illustrating a method for generating a laser marking CNC machining program according to another embodiment of this application is shown below. Figure 7 As shown, the method for generating a laser marking CNC machining program provided in this embodiment includes the following steps:

[0198] S701: Obtain the canvas data corresponding to the target object to be printed, read the target image type from the original graphic data, and retrieve the preset marking type corresponding to the target image type in the preset mapping relationship to obtain the target marking type. The target image type can be a planar image, an internally carved 3D image, or a relief 3D image.

[0199] S702: When the target image type is a planar image, parse the graphic element type identifier. If it is determined that there are combined graphic elements in the original graphic data, first perform decomposition processing on the combined graphic elements to obtain multiple single graphic elements.

[0200] S703: Extract structured description information based on the geometric data and rendering style of each individual graphic element, and convert the structured description information into corresponding initial vector graphic labels.

[0201] S704: If the planar image is an SVG or DXF image and a single graphic element is a group element, then flattening is performed based on the structured description information, image processing data and labeling parameters corresponding to the group element, and each sub-element in the group element is traversed.

[0202] S705: When the current sub-element is not a group element, extract the structured description information of the current sub-element from the structured description information of the group element, extract the labeling parameters of the group element as the labeling parameters of the current sub-element, extract the image processing data of the current sub-element from the image processing data of the group element, and determine the transformation matrix of the current sub-element based on the image processing data.

[0203] S706: When the current child element is a nested group element, recursively perform flattening processing on the nested group element to obtain the structured description information, transformation matrix and marking parameters of each child element under the nested group element.

[0204] S707: Generate initial vector sub-tags based on the structured description information of each sub-element, and concatenate the initial vector sub-tags into an initial vector tag.

[0205] S708: Write the transformation matrix and the corresponding labeling parameters of each graphic element into the initial vector graphic tag, generate the target vector graphic tag, and convert the target vector graphic tag into a target SVG file.

[0206] S709: When the target image type is an internally sculpted 3D image, perform mesh optimization processing on the original graphic data and delete the data that cannot be seen in the original graphic data.

[0207] S710: Compresses the original graphic data according to the depth dimension to obtain compressed data.

[0208] S711: Encode the compressed data using a preset encoding algorithm to obtain the first plain text data, and store the first plain text data in the initial vector graphic label.

[0209] S712: Combining the transformation matrix determined by the image processing data and the corresponding labeling parameters, add the transformation matrix and labeling parameters to the initial vector graphic label to obtain the target vector graphic label, and convert it into the target SVG file.

[0210] S713: When the target image type is a relief 3D image, convert the original graphic data into a depth image, and then convert the depth image into a grayscale image.

[0211] S714: Encode the grayscale image using a preset encoding algorithm to obtain the second plain text data, and use the second plain text data as the initial vector graphic label.

[0212] S715: Determine the transformation matrix of the original graphic data in the canvas based on the image processing data, write the transformation matrix and marking parameters into the initial vector graphic tag, form the target vector graphic tag, and convert the target vector graphic tag into the target SVG file.

[0213] S716: The laser marking CNC machining program reads the target SVG file and generates the target CNC machining program according to the program syntax and motion control rules corresponding to the laser marking equipment.

[0214] It should be noted that there is no strict execution order restriction between S702-S708 and S709-S712 and S713-S715. S702-S708 and S709-S712 and S714-S715 are executed selectively based on the target image type.

[0215] In this embodiment, the implementation of each step is similar to the technical effect of the corresponding method in the above embodiments, and will not be repeated here.

[0216] Figure 8 This is a schematic diagram of the structure of a laser marking CNC machining program generation device provided in an embodiment of this application, as shown below. Figure 8 As shown, the laser marking CNC machining program generation device provided in this embodiment is located in the terminal device and includes an acquisition module 81, a determination module 82, a first generation module 83, and a second generation module 84.

[0217] The acquisition module 81 is used to acquire the canvas data corresponding to the target object to be printed. The canvas data includes the original graphic data corresponding to the target object, the image processing data corresponding to the original graphic data, and the marking parameters. The original graphic data includes at least one graphic element, and the marking parameters are the marking parameters corresponding to each graphic element.

[0218] The determination module 82 is used to determine the target marking type based on the target image type and preset mapping relationship of the original graphic data. The preset mapping relationship stores multiple preset image types and preset marking types. The target image type can be any one of the following: planar image, internally carved 3D image, or relief 3D image.

[0219] The first generation module 83 is used to determine the initial vector graphic label corresponding to the original graphic data according to the target file generation process corresponding to the target label type and based on the original graphic data. The initial vector graphic label is used to represent the structured description information of the original graphic data. The transformation matrix corresponding to the original graphic data is determined according to the target file generation process and based on the image processing data. The transformation matrix is ​​used to represent the geometric transformation information of the original graphic data in the canvas. The target vector graphic label is generated according to the initial vector graphic label, the transformation matrix and the labeling parameters. The target vector graphic label is converted into a target scalable vector graphic SVG file.

[0220] The second generation module 84 is used to generate the corresponding target CNC machining program based on the target SVG file.

[0221] Optionally, module 81 is used to uniformly acquire canvas data, so that the original graphic data, image processing data, and the labeling parameters corresponding to each graphic element are associated and saved in the same data carrier.

[0222] Optionally, module 82 is specifically used to identify the target marking type based on the target image type and the preset mapping relationship, so that planar images, internally carved 3D images and relief 3D images can enter the corresponding file generation process.

[0223] Optionally, the first generation module 83, when determining the initial vector graphic label corresponding to the original graphic data based on the target image type being a planar image and the original graphic data including: graphic element type identifier, graphic geometric data, and rendering style; and according to the target file generation process corresponding to the target label type and based on the original graphic data, specifically performs the following: if it is determined from the graphic element type identifier that the original graphic data contains combined graphic elements, then the combined graphic elements are decombined to obtain single graphic elements; the structured description information of each single graphic element is determined based on the graphic geometric data and rendering style, and the corresponding initial vector graphic label is determined based on the structured description information of each single graphic element; and the transformation matrix corresponding to the original graphic data is determined according to the target file generation process and based on the image processing data, including: determining the transformation matrix corresponding to the original graphic data based on the image processing data of each single graphic element.

[0224] Optionally, the first generation module 83, when determining the corresponding initial vector graphic label based on the structured description information of each individual graphic element, specifically performs the following steps when: flattening the group elements according to the structured description information, image processing data, and labeling parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and labeling parameters of any one sub-element in the group elements; determining the initial vector graphic sub-label of any one sub-element according to the structured description information of any one sub-element; and splicing the initial vector graphic sub-labels to obtain the initial vector graphic label.

[0225] Optionally, the first generation module 83, when determining the transformation matrix corresponding to the original graphic data based on the image processing data of each individual graphic element, is specifically used for: determining the image processing data of any one sub-element based on the image processing data of the group elements; determining the initial transformation matrix corresponding to any one sub-element based on the image processing data of any one sub-element; multiplying the initial transformation matrix of any one sub-element with the transformation matrix of the corresponding group element to obtain the final transformation matrix of any one sub-element; and concatenating the final transformation matrix of any one sub-element with the transformation matrix corresponding to the basic graphic element to obtain the transformation matrix corresponding to the original graphic data, wherein the basic graphic element is a single graphic element other than the group elements.

[0226] Optionally, the first generation module 83, when flattening the group elements based on the structured description information, image processing data, and calibration parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and calibration parameters of any sub-element in the group elements, specifically performs the following operations: traversing each sub-element in the group elements, and performing the following operations for any sub-element: if the current sub-element is not a group element, then extracting the structured description information of the current sub-element from the structured description information of the group elements, extracting the calibration parameters of the group elements as the calibration parameters of the current sub-element, extracting the image processing data of the current sub-element from the image processing data of the group elements, and determining the transformation matrix of the current sub-element based on the image processing data; if the current sub-element is a nested group element, then recursively performing flattening processing on the nested group elements to obtain the structured description information, transformation matrix, and calibration parameters of any sub-element under the nested group elements.

[0227] Optionally, the first generation module 83, when based on the target image type being an internally sculpted 3D image; following the target file generation process corresponding to the target marking type and determining the initial vector graphic label corresponding to the original graphic data based on the original graphic data, specifically performs the following: compressing the original graphic data using a preset compression algorithm to obtain compressed data; encoding the compressed data using a preset encoding algorithm to obtain first plain text data, wherein the initial vector graphic label is the first plain text data.

[0228] Optionally, the first generation module 83, when the target image type is a relief 3D image; and when the target file generation process corresponding to the target marking type is followed and the initial vector label corresponding to the original graphic data is determined based on the original graphic data, specifically performs the following: converting the original graphic data into a depth image, and converting the depth image into a grayscale image; encoding the grayscale image using a preset encoding algorithm to obtain the second plain text data, and the initial vector label is the second plain text data.

[0229] Optionally, the first generation module 83, when generating the target vector label corresponding to the original graphic data based on the initial vector label, transformation matrix, and marking parameters, is specifically used to: add the transformation matrix and marking parameters to the initial vector label to obtain the target vector label.

[0230] Optionally, the second generation module 84 is specifically used to generate a target CNC machining program based on the target SVG file, forming a standardized link from canvas editing to program output.

[0231] The technical effect of the laser marking CNC machining program generation device provided in this embodiment is similar to that of the corresponding method in the above embodiments, and will not be repeated here.

[0232] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, as shown below. Figure 9 As shown, the laser marking CNC machining program generation device provided in this embodiment includes: a processor 91 and a memory 92 that is communicatively connected to the processor.

[0233] The memory 92 stores computer-executed instructions; the processor 91 executes the computer-executed instructions stored in the memory 92 to implement the laser marking CNC machining program generation method provided in any of the above embodiments. Related explanations can be understood by referring to the relevant descriptions and effects corresponding to the steps in the accompanying drawings, and will not be elaborated further here.

[0234] The program may include program code, which includes computer-executable instructions. Memory 92 may include high-speed RAM or non-volatile memory.

[0235] In this embodiment, the memory 92 and the processor 91 are connected via a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0236] This application also provides a computer-readable storage medium storing computer-executable instructions. When executed by a processor, these instructions are used to implement the laser marking CNC machining program generation method provided in any of the above embodiments. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device.

[0237] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the method for generating a laser marking CNC machining program provided in any of the above embodiments.

[0238] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0239] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.

[0240] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.

[0241] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0242] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, and magnetic disks.

[0243] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.

[0244] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0245] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.< / g>

Claims

1. A method for generating a CNC laser marking machining program, characterized in that, include: Obtain canvas data corresponding to the target object to be printed. The canvas data includes the original graphic data corresponding to the target object, the image processing data corresponding to the original graphic data, and the marking parameters. The original graphic data includes at least one graphic element, and the marking parameters are the marking parameters corresponding to each graphic element. The target marking type is determined based on the target image type and preset mapping relationship of the original graphic data. The preset mapping relationship stores multiple preset image types and preset marking types. The target image type can be any one of the following: planar image, internally carved 3D image, or relief 3D image. The target file generation process corresponding to the target marking type is followed, and the initial vector graphic label corresponding to the original graphic data is determined based on the original graphic data. The initial vector graphic label is used to represent the structured description information of the original graphic data. The transformation matrix corresponding to the original graphic data is determined according to the target file generation process and based on the image processing data. The transformation matrix is ​​used to represent the geometric transformation information of the original graphic data in the canvas. Generate target vector labels corresponding to the original graphic data based on the initial vector label, transformation matrix, and labeling parameters; convert the target vector label into a target scalable vector SVG file; Generate the corresponding target CNC machining program based on the target SVG file.

2. The method according to claim 1, characterized in that, The target image type is a planar image, and the original graphic data includes: graphic element type identifier, graphic geometric data, and rendering style; The step of generating a target file according to the target marking type and determining the initial vector graphic label corresponding to the original graphic data based on the original graphic data includes: If it is determined from the graphic element type identifier that there are combined graphic elements in the original graphic data, then the combined graphic elements are decombined to obtain a single graphic element. Based on the graphic geometry data and rendering style, the structured description information of each individual graphic element is determined, and based on the structured description information of each individual graphic element, the corresponding initial vector graphic label is determined; The step of determining the transformation matrix corresponding to the original graphic data according to the target file generation process and the image processing data includes: The transformation matrix corresponding to the original graphic data is determined based on the image processing data of each individual graphic element.

3. The method according to claim 2, characterized in that, The planar image is an SVG image or a DXF image; the SVG image or DXF image includes group elements; When a single graphic element is one of the group elements, determining the corresponding initial vector graphic label based on the structured description information of each single graphic element includes: The group elements are flattened based on the structured description information, image processing data, and calibration parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and calibration parameters of any one of the sub-elements in the group elements. The initial vector sub-label of any given sub-element is determined based on the structured description information of any given sub-element; The initial vector sub-labels are spliced ​​together to obtain the initial vector sub-labels.

4. The method according to claim 3, characterized in that, Determining the transformation matrix corresponding to the original graphic data based on the image processing data of each of the individual graphic elements includes: The image processing data of any one of the sub-elements is determined based on the image processing data of the group elements; Determine the initial transformation matrix corresponding to any one of the sub-elements based on the image processing data of any one of the sub-elements; Multiply the initial transformation matrix of any one of the sub-elements by the transformation matrix of the corresponding group element to obtain the final transformation matrix of any one of the sub-elements. The final transformation matrix of any one of the sub-elements and the transformation matrix corresponding to the basic graphic element are concatenated to obtain the transformation matrix corresponding to the original graphic data. The basic graphic element is a single graphic element other than the group element.

5. The method according to claim 3, characterized in that, The step of flattening the group elements based on the structured description information, image processing data, and calibration parameters corresponding to the group elements to obtain the structured description information, transformation matrix, and calibration parameters of any sub-element in the group elements includes: Iterate through each child element in the group and perform the following operation on any child element; If the current sub-element encountered is not a group element, then the structured description information of the current sub-element is extracted from the structured description information of the group element, the labeling parameters of the group element are extracted as the labeling parameters of the current sub-element, the image processing data of the current sub-element is extracted from the image processing data of the group element, and the transformation matrix of the current sub-element is determined based on the image processing data. If the current child element encountered during traversal is a nested group element, then the flattening process is recursively performed on the nested group element to obtain the structured description information, transformation matrix, and marking parameters of any child element under the nested group element.

6. The method according to claim 1, characterized in that, The target image type is an internally sculpted 3D image; The step of generating a target file according to the target marking type and determining the initial vector graphic label corresponding to the original graphic data based on the original graphic data includes: The original graphic data is compressed using a preset compression algorithm to obtain compressed data; The compressed data is encoded using a preset encoding algorithm to obtain first plain text data, and the initial vector graphic label is the first plain text data.

7. The method according to claim 1, characterized in that, The target image type is a relief 3D image; The step of generating a target file according to the target marking type and determining the initial vector graphic label corresponding to the original graphic data based on the original graphic data includes: The original graphic data is converted into a depth image, and the depth image is then converted into a grayscale image. The grayscale image is encoded using a preset encoding algorithm to obtain second plain text data, and the initial vector graphic label is the second plain text data.

8. The method according to claim 1, characterized in that, The step of generating the target vector map label corresponding to the original graphic data based on the initial vector map label, transformation matrix, and labeling parameters includes: The transformation matrix and the marking parameters are added to the initial vector graphic label to obtain the target vector graphic label.

9. A device for generating CNC laser marking programs, characterized in that, include: The acquisition module is used to acquire canvas data corresponding to the target object to be printed. The canvas data includes the original graphic data corresponding to the target object, the image processing data corresponding to the original graphic data, and the marking parameters. The original graphic data includes at least one graphic element, and the marking parameters are the marking parameters corresponding to each graphic element. The determination module is used to determine the target marking type based on the target image type and the preset mapping relationship of the original graphic data. The preset mapping relationship stores multiple preset image types and preset marking types. The target image type is any one of the following: planar image, internally carved 3D image, relief 3D image. The first generation module is used to determine the initial vector graphic label corresponding to the original graphic data according to the target file generation process corresponding to the target marking type and the original graphic data, wherein the initial vector graphic label is used to represent the structured description information of the original graphic data; and to determine the transformation matrix corresponding to the original graphic data according to the target file generation process and the image processing data, wherein the transformation matrix is ​​used to represent the geometric transformation information of the original graphic data in the canvas. Generate target vector labels corresponding to the original graphic data based on the initial vector label, transformation matrix, and labeling parameters; convert the target vector label into a target scalable vector SVG file; The second generation module is used to generate the corresponding target CNC machining program based on the target SVG file.

10. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-8.