CN117745807B - Method and device for confirming marking position - Google Patents

Method and device for confirming marking position Download PDF

Info

Publication number
CN117745807B
CN117745807B CN202410181820.9A CN202410181820A CN117745807B CN 117745807 B CN117745807 B CN 117745807B CN 202410181820 A CN202410181820 A CN 202410181820A CN 117745807 B CN117745807 B CN 117745807B
Authority
CN
China
Prior art keywords
square
target graph
marking
value
dimensional array
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410181820.9A
Other languages
Chinese (zh)
Other versions
CN117745807A (en
Inventor
孟祥群
张永银
郝军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Fangling Computer Software Co ltd
Original Assignee
Shanghai Fangling Computer Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Fangling Computer Software Co ltd filed Critical Shanghai Fangling Computer Software Co ltd
Priority to CN202410181820.9A priority Critical patent/CN117745807B/en
Publication of CN117745807A publication Critical patent/CN117745807A/en
Application granted granted Critical
Publication of CN117745807B publication Critical patent/CN117745807B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Generation (AREA)

Abstract

The invention provides a method and a device for confirming marking positions, which are applied to the technical field of laser cutting and comprise the following steps: determining the auxiliary rectangle size of the outer contour line of the enveloping target graph; dividing grid units of the auxiliary rectangle according to the set precision and marking points on the grid; judging whether points on the grids in the auxiliary rectangle are inside the target graph or not, and marking all the points in the target graph; calculating the maximum inscribed square in the target graph; determining the center point O ((startX + endX)/2, (startY + endY)/2) of the maximum inscribed square according to the determined coordinate position; adding marking information in the largest inscribed square in the target graph; the marking position of laser cutting and the maximum size of the marking area can be determined according to the actual condition of the target graph, so that the marking characters or patterns are not overlapped or blocked with the inner hole when the marking characters or patterns are added into the closed graph with the inner hole.

Description

Method and device for confirming marking position
Technical Field
The invention belongs to the technical field of marking, and particularly relates to a method and a device for confirming marking positions.
Background
Marking is divided into three types of pneumatic marking, laser marking and electric corrosion marking, wherein the pneumatic marking is controlled by a computer, and a printing needle performs high-frequency impact movement under the action of compressed air, so that a mark with a certain depth is printed on a workpiece, and the marking is characterized by a larger depth; the laser marking is to mark the surfaces of various substances permanently by laser beams, and the laser marking is to expose deep substances through the evaporation of surface substances so as to etch exquisite patterns, trademarks and characters; the electric corrosion marking mainly prints fixed trademarks, and the printing content is inconvenient to change.
In the laser cutting industry, a part is usually used as a minimum unit for cutting, and one part can be a closed outer contour or a closed outer contour comprising a plurality of closed inner contours. In the cutting process, some marked text, trademark and pattern information is usually added, and the information can be manually moved to an ideal position or calculated by a computer according to the graphic information of the part to find a reasonable position.
The following problems are typically encountered in the laser cutting industry to automatically calculate the position of text within a part:
the sizes of the marking area and the marking characters cannot be adjusted according to the actual conditions of the sizes and the shapes of the parts, and the unreasonable marking positions and the too small marking characters, trademarks and patterns play a small role in preventing the false of the marks.
In addition, when calculating the reasonable position of the marking word, the condition that the part exists in the inner contour can be ignored, and the traditional mark adding method cannot always consider the position of the inner hole in the closed graph, so that the position of the marking mark adding can be overlapped with the inner hole or be too close to the edge of the inner hole, and the definition of the marking word is affected.
Disclosure of Invention
In view of the above problems in the prior art, the present invention aims to provide a method for confirming a marking position, which can determine the maximum size and the marking position of a marking area of a part according to the actual condition of a target graph, and adjust the sizes of marking characters, trademarks and patterns according to the size of the marking area, so as to improve the anti-counterfeiting effect of a mark.
A method of confirming a marking location, comprising the steps of:
Determining the auxiliary rectangle size of the outer contour line of the enveloping target graph; the target graph is a graph surrounded by a closed outer contour line;
Dividing grid units of the auxiliary rectangle according to the set precision and marking points on the grid;
Judging whether the points on the grids in the auxiliary rectangle are inside the target graph or not, and marking all the points inside the target graph;
Calculating the maximum inscribed square inside the target graph according to all the points inside the target graph;
determining the central point O ((startX + endX)/2, (startY + endY)/2) of the maximum inscribed square according to the determined coordinate position of the maximum inscribed square;
Adding marking information into the maximum inscribed square in the target graph, wherein the center of the marking information is positioned at the center point O of the maximum inscribed square in the target graph, and the size of the marking information is matched with the side length of the corresponding maximum inscribed square;
The method for calculating the maximum inscribed square inside the target graph comprises the following steps: defining a variable largest, startX, endX, startY, endY, wherein larget is the side length of the maximum inscribed square, and E (startX, startY), F (startX, endY), G (endX, startY) and H (endX, endY) are the coordinate positions of four vertexes of the maximum inscribed square;
Defining two-dimensional array dp [ i ] [ j ] for recording side length of inscribed square;
Traversing row by row or column by column in turn, determining dp [ i ] [ j ] of each point in the target graph, comparing the dp [ i ] [ j ] with the larget, if the value of dp [ i ] [ j ] is larger than the value of the larget, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinates of the E, F, G, H vertexes; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes;
After the traversal is completed, the variables largest, startX, endX, startY, endY are determined, thereby determining the side length and coordinate position of the largest inscribed square.
Preferably, the target pattern includes a closed outer contour and a plurality of closed inner contours, the inner contours being located in a pattern surrounded by the outer contour.
Preferably, the specific steps of determining the auxiliary rectangle size of the outer contour line of the enveloping target graph are as follows: and traversing the coordinates of each point in the outer contour line of the target graph, and determining the minimum X coordinate Xmin, the maximum X coordinate Xmax, the minimum Y coordinate Ymin and the maximum Y coordinate Ymax of the coordinates of each point in the outer contour line of the target graph, thereby determining the vertex coordinates of the auxiliary rectangle as A (Xmin, ymin), B (Xmin, ymax), C (Xmax, ymin) and D (Xmax, ymax).
Preferably, the method for dividing the auxiliary rectangle into grid cells and marking the points on the grid according to the setting precision comprises the following steps: after setting the required precision, the points on the grid are marked by a two-dimensional array or matrix.
Preferably, marking points on the grid by a two-dimensional array comprises the steps of: and recording a two-dimensional array A [ r ] [ c ] for marking points on a grid, wherein the parameters of the grid unit comprise grid length L and grid width W, the number r of the grid unit is (Ymax-Ymin)/W, the number c of the grid unit is (Xmax-Xmin)/L, and the numerical values of the grid length L and the grid width W are equal.
Preferably, when the target pattern is a pattern surrounded by a closed outer contour line, traversing and judging whether the points represented by the two-dimensional array A [ r ] [ c ] are inside the outer contour line by using an ignition method, and marking the points positioned inside the outer contour line by using the two-dimensional array B [ r ] [ c ].
Preferably, when the target graph comprises a closed outer contour line and a plurality of closed inner contour lines, and the inner contour lines are positioned in the graph surrounded by the outer contour lines, traversing and judging whether the points represented by the two-dimensional array A [ r ] [ c ] are positioned inside the outer contour lines and outside the inner contour lines by using a ray-induced method, and marking the points positioned inside the outer contour lines and outside the inner contour lines by using the two-dimensional array B [ r ] [ c ].
Preferably, the calculating the maximum inscribed square inside the target graph according to all the points inside the target graph comprises the following specific steps:
Setting the point with the smallest X value of the ith row in the target graph as the following traversal from bottom to top and from left to right The point in the target graph where the X value of the ith row is the largest is/>Note startX =/>Recording a two-dimensional array dp [ i ] [ j ] =1, taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from an upper right square frame, and judging whether the square is positioned in the target graph or not;
If the square is positioned in the target graph, judging whether the value of the two-dimensional array dp [ i ] [ j ] is larger than the value of the larget, if so, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinate of the E, F, G, H vertex; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes; meanwhile, recording the two-dimensional array dp [ i ] [ j ] =dp [ i ] +1, continuing to take the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from the upper right square, and judging whether the square is positioned in the target graph;
If the square is not inside the target pattern, then startX = +1, Recording a two-dimensional array dp [ i ] [ j ] =1, selecting a square from an upper right square frame by taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, and judging whether the square is positioned in the target graph;
when startX = When the i-th row is traversed, starting traversing the i+1th row;
Until the circulation traversal of each point in the target graph is finished, determining largest, startX, endX, startY, endY values, and accordingly determining the side length and the coordinate position of the maximum inscribed square.
Preferably, the calculating the maximum inscribed square inside the target graph according to all the points inside the target graph comprises the following specific steps:
setting the minimum Y value point of the jth column in the target graph as The point in the target graph where the j-th column Y value is the largest is/>Note startY =/>Recording a two-dimensional array dp [ i ] [ j ] =1, taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from an upper right square frame, and judging whether the square is positioned in the target graph or not;
If the square is positioned in the target graph, judging whether the value of the two-dimensional array dp [ i ] [ j ] is larger than the value of the larget, if so, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinate of the E, F, G, H vertex; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes; meanwhile, recording the two-dimensional array dp [ i ] [ j ] =dp [ i ] +1, continuing to take the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from the upper right square, and judging whether the square is positioned in the target graph;
if the square is not inside the target pattern, then startY = +1, Recording a two-dimensional array dp [ i ] [ j ] =1, selecting a square from an upper right square frame by taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, and judging whether the square is positioned in the target graph;
When startY = When the traversal of the j-th column is finished, starting to traverse the j+1th column;
And determining the final largest, startX, endX, startY, endY value until the circulation traversal of each point in the target graph is finished, thereby determining the side length and the coordinate position of the maximum inscribed square.
Another object of the present invention is to provide an apparatus for confirming a marking position, comprising:
the auxiliary module is used for determining the size of an auxiliary rectangle enveloping the outer contour line of the target graph;
the marking module is used for dividing grid cells of the auxiliary rectangle according to the set precision and marking points on the grid;
The judging module is used for judging whether the points on the grid in the auxiliary rectangle are inside the target graph or not and marking all the points inside the target graph;
the calculation module is used for calculating the maximum inscribed square inside the target graph according to all the points inside the target graph;
the positioning module is used for determining the central point O ((startX + endX)/2, (startY + endY)/2) of the maximum inscribed square according to the determined coordinate position of the maximum inscribed square;
the adding module is used for adding marking information in the maximum inscribed square in the target graph, the center of the marking information is positioned at the center point O of the maximum inscribed square in the target graph, and the size of the marking information is matched with the side length of the corresponding maximum inscribed square.
The beneficial effects of the invention are as follows: according to the method and the device for confirming the marking position, the maximum size of the marking area and the position of the marking area are confirmed by calculating the maximum inscribed square of the internal area of the target graph, and the center position of marking information is further confirmed by confirming the center point of the maximum inscribed square, so that the marking area and the position are more reasonable, and the improvement of the marking anti-counterfeiting effect is facilitated.
Secondly, the sizes of the marking characters, the marking patterns and the marking trademarks are automatically adjusted according to the size of the maximum inscribed square, so that the sizes of the marking characters, the marking patterns and the marking trademarks are matched with the size of the maximum marking area, the actual requirements are met, and the marking effect can be improved.
In addition, according to the actual condition of the target pattern, when the target pattern has an inner hole, the position and the size of the inner hole of the closed pattern can be determined, the position of the inner hole is considered during marking, marking information and the edge of the inner hole are prevented from being interfered, and marking effect is prevented from being influenced.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate the invention and together with the embodiments of the invention, serve to explain the invention. In the drawings:
FIG. 1 is a flow chart of the present invention;
FIG. 2 is a schematic diagram of a grid cell in step two of the first embodiment of the present invention;
FIG. 3 is a schematic diagram of a grid cell in step three in accordance with an embodiment of the present invention;
FIG. 4 is a schematic diagram of the largest inscribed square in step four in the first embodiment of the present invention;
FIG. 5 is a schematic diagram of the marking information in step six in the first embodiment of the present invention;
FIG. 6 is a schematic diagram of a grid cell in step two of the second embodiment of the present invention;
FIG. 7 is a schematic diagram of a grid cell in step three in a second embodiment of the present invention;
FIG. 8 is a schematic diagram of the largest inscribed square in step four in the second embodiment of the present invention;
FIG. 9 is a diagram of a second embodiment of the present invention in which information is marked in step six;
fig. 10 is a schematic diagram of a line-by-line traversal process in accordance with an embodiment of the invention.
Detailed Description
Example 1
As shown in fig. 1 to 5, a method for confirming a marking position includes the steps of:
Step one: an auxiliary rectangle size that envelopes the object graph outline is determined. The target pattern is a pattern surrounded by a closed outer contour line.
Specifically, the specific steps of determining the auxiliary rectangle size of the outer contour line of the enveloping target graph are as follows: and traversing coordinates of each point in the outline of the target graph, and determining the minimum X coordinate Xmin, the maximum X coordinate Xmax, the minimum Y coordinate Ymin and the maximum Y coordinate Ymax of the coordinates of each point in the outline of the graph, thereby determining vertex coordinates of the auxiliary rectangle as A (Xmin, ymin), B (Xmin, ymax), C (Xmax, ymin) and D (Xmax, ymax).
Step two: the auxiliary rectangle is divided into grid units according to the set precision and points on the grid are marked. The method comprises the following specific steps: after setting the required precision, the points on the grid are marked by a two-dimensional array or matrix. The setting precision can adjust the size of the grid unit and control the distance between each point on the grid.
Taking the example of marking the points on the grid through a two-dimensional array, marking the points on the grid through a two-dimensional array A [ r ] [ c ], wherein the parameters of the grid unit comprise grid length L and grid width W, the number r of the grid unit is (Ymax-Ymin)/W, the number c of the grid unit is (Xmax-Xmin)/L, and the maximum inscribed square inside the target graph is required to be found, so that the numerical value settings of the grid length L and the grid width W are equal, and the side length of the maximum inscribed square inside the target graph is conveniently determined through the grid side length.
Step three: and judging whether the points on the grids in the auxiliary rectangle are inside the target graph or not, and marking all the points inside the target graph. Specifically, whether the points represented by the two-dimensional array A [ r ] [ c ] are inside the outer contour line or not is judged through traversal of an extraction line method, and the points located inside the outer contour line are marked through the two-dimensional array B [ r ] [ c ].
Judging whether the target point is in the target graph, starting from the target point, guiding a ray, calculating the number of intersection points of the ray and all sides of the target graph, if the intersection points are odd, indicating that the target point is in the target graph, and if the intersection points are even, indicating that the target point is outside the target graph.
In addition, the target point can be judged by methods such as an area and judging method, an included angle and judging method, and whether the point is in the target graph or not can be judged.
Step four: and calculating the maximum inscribed square inside the target graph according to all the points inside the target graph.
The method specifically comprises the following steps: firstly, defining a variable largest, startX, endX, startY, endY, wherein the larget is the side length of the maximum inscribed square, and the initial value of the variable larget is 0; e (startX, startY), F (startX, endY), G (endX, startY), H (endX, endY) are positions of four vertices of the largest inscribed square, and the position and size of the largest inscribed square can be determined by determining the value of the variable startX, endX, startY, endY.
Secondly, defining a two-dimensional array dp [ i ] [ j ] for recording the side length of the inscribed square;
Then traversing row by row or column by column in turn, determining dp [ i ] [ j ] of each point in the target graph, comparing with the larget, if the value of dp [ i ] [ j ] is larger than the value of larget, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinate of E, F, G, H vertexes; if the value of dp [ i ] [ j ] is not greater than the value of larget, the coordinates of the current larget and E, F, G, H vertices are preserved.
Taking a row-by-row traversal as an example:
Setting the point with the smallest X value of the ith row in the target graph as the following traversal from bottom to top and from left to right The point in the target graph where the X value of the ith row is the largest is/>Note startX =/>And (3) recording the two-dimensional array dp [ i ] [ j ] =1, taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from the upper right square, and judging whether the square is positioned in the target graph or not, namely judging whether each point in the square is positioned in the two-dimensional array Br ] [ c.
If the square is positioned in the target graph, judging whether the value of the two-dimensional array dp [ i ] [ j ] is larger than the value of the larget, if so, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinate of the E, F, G, H vertex; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes; meanwhile, the two-dimensional array dp [ i ] [ j ] =dp [ i ] [ j ] +1 is recorded, the value of the two-dimensional array dp [ i ] [ j ] is taken as the side length, a square is selected from the upper right square frame, and whether the square is positioned in the target graph is judged.
If the square is not inside the target pattern, then startX =+1, Recording a two-dimensional array dp [ i ] [ j ] =1, taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from an upper right square, and judging whether the square is positioned in the target graph.
Repeating the above operation when startX =When the i-th line is traversed, the i+1th line is traversed.
And traversing row by row until the circulation traversing of each point in the target graph is finished, and determining a final largest, startX, endX, startY, endY value.
Specifically, as shown in fig. 10, the enclosed pattern of the enclosed outline is a target pattern, the auxiliary rectangle encapsulates the target pattern, the points in the auxiliary rectangle are located in the two-dimensional array A [ r ] [ c ], and the points in the target pattern are represented by the hollow points, namely, the hollow points are located in the two-dimensional array B [ r ] [ c ].
Performing a row-by-row traversal from bottom to top and from left to right, performing a first row traversal with the dots of the first rowThe traversal is started.
Firstly, a two-dimensional array dp [ i ] [ j ] =1 is recorded, a square is selected by a square frame with a side length of 1 grid width to the right upper frame, a rectangular structure as shown in ① in fig. 10 is obtained, at this time, whether all points on the rectangular structure are inside a target graph needs to be judged, since all points on the rectangular structure as shown in ① in fig. 10 are inside the target graph, dp [ i ] [ j ] =1 is compared with the current value of the larget, and since the larget initial value is 0, the points areIs greater than the current value of larget, note that larget = 1, update vertex coordinates of E (startX, startY), F (startX, endY), G (endX, startY), H (endX, endY).
Due to the dotsIf the points on the rectangular structure selected currently are all inside the target graph, square is selected to the right upper square frame by using the side length as 2 grid widths, and the rectangular structure shown in figure 10 ② is obtained, and at the moment, the points on the rectangular structure are judged to exist at the points outside the target graph, so that the ending point/>Is used for traversing.
In dotsFor the target point, the largest square framed in the target graph is a rectangular structure as shown in ① in fig. 10, where the value of larget is 1 and the vertex coordinates are the coordinates of the rectangular structure in ① in fig. 10.
When the point isAfter the traversal is finished, start point/>Traversing +1, similarly, recording two-dimensional array dp [ i ] [ j ] =1, and square-selecting to the right upper square frame with side length of 1 grid width, obtaining a rectangular structure as shown in ③ in 10, judging that the point on the rectangular structure exists a point positioned outside the target graph, thus ending the point/>Traversal of +1, where the value of larget is 1, the vertex coordinates are the coordinates of the rectangular structure in FIG. 10 ①.
Since the first line has only two points located in the target graph, the second line is traversed after the two points of the first line are traversed, and the second line is traversed by the points of the second lineThe traversal is started.
And (3) marking a two-dimensional array dp [ i ] [ j ] =1, and selecting a square with a side length of 1 grid width to an upper right square frame to obtain a rectangular structure shown as ④ in fig. 10, comparing the value of dp [ i ] [ j ] =1 with the value of the current larget because each point on the rectangular structure shown as ④ in fig. 10 is in the target graph, and reserving the value of the current larget and the vertex coordinates in ① in fig. 10 because the value of dp [ i ] [ j ] is the same as the value of the current larget.
Due to the dotsAnd (3) when the points on the rectangular structure selected by the current frame are all inside the target graph, square is selected by the square frame with the side length of 2 grid widths to the right upper frame, so that the rectangular structure shown in figure 10 ⑤ is obtained, and since the points on the rectangular structure shown in figure 10 ⑤ are all inside the target graph, the values of dp [ i ] [ j ] = 2 and the current larget are compared, and since dp [ i ] [ j ] is larger than the value of the current larget, the larget=2 is obtained and the vertex coordinates are updated to be the vertex of ⑤ in figure 10.
Due to the dotsIf the points on the rectangular structure currently selected are all inside the target graph, the dp [ i ] [ j ] = dp [ i ] [ j ] +1 is square-selected by the square frame with the side length of 3 grid widths to the right upper side, and the rectangular structure shown in ⑥ in fig. 10 is obtained, and the points on the rectangular structure are located outside the target graph, so that the ending point/>At this point the value of larget is 2 and the vertex coordinates are the coordinates of the rectangular structure in figure 10 ⑤.
Starting pointTraversing +1, square is selected by square frame with 1 grid width of side length to right upper frame, and a rectangular structure as shown in ⑦ in fig. 10 is obtained, since points on the rectangular structure shown in ⑦ in fig. 10 are all in the target graph, the values of dp [ i ] [ j ] = 1 and the current larget are compared, and since dp [ i ] [ j ] is smaller than the value of the current larget, the vertex coordinates of larget=2 and ⑤ in fig. 10 are reserved.
Square is then boxed right up with a side length of 2 grid widths to obtain a rectangular structure as shown in FIG. 10 at ⑧, which ends with points outside the target pattern due to the existence of points on the rectangular structureTraversal of +1, start point/>And (2) traversing, and square selection is performed by a square frame with a side length of 1 grid width to the right upper frame, so as to obtain a rectangular structure shown as ⑨ in fig. 10.
And the like until all the points in the target graph are traversed, and finally determining the size and the position of the largest inscribed square selected by the frame, thereby further confirming the marking position and the marking size.
Further, taking a column-wise traversal as an example:
setting the minimum Y value point of the jth column in the target graph as The point in the target graph where the j-th column Y value is the largest is/>Note startY =/>Recording a two-dimensional array dp [ i ] [ j ] =1, taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from an upper right square frame, and judging whether the square is positioned in the target graph or not;
If the square is positioned in the target graph, judging whether the value of the two-dimensional array dp [ i ] [ j ] is larger than the value of the larget, if so, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinate of the E, F, G, H vertex; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes; meanwhile, recording the two-dimensional array dp [ i ] [ j ] =dp [ i ] +1, continuing to take the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from the upper right square, and judging whether the square is positioned in the target graph;
if the square is not inside the target pattern, then startY = +1, Recording a two-dimensional array dp [ i ] [ j ] =1, selecting a square from an upper right square frame by taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, and judging whether the square is positioned in the target graph;
When startY = When the traversal of the j-th column is finished, starting to traverse the j+1th column;
And determining the final largest, startX, endX, startY, endY value until the circulation traversal of each point in the target graph is finished, thereby determining the side length and the coordinate position of the maximum inscribed square.
It should be noted that: traversing line by line, namely traversing line by line from bottom to top and from right to left, wherein a rectangular structure needs to be selected for the upper left square frame of the target point; traversing line by line, namely traversing line by line from top to bottom and from left to right, wherein a rectangular structure needs to be selected for a lower right square frame of a target point; a row-by-row traversal may be provided from top to bottom and right to left, where a rectangular structure needs to be selected for the bottom left box of the target point. The specific process is the same as the above-mentioned line-by-line traversal process, and will not be described here.
Traversing column by column, namely traversing column by column from left to right and from top to bottom, wherein a rectangular structure needs to be selected for a lower right square frame of a target point; traversing column by column, namely traversing column by column from right to left and from bottom to top, wherein a rectangular structure needs to be selected for the upper left square frame of the target point; column-wise traversal may be set from right to left and top to bottom, where a rectangular structure needs to be selected for the bottom left box of the target point. The specific process is the same as the above-mentioned column-by-column traversal process, and will not be described here.
Step five: the center point O ((startX + endX)/2, (startY + endY)/2) of the largest inscribed square is determined from the determined coordinate positions. The center of the marking characters is arranged at the center point O of the maximum inscribed square, so that marking information is positioned at the center of the maximum inscribed square, and interference between the marking information and an inner hole or an outer contour is avoided, and the marking information is not clear.
Step six: marking information is added in the largest inscribed square in the target graph. Furthermore, the size of the marking information is in direct proportion to the side length of the corresponding maximum inscribed square, and the size of the marking information can be adaptively adjusted according to the determined side length of the maximum inscribed square, so that the marking information is more suitable for the size and the proportion of the target graph.
The marking information comprises marking characters, marking patterns and marking trademarks, the characters, the patterns and the trademarks mainly play a role in marking anti-counterfeiting, and the characters, the patterns and the trademarks can be selected according to actual demands.
Example two
As shown in fig. 1, 6 to 9, the structure of the present embodiment is substantially the same as that of the first embodiment, except that: the target pattern of this embodiment includes a closed outer contour and a plurality of closed inner contours, the inner contours being located in the pattern enclosed by the outer contours.
Compared with the specific operation of the third step in the first embodiment, the method in this embodiment determines whether the points on the grid in the auxiliary rectangle are inside the target graph, and marks all the points inside the target graph, and specifically includes the following steps: and traversing and judging whether the points represented by the two-dimensional array A [ r ] [ c ] are inside the outer contour and outside the inner contour by using an ignition method, and marking the points positioned inside the outer contour and outside the inner contour by using the two-dimensional array B [ r ] [ c ].
Example III
In a second aspect of the present invention, a device for confirming a marking position is provided, including an auxiliary module, a marking module, a judging module, a calculating module, a positioning module and an adding module. The auxiliary module is used for determining the auxiliary rectangle size of the outer contour line of the enveloping target graph; the marking module is used for dividing grid cells of the auxiliary rectangle according to the set precision and marking points on the grid; the judging module is used for judging whether the points on the grid in the auxiliary rectangle are inside the target graph or not and marking all the points inside the target graph; the calculation module is used for calculating the maximum inscribed square inside the target graph according to all the points inside the target graph; the positioning module is used for determining the central point O ((startX + endX)/2, (startY + endY)/2) of the maximum inscribed square according to the determined coordinate position of the maximum inscribed square; the adding module is used for adding marking information in the maximum inscribed square in the target graph, the center of the marking information is positioned at the center point O of the maximum inscribed square in the target graph, and the size of the marking information is matched with the side length of the corresponding maximum inscribed square.
The foregoing description is only a preferred embodiment of the present invention, and the present invention is not limited thereto, but it is to be understood that modifications and equivalents of some of the technical features described in the foregoing embodiments may be made by those skilled in the art, although the present invention has been described in detail with reference to the foregoing embodiments. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (8)

1. A method of identifying a marking location, comprising the steps of:
Determining the auxiliary rectangle size of the outer contour line of the enveloping target graph; the target graph is a graph surrounded by a closed outer contour line or comprises a closed outer contour line and a plurality of closed inner contour lines, and the inner contour lines are positioned in the graph surrounded by the outer contour lines;
Dividing grid units of the auxiliary rectangle according to the set precision and marking points on the grid;
Judging whether the points on the grids in the auxiliary rectangle are inside the target graph or not, and marking all the points inside the target graph;
Calculating the maximum inscribed square inside the target graph according to all the points inside the target graph;
determining the central point O ((startX + endX)/2, (startY + endY)/2) of the maximum inscribed square according to the determined coordinate position of the maximum inscribed square;
Adding marking information into the maximum inscribed square in the target graph, wherein the center of the marking information is positioned at the center point O of the maximum inscribed square in the target graph, and the size of the marking information is matched with the side length of the corresponding maximum inscribed square;
The method for calculating the maximum inscribed square inside the target graph comprises the following steps: defining a variable largest, startX, endX, startY, endY, wherein larget is the side length of the maximum inscribed square, and E (startX, startY), F (startX, endY), G (endX, startY) and H (endX, endY) are the coordinate positions of four vertexes of the maximum inscribed square;
Defining two-dimensional array dp [ i ] [ j ] for recording side length of inscribed square;
Traversing row by row or column by column in turn, determining dp [ i ] [ j ] of each point in the target graph, comparing the dp [ i ] [ j ] with the larget, if the value of dp [ i ] [ j ] is larger than the value of the larget, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinates of the E, F, G, H vertexes; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes;
After the traversal is finished, determining a variable largest, startX, endX, startY, endY so as to determine the side length and the coordinate position of the maximum inscribed square;
When the target graph comprises a closed outer contour line and a plurality of closed inner contour lines, the inner contour lines are positioned in the graph surrounded by the outer contour lines, whether points represented by the two-dimensional array A [ r ] [ c ] are positioned inside the outer contour lines and outside the inner contour lines or not is judged through traversal of an induced ray method, and the points positioned inside the outer contour lines and outside the inner contour lines are marked through the two-dimensional array B [ r ] [ c ].
2. The method for determining the marking position according to claim 1, wherein the specific step of determining the auxiliary rectangle size of the envelope object graph outline is: and traversing the coordinates of each point in the outer contour line of the target graph, and determining the minimum X coordinate Xmin, the maximum X coordinate Xmax, the minimum Y coordinate Ymin and the maximum Y coordinate Ymax of the coordinates of each point in the outer contour line of the target graph, thereby determining the vertex coordinates of the auxiliary rectangle as A (Xmin, ymin), B (Xmin, ymax), C (Xmax, ymin) and D (Xmax, ymax).
3. The method for confirming a marking position according to claim 1, wherein the dividing of the auxiliary rectangle into grid cells and marking the points on the grid according to the set precision comprises the steps of: after setting the required precision, the points on the grid are marked by a two-dimensional array or matrix.
4. A method of validating a marking location as claimed in claim 3, wherein marking points on a grid by a two-dimensional array comprises the steps of: and recording a two-dimensional array A [ r ] [ c ] for marking points on a grid, wherein the parameters of the grid unit comprise grid length L and grid width W, the number r of the grid unit is (Ymax-Ymin)/W, the number c of the grid unit is (Xmax-Xmin)/L, and the numerical values of the grid length L and the grid width W are equal.
5. The method of confirming marking location according to claim 4, wherein when the target pattern is a pattern enclosed by a closed outer contour, determining whether the point represented by the two-dimensional array ar [ c ] is inside the outer contour by traversing by an emission line method and marking the point located inside the outer contour by the two-dimensional array B [ r [ c ].
6. The method for confirming a marking position according to claim 1, wherein the calculating the maximum inscribed square inside the target pattern based on all points inside the target pattern comprises the following steps:
Setting the point with the smallest X value of the ith row in the target graph as the following traversal from bottom to top and from left to right The point in the target graph where the X value of the ith row is the largest is/>Note startX =/>Recording a two-dimensional array dp [ i ] [ j ] =1, taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from an upper right square frame, and judging whether the square is positioned in the target graph or not;
If the square is positioned in the target graph, judging whether the value of the two-dimensional array dp [ i ] [ j ] is larger than the value of the larget, if so, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinate of the E, F, G, H vertex; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes; meanwhile, recording the two-dimensional array dp [ i ] [ j ] =dp [ i ] +1, continuing to take the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from the upper right square, and judging whether the square is positioned in the target graph;
If the square is not inside the target pattern, then startX = +1, Recording a two-dimensional array dp [ i ] [ j ] =1, selecting a square from an upper right square frame by taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, and judging whether the square is positioned in the target graph;
when startX = When the i-th row is traversed, starting traversing the i+1th row;
Until the circulation traversal of each point in the target graph is finished, determining largest, startX, endX, startY, endY values, and accordingly determining the side length and the coordinate position of the maximum inscribed square.
7. The method for confirming a marking position according to claim 1, wherein the calculating the maximum inscribed square inside the target pattern based on all points inside the target pattern comprises the following steps:
setting the minimum Y value point of the jth column in the target graph as The point in the target graph where the j-th column Y value is the largest is/>Note startY =/>Recording a two-dimensional array dp [ i ] [ j ] =1, taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from an upper right square frame, and judging whether the square is positioned in the target graph or not;
If the square is positioned in the target graph, judging whether the value of the two-dimensional array dp [ i ] [ j ] is larger than the value of the larget, if so, giving the value of dp [ i ] [ j ] to the larget, storing the larget, and updating the coordinate of the E, F, G, H vertex; if the value of dp [ i ] [ j ] is not greater than the value of the larget, reserving the coordinates of the current larget and E, F, G, H vertexes; meanwhile, recording the two-dimensional array dp [ i ] [ j ] =dp [ i ] +1, continuing to take the value of the two-dimensional array dp [ i ] [ j ] as the side length, selecting a square from the upper right square, and judging whether the square is positioned in the target graph;
if the square is not inside the target pattern, then startY = +1, Recording a two-dimensional array dp [ i ] [ j ] =1, selecting a square from an upper right square frame by taking the value of the two-dimensional array dp [ i ] [ j ] as the side length, and judging whether the square is positioned in the target graph;
When startY = When the traversal of the j-th column is finished, starting to traverse the j+1th column;
And determining the final largest, startX, endX, startY, endY value until the circulation traversal of each point in the target graph is finished, thereby determining the side length and the coordinate position of the maximum inscribed square.
8. An apparatus for confirming a marking position, for implementing the method for confirming a marking position according to any one of claims 1 to 7, comprising:
the auxiliary module is used for determining the size of an auxiliary rectangle enveloping the outer contour line of the target graph;
the marking module is used for dividing grid cells of the auxiliary rectangle according to the set precision and marking points on the grid;
The judging module is used for judging whether the points on the grid in the auxiliary rectangle are inside the target graph or not and marking all the points inside the target graph;
the calculation module is used for calculating the maximum inscribed square inside the target graph according to all the points inside the target graph;
the positioning module is used for determining the central point O ((startX + endX)/2, (startY + endY)/2) of the maximum inscribed square according to the determined coordinate position of the maximum inscribed square;
the adding module is used for adding marking information in the maximum inscribed square in the target graph, the center of the marking information is positioned at the center point O of the maximum inscribed square in the target graph, and the size of the marking information is matched with the side length of the corresponding maximum inscribed square.
CN202410181820.9A 2024-02-19 2024-02-19 Method and device for confirming marking position Active CN117745807B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410181820.9A CN117745807B (en) 2024-02-19 2024-02-19 Method and device for confirming marking position

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410181820.9A CN117745807B (en) 2024-02-19 2024-02-19 Method and device for confirming marking position

Publications (2)

Publication Number Publication Date
CN117745807A CN117745807A (en) 2024-03-22
CN117745807B true CN117745807B (en) 2024-04-26

Family

ID=90277630

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410181820.9A Active CN117745807B (en) 2024-02-19 2024-02-19 Method and device for confirming marking position

Country Status (1)

Country Link
CN (1) CN117745807B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05225326A (en) * 1992-01-13 1993-09-03 Nec Corp Graphic skeleton detection method and device
CN108520121A (en) * 2018-03-27 2018-09-11 信利半导体有限公司 Lattice generation method and device and computer installation and readable storage medium storing program for executing
CN110968112A (en) * 2019-12-12 2020-04-07 哈尔滨工程大学 Unmanned aerial vehicle autonomous landing system and method based on monocular vision
CN115631347A (en) * 2022-12-21 2023-01-20 济南邦德激光股份有限公司 Plate stock layout method, equipment and storage medium
CN116050123A (en) * 2023-01-07 2023-05-02 中国航空制造技术研究院 Method for processing position of web mark and computer readable storage medium
CN116090126A (en) * 2023-01-06 2023-05-09 西北工业大学 DXF-based complex sheet contour topology reconstruction method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05225326A (en) * 1992-01-13 1993-09-03 Nec Corp Graphic skeleton detection method and device
CN108520121A (en) * 2018-03-27 2018-09-11 信利半导体有限公司 Lattice generation method and device and computer installation and readable storage medium storing program for executing
CN110968112A (en) * 2019-12-12 2020-04-07 哈尔滨工程大学 Unmanned aerial vehicle autonomous landing system and method based on monocular vision
CN115631347A (en) * 2022-12-21 2023-01-20 济南邦德激光股份有限公司 Plate stock layout method, equipment and storage medium
CN116090126A (en) * 2023-01-06 2023-05-09 西北工业大学 DXF-based complex sheet contour topology reconstruction method
CN116050123A (en) * 2023-01-07 2023-05-02 中国航空制造技术研究院 Method for processing position of web mark and computer readable storage medium

Also Published As

Publication number Publication date
CN117745807A (en) 2024-03-22

Similar Documents

Publication Publication Date Title
Anderson Detecting and eliminating collisions in NC machining
CN111410414B (en) Implementation method of glass cutting optimization technology
JP2009524862A (en) Cutting method for parts assembly
CN106679684A (en) Path planning method and system of automatic operating device
CN117745807B (en) Method and device for confirming marking position
CN1088869C (en) Character processing apparatus and character processing method
CN107914397A (en) A kind of 3D objects determine area's Method of printing and system
CN112077452B (en) Longitudinal and transverse coordinate correction method of laser marking system
CN105955191B (en) A kind of method that path planning is carried out based on image feature data
CN115870629B (en) Single-line font laser engraving method, device, equipment and medium
CN115213737A (en) Material increase and decrease manufacturing cutter interference detection method based on minimum process decomposition times
JPH04339581A (en) Laser marking device
JPH03166039A (en) Method and device for deciding method of machining inner diameter in function of generating information on numerical control
EP0450940B1 (en) Character processing method and apparatus
CN101916318A (en) Scale value outline overstriking drawing method of sign plate
US5134687A (en) Method for converting image data into dot data
JPH0236022B2 (en)
CN109918750A (en) A kind of full-automatic modeling method of the erosion of the accurate control points on H profile steel column range
CN115310237B (en) Automatic profile steel hole type parameterization method based on graphic file
CN107942946A (en) A kind of digital control programming method of wide step conical surface
TWI704995B (en) Slicing method for horizontal facets of color 3d object
WO1996028927A1 (en) Method and system for translating between an image and a 3-dimensional relief
CN111898082A (en) High-precision rapid point cloud generation algorithm based on direction template
JPH08282195A (en) Character engraving device
JPH0326056B2 (en)

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant