Curve smoothing method and system, electronic equipment and medium
By obtaining the inflection point of the printed fabric profile, using polygon approximation and B-spline algorithm processing, the zigzag problem of printed fabric profile is solved, efficient and smooth cutting is achieved, and the cutting quality and speed is improved.
Patent Information
- Application Number
- CN202311550768.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-20
- Publication Date
- 2025-05-20
AI Technical Summary
In the prior art, the printed fabric profile obtained by taking photos with a camera is jagged, resulting in stuttering of cutting, slow speed and poor quality.
By obtaining the contour inflection points of the to-process curve, filtering segmented inflection points based on the polygon approximation algorithm and angle and distance, using the B-spline algorithm to perform smooth processing to obtain the smooth curve.
Reduces jagged and irregular edges on the curve, improves cutting quality and efficiency, and can efficiently and smoothly cut out the required patterns.
Smart Images

Figure CN120020860A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of line processing, and relates to a curve smoothing method, system, electronic device and medium. Background Art
[0002] Currently, in the field of clothing, for fabrics such as printed fabrics for which it is impossible to obtain a layout, in order to obtain a layout, a single-layer cutting bed basically first takes a photo with a camera, and after identifying the contour of the printed fabric, generates a cutting layout based on the contour. However, in this method, the contours directly extracted using the camera are all non-smooth. Since the contour has a very large number of serrations, directly performing cutting will easily cause the cutting bed to frequently get stuck, resulting in a low cutting speed and poor cutting quality. Summary of the Invention
[0003] This application provides a curve smoothing method, system, electronic device and medium, which are used to solve the technical problem of how to eliminate the serrations of a curve contour.
[0004] In a first aspect, this application provides a curve smoothing method, and the method includes: obtaining the contour inflection points of the curve to be processed; screening the contour inflection points based on angle and distance to obtain segmented inflection points; processing the curve to be processed based on the segmented inflection points to obtain a smooth curve.
[0005] In an implementation manner of the first aspect, obtaining the contour inflection points of the curve to be processed includes: obtaining the contour inflection points of the curve to be processed based on the polygon approximation algorithm.
[0006] In an implementation manner of the first aspect, screening the contour inflection points based on angle and distance to obtain segmented inflection points includes: selecting the contour inflection points with an angle not greater than 150° or a distance not less than 10 mm as the segmented inflection points.
[0007] In an implementation manner of the first aspect, processing the curve to be processed based on the segmented inflection points to obtain a smooth curve includes: performing segmented processing on the curve to be processed based on the segmented inflection points to obtain segmented curves; performing smoothing processing on the segmented curves to obtain a smooth curve.
[0008] In an implementation manner of the first aspect, performing smoothing processing on the segmented curves to obtain a smooth curve includes: performing smoothing processing on the segmented curves based on the B-spline algorithm to obtain smooth segmented curves; connecting the smooth segmented curves to obtain the smooth curve.
[0009] In an implementation manner of the first aspect, performing smoothing processing on the segmented curves based on the B-spline algorithm includes: performing cubic B-spline curve approximation fitting on the segmented curves.
[0010] In a second aspect, the present application provides a curve smoothing system, which includes: a first acquisition module for acquiring the contour inflection points of a curve to be processed; a second acquisition module for screening the contour inflection points based on angles and distances to obtain segmented inflection points; and a third acquisition module for processing the curve to be processed based on the segmented inflection points to obtain a smoothed curve.
[0011] In an implementation manner of the second aspect, the third acquisition module includes a segmentation processing sub-module and a smoothing processing sub-module; the segmentation processing sub-module is used for segmenting the curve to be processed based on the segmented inflection points to obtain segmented curves; and the smoothing processing sub-module is used for smoothing the segmented curves to obtain a smoothed curve.
[0012] In a third aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the curve smoothing method described in the first aspect of the present application is implemented.
[0013] In a fourth aspect, the present application provides an electronic device, including: a memory configured to store a computer program; and a processor communicatively connected to the memory, where the processor is configured to call the computer program to execute the curve smoothing method described in the first aspect of the present application.
[0014] The curve smoothing method, system, electronic device, and medium described in the present application have the following beneficial effects: The present application can reduce the serrated and irregular edges on the curve and obtain a smoothed curve, so that the required pattern can be efficiently and smoothly cut along the curve, improving the cutting quality. At the same time, the cutting task can be completed faster, greatly improving the production efficiency. Description of the Drawings
[0015] Figure 1 It shows a schematic flowchart of a curve smoothing method according to an embodiment of the present application.
[0016] Figure 2 It shows a schematic diagram of a polygon approximation algorithm function according to an embodiment of the present application.
[0017] Figure 3 It shows a schematic flowchart of a curve smoothing method according to an embodiment of the present application.
[0018] Figure 4 It shows a schematic flowchart of a curve smoothing method according to an embodiment of the present application.
[0019] Figure 5 It shows the serrated and irregular edges of the curve to be processed according to an embodiment of the present application.
[0020] Figure 6 It shows a schematic diagram of the implementation result of a curve smoothing method according to an embodiment of the present application.
[0021] Figure 7 It shows a schematic diagram of the architecture of a curve smoothing system according to an embodiment of the present application.
[0022] Figure 8 It shows a schematic diagram of the architecture of a curve smoothing system according to an embodiment of the present application.
[0023] Figure 9 It shows a schematic diagram of the architecture of an electronic device according to an embodiment of the present application. Detailed implementation manners
[0024] The following uses specific specific examples to illustrate the implementation manners of the present application. Those skilled in the art can easily understand other advantages and effects of the present application from the content disclosed in this specification. The present application can also be implemented or applied through other different specific implementation manners. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, without conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0025] It should be noted that the diagrams provided in the following embodiments only illustrate the basic concept of the present application in a schematic manner. Therefore, only the components related to the present application are shown in the diagrams, rather than being drawn according to the number, shape, and size of the components in actual implementation. The type, quantity, and proportion of each component in actual implementation can be arbitrarily changed, and the component layout type may also be more complex.
[0026] In addition, it should also be understood that unless otherwise specified or indicated, the terms "first", "second", etc. described in the specification are only used to distinguish each component, element, step, etc. in the specification, rather than to represent the logical relationship or sequence relationship between each component, element, step, etc., nor can it be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features.
[0027] In the embodiments of the present application, a curve smoothing method, system, electronic device, and medium are provided, which can reduce the serrations and irregular edges on the curve and obtain a smooth curve, so that the required pattern can be efficiently and smoothly cut along the curve, improving the cutting quality. At the same time, the cutting task can be completed faster, greatly improving the production efficiency.
[0028] Please refer to Figure 1 As shown, the curve smoothing method provided by an embodiment of the present application includes the following steps S1 to S3:
[0029] S1: Obtain the contour inflection points of the curve to be processed.
[0030] Specifically, obtain the contour inflection points of the curve to be processed based on the polygon approximation algorithm. As Figure 2 shows the polygon approximation algorithm function in OpenCV in an embodiment.
[0031] In this embodiment, the approxPolyDP() function uses the Douglas-Peucker algorithm.
[0032] Specifically, the steps of the Douglas-Peucker algorithm are as follows:
[0033] 1) First, find two points A and B with the farthest distance from the contour, and connect them with a straight line AB, which is the chord of the curve;
[0034] 2) Obtain the point C on the curve with the largest distance from the straight line segment, and calculate its distance d from AB;
[0035] 3) Compare the size of the distance d with a pre-given threshold threshold.
[0036] When the distance d is less than the threshold threshold, then the straight line segment is used as the approximation of the curve, and this section of the curve is processed;
[0037] When the distance d is not less than the threshold threshold, then use C to divide the curve into two segments AC and BC, and perform the processing of 1) - 3) on the two segments of the curve respectively.
[0038] 5) When all the curves are processed, connect the broken lines formed by the segmentation points in sequence, which can be used as the approximation of the curve.
[0039] S2: Screen the contour inflection points based on the angle and distance to obtain the segmented inflection points.
[0040] Specifically, select the contour inflection points with an angle not greater than 150° or a distance not less than 10 mm as the segmented inflection points. For example, there is a contour inflection point f. When the angle between f and the adjacent inflection point is not greater than 150° or the distance from the adjacent inflection point is not less than 10 mm, then the contour inflection point f is used as the segmented inflection point, otherwise the inflection point f is deleted.
[0041] It should be noted that steps S1 and S2 can be executed again according to needs to screen out the real segmented inflection points.
[0042] S3: Process the curve to be processed based on the segmented inflection points to obtain a smooth curve.
[0043] Specifically, as Figure 3As shown, step S3 includes S31 and S32.
[0044] S31: Segment the curve to be processed based on the piecewise inflection points to obtain segmented curves.
[0045] S32: Smooth the segmented curves to obtain smooth curves.
[0046] Specifically, as Figure 4 shown, step S32 includes S321 and S322.
[0047] S321: Smooth the segmented curves based on the B-spline algorithm to obtain smooth segmented curves.
[0048] Specifically, the B-spline algorithm includes B-spline curve approximation fitting.
[0049] Specifically, the segmented curves obtained in step S31 are approximately fitted using the cubic B-spline algorithm to obtain smooth segmented curves.
[0050] Specifically, the general equation of the B-spline curve is:
[0051]
[0052] where P i is the characteristic point in each segmented curve, and F i,k (t) is the K-order B-spline basis function.
[0053] Specifically, the basis function in the cubic B-spline curve equation is:
[0054]
[0055] where represents the factorial, and the basis function of the third order can be reduced to:
[0056]
[0057]
[0058]
[0059]
[0060] Substitute the above basis function into the general equation of the B-spline curve, and the cubic B-spline curve equation is obtained as follows:
[0061] P(t) = P 0 *F 0,3 (t) + P 1 *F 1,3 (t) + P 2*F 2,3 (t) + P 3 *F 3,3 (t)
[0062] Specifically, the above cubic B-spline curve equation is used to approximately fit the piecewise curve with a cubic B-spline curve. Given the t value, F i,k (t) is obtained, and P i , P i+1 , P i+2 , P i+3 are cyclically substituted to obtain a spline curve approximately fitted by 4 points.
[0063] S322: Connect the smooth piecewise curves to obtain the smooth curve.
[0064] Specifically, the piecewise curve processed in step S321 is connected to obtain a processed smooth curve.
[0065] Figure 5 shows the serrated and irregular edges of the curve to be processed. Figure 6 shows the smooth curve obtained after being processed by the curve smoothing method provided in this application.
[0066] As described above, the curve smoothing method provided in this application can reduce the serrated and irregular edges on the curve and obtain a smooth curve, so that the required pattern can be efficiently and smoothly cut along the curve, improving the cutting quality and efficiency.
[0067] The protection scope of the curve smoothing method described in the embodiments of this application is not limited to the execution order of the steps listed in this embodiment. Any solution achieved by adding or subtracting steps of the prior art and replacing steps according to the principle of this application is included in the protection scope of this application.
[0068] The embodiments of this application also provide a curve smoothing system. The curve smoothing system can implement the curve smoothing method described in this application. However, the implementation device of the curve smoothing method described in this application includes, but is not limited to, the structure of the curve smoothing system listed in this embodiment. Any structural deformation and replacement of the prior art made according to the principle of this application are included in the protection scope of this application.
[0069] As Figure 7 shown, the curve smoothing system provided in this embodiment includes a first acquisition module 10, a second acquisition module 20, and a third acquisition module 30.
[0070] The first acquisition module 10 is used to acquire the contour inflection points of the curve to be processed; the second acquisition module 20 is used to screen the contour inflection points based on the angle and distance to obtain segmented inflection points; the third acquisition module 30 is used to process the curve to be processed based on the segmented inflection points to obtain a smooth curve.
[0071] Among them, as Figure 8 shown, the third acquisition module 30 includes a segmentation processing sub-module 301 and a smoothing processing sub-module 302.
[0072] The segmentation processing sub-module 301 is configured to perform segmentation processing on the curve to be processed based on the segmented inflection points to obtain a segmented curve; the smoothing processing sub-module 302 is configured to perform smoothing processing on the segmented curve to obtain a smoothed curve.
[0073] Specifically, after the first acquisition module 10 obtains the contour inflection points of the curve to be processed based on the polygon approximation algorithm, the second acquisition module 20 selects the contour inflection points with an angle not less than 150° or the distance between two sides not greater than 10 mm as the segmented inflection points. The segmentation processing sub-module 301 in the third acquisition module 30 performs segmentation processing on the curve to be processed based on the segmented inflection points to obtain a segmented curve. The smoothing processing sub-module 302 uses the B-spline algorithm to perform smoothing processing on the segmented curve to obtain a smoothed segmented curve, and connects the smoothed segmented curves to obtain the smoothed curve.
[0074] Specifically, the smoothing processing sub-module 302 performs a cubic B-spline curve approximation fitting on the segmented curve.
[0075] The curve smoothing system provided by the present application can reduce the serrated and irregular edges on the curve and obtain a smoothed curve, so that the required pattern can be efficiently and smoothly cut along the curve, improving the cutting quality and efficiency.
[0076] The present application also provides an electronic device. As Figure 9 shown, this embodiment provides an electronic device 90, and the electronic device 90 includes: a memory 901 configured to store a computer program; and a processor 902 communicatively connected to the memory 901 and configured to call the computer program to execute the curve smoothing method.
[0077] The memory 901 includes various media such as ROM (Read Only Memory image), RAM (Random Access Memory), magnetic disk, USB flash drive, memory card, or optical disc that can store program codes.
[0078] The processor 902 is connected to the memory 901 and is configured to execute the computer program stored in the memory 901, so that the electronic device executes the above-mentioned curve smoothing method.
[0079] Preferably, the processor 902 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0080] In several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, or method can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of modules / units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces, and the indirect coupling or communication connection of devices, modules, or units may be in an electrical, mechanical, or other form.
[0081] The modules / units described as separate components may or may not be physically separated, and the components shown as modules / units may or may not be physical modules, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules / units can be selected according to actual needs to achieve the purpose of the embodiments of the present application. For example, in each embodiment of the present application, the various functional modules / units can be integrated in a processing module, or each module / unit can exist physically alone, or two or more modules / units can be integrated in one module / unit.
[0082] Those of ordinary skill in the art should also be further aware that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0083] The embodiments of the present application also provide a computer-readable storage medium. Those of ordinary skill in the art can understand that all or part of the steps in the methods of the above embodiments can be completed by instructing a processor through a program. The program can be stored in a computer-readable storage medium. The storage medium is a non-transitory medium, such as random access memory, read-only memory, flash memory, hard disk, solid state drive, magnetic tape, floppy disk, optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center integrating one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid state disk (SSD)), etc.
[0084] The embodiments of the present application can also provide a computer program product, which includes one or more computer instructions. When the computer instructions are loaded and executed on a computing device, all or part of the processes or functions described in the embodiments of the present application are generated. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, a computer, or a data center to another website, a computer, or a data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.).
[0085] When the computer program product is executed by a computer, the computer executes the methods described in the foregoing method embodiments. The computer program product can be a software installation package. In the case where the foregoing methods are required, the computer program product can be downloaded and executed on the computer.
[0086] The descriptions of the processes or structures corresponding to the above respective drawings each have their own emphases. For parts not detailed in a certain process or structure, reference can be made to the relevant descriptions of other processes or structures.
[0087] The above embodiments are only illustrative of the principles and effects of the present application and are not used to limit the present application. Any person familiar with this technology can make modifications or changes to the above embodiments without departing from the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by those with ordinary knowledge in the technical field without departing from the spirit and technical ideas disclosed by the present application should still be covered by the claims of the present application.
Claims
1. A curve smoothing method, characterized in that: include: Obtain the contour inflection point of the curve to be processed; Filtering the contour inflection points based on angle and distance to obtain segmented inflection points; The curve to be processed is processed based on the piecewise inflection points to obtain a smooth curve.
2. The curve smoothing method according to claim 1, characterized in that: Obtaining the contour inflection point of the curve to be processed includes: The contour inflection point of the to-be-processed curve is obtained based on a polygonal approximation algorithm.
3. The curve smoothing method according to claim 1, characterized in that: Filtering the contour inflection points based on angle and distance to obtain piecewise inflection points includes: The contour inflection point with an angle not greater than 150° or a distance not less than 10 mm is selected as the segmented inflection point.
4. The curve smoothing method according to claim 1, characterized in that: Processing the to-be-processed curve based on the piecewise inflection points to obtain a smooth curve comprises: Performing segmented processing on the to-be-processed curve based on the segmented inflection points to obtain a segmented curve; The segmented curve is smoothed to obtain a smooth curve.
5. The curve smoothing method according to claim 4, characterized in that: Smoothing the segmented curve to obtain a smooth curve includes: Smoothing the segmented curve based on a B-spline algorithm to obtain a smooth segmented curve; The smooth piecewise curves are connected to obtain the smooth curve.
6. The curve smoothing method according to claim 5, characterized in that: The smoothing process of the segmented curve based on the B-spline algorithm includes: performing cubic B-spline curve approximate fitting on the segmented curve.
7. A curve smoothing system, characterized in that: include: A first acquisition module is used to acquire the contour inflection point of the curve to be processed; A second acquisition module, used for screening the contour inflection points based on angle and distance to obtain segmented inflection points; The third acquisition module is used to process the to-be-processed curve based on the piecewise inflection points to obtain a smooth curve.
8. The curve smoothing system according to claim 7, characterized in that: The third acquisition module includes a segmentation processing submodule and a smoothing processing submodule; The segment processing submodule is used for performing segment processing on the to-be-processed curve based on the segmented inflection points to obtain a segmented curve; The smoothing submodule is used to perform smoothing on the segmented curve to obtain a smooth curve.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the curve smoothing method according to any one of claims 1 to 6 is implemented.
10. An electronic device, characterized in that: The electronic device comprises: A memory storing a computer program; A processor is communicatively connected to the memory, and executes the curve smoothing method according to any one of claims 1 to 6 when calling the computer program.