A method and device for accurately obtaining the frame of a paper cup fan
Through training model and algorithm adjustment, combined with model list and template diagram, the precise positioning of the sliver border of the paper cup under complex background and noise interference is achieved, solving the problem of inaccurate results in the existing technology, and improving the automation and accuracy of paper cup production.
Patent Information
- Application Number
- CN202410836783.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2044-06-26
AI Technical Summary
The results of existing methods are inaccurate when acquiring the fan-shaped border of paper cups, especially in images with uncertain location, complex background, and severe noise interference, making it difficult to accurately locate the fan-shaped border.
The pre-trained fan-shaped piece detection model and segmentation model are used for detection and segmentation, and the edge position of the rectangular detection frame is adjusted in combination with the hit_num algorithm, and the minimum external matrix crop is cut using the model list and template diagram. Finally, the paper cup model is judged through the rough outline of the fan-shaped piece to achieve accurate border acquisition.
Under complex background and noise interference, the sector border and paper cup models can be accurately determined, improving the accuracy and efficiency of model training, and supporting subsequent operations such as printing, die-cutting and texture sampling.
Smart Images

Figure CN118862199B_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to the technical field of paper cup design, and in particular to a method and device for accurately obtaining a paper cup fan frame. [Background technology]
[0002] With the increasing demand for flexible production, small batches, and customization, in the process of customized paper cup production, it is often necessary to design based on the design drawings of paper cups: Figure 3 3D effect display, digital printing nozzle positioning or offset printing platemaking (combination), laser die-cutting and other operations or links. Therefore, obtaining the paper cup fan frame and accurately positioning the target area for printing, die-cutting and texture sampling is the premise and basis for achieving the above operations.
[0003] With the application of artificial intelligence technology in the field of paper cup production, the training and fine-tuning of neural network models in these fields are increasingly becoming the key links in the intelligence of this field. The effect of model training and fine-tuning depends on a large amount of high-precision labeled data, such as high-precision fan-shaped bbox labeling and mask labeling. Manual labeling or the use of general automated labeling tools is not only inefficient, but also often lacks data volume, and most importantly, the labeling is inaccurate.
[0004] Therefore, the paper cup fan border is accurately matched from the low-precision data output by the initial iterative neural network model, and the precise annotation data is automatically generated and input into the subsequent iterative process of the model, thereby providing the model with automated, incremental, high-precision annotation data required for training, verification and testing, thereby improving the adequacy, speed and accuracy of the model's training results, and improving the practicality of the model for downstream tasks.
[0005] In addition, in the fully automatic prepress inspection, for some relatively hidden, pixel-level design errors, it is necessary to first obtain the accurate paper cup fan frame, and then accurately locate the specific pixels where the possible errors are before checking and judging, such as Figure 1 The yellow dotted frame for marking the printed content area shown must be removed in actual production. However, to locate this yellow dotted frame, the border of the paper cup fan must be accurately obtained first.
[0006] However, the existing methods for obtaining the fan-shaped border in the design drawing have the following shortcomings:
[0007] (1) Directly fitting the edge of the segmentation mask output by the deep neural network. Since the output of the neural network is directly affected by the quality and quantity of the training data and the labeled data, the fan-shaped border of the paper cup obtained in this way is not accurate.
[0008] (2) Traditional image processing methods use methods such as template matching and feature point matching to obtain the border of a paper cup fan based on its geometric characteristics (straight lines, arcs, etc.). The disadvantages of this method are that it is easily affected by noise in the image, the results are unstable, the output results vary greatly under different conditions, it has high requirements for the image files to be processed, and it lacks universal applicability.
[0009] In view of this, it is necessary to provide a method and device for accurately obtaining the frame of a paper cup fan to overcome the above-mentioned defects. [Summary of the invention]
[0010] The purpose of the present invention is to provide a method and device for accurately obtaining the fan-shaped border of a paper cup, aiming to solve the problem of inaccurate results of obtaining the fan-shaped border of a paper cup by existing methods. The fan-shaped frame and model can be accurately determined from images and files with uncertain positions, complex backgrounds, and severe noise interference.
[0011] In order to achieve the above object, the first aspect of the present invention provides a method for accurately obtaining a paper cup fan frame, comprising:
[0012] Step S10: Detect the imported image to be processed by using a pre-trained fan-shaped piece detection model, and output a rectangular detection box of the fan-shaped piece, which is recorded as fan_bbox;
[0013] Step S20: performing fan-shaped segmentation on the imported image to be processed by using a pre-trained fan-shaped segmentation model, and outputting a binary mask of the fan-shaped slice, which is recorded as fan_mask;
[0014] Step S30: binarizing the image to be processed to obtain a binarized image, recorded as bin_image, and segmenting the binarized image bin_image according to the binarized mask fan_mask to obtain a binary fan-shaped image, recorded as fan_seg;
[0015] Step S40: determining the number of times the edge of the rectangular detection box fan_bbox passes through the border connected area of the binary fan image fan_seg by a preset hit_num algorithm, and adjusting the edge position of the rectangular detection box fan_bbox according to the number, to obtain the minimum circumscribed matrix of the binary fan image fan_seg, recorded as min_bbox;
[0016] Step S50: obtaining a model list including a template image of all paper cup models and their corresponding precise fan sheet specification data and precise binary mask; wherein the template image is recorded as tmpl_image and the precise binary mask is recorded as tmpl_mask;
[0017] Step S60: obtaining a rough contour of the fan-shaped piece according to the binary mask fan_mask and the binary image bin_image, which is recorded as fan_contour;
[0018] Step S70: determining the target paper cup model corresponding to the fan-shaped sheet rough contour fan_contour by a preset algorithm, which is recorded as cup_type; wherein the determination condition of the preset algorithm satisfies: the right side line of the fan-shaped sheet rough contour fan_contour and the right side line of the target paper cup model cup_type are closest to the same straight line;
[0019] Step S80: importing the template image tmpl_image of the target paper cup model cup_type, the image to be processed and its corresponding minimum external matrix min_bbox, and cutting the image to be processed according to the minimum external matrix min_bbox to obtain the processing area roi_image;
[0020] Step S90: scaling the processing region roi_image to the same size as the template image tmpl_image, and performing a bitwise AND operation on the precise binary mask tmpl_mask and the processing region roi_image to obtain the precisely segmented sector pieces of the image to be processed and their corresponding borders.
[0021] In a preferred embodiment, the step S30 includes:
[0022] Step S31: performing a morphological operation on the binary mask fan_mask, first performing a closing operation and then performing an opening operation, and calculating to obtain a morphological dilation of dilated_mask=fan_mask;
[0023] Step S32: performing a bitwise AND operation on the binary mask fan_mask and the binary image bin_image after the morphological operation to obtain the segmented binary fan image fan_seg.
[0024] In a preferred embodiment, in step S40, the hit_num algorithm includes:
[0025] Step S41: importing the rectangular detection box fan_bbox and the binary fan image fan_seg, and passing in the straight line equation parameters based on the edge of the rectangular detection box fan_bbox;
[0026] Step S42: Starting from the leftmost or topmost side of the binary fan graph fan_seg, traverse all pixel points along the path determined by the input straight line equation. If the pixel value of the traversed pixel point is greater than the preset pixel threshold, the recorded number of passages is increased by 1. If the pixel value of the next pixel point traversed is also greater than the pixel threshold, the recorded number of passages remains unchanged.
[0027] In a preferred embodiment, in the step S40, a left line l_left, a right line l_right, a top line l_top, and a bottom line l_bottom of the rectangular detection box fan_bbox are defined;
[0028] Among them, the steps to adjust the left line l_left of the rectangular detection box fan_bbox are as follows:
[0029] By using the hit_num algorithm, determine the number of times hit_num that the left line l_left passes through the fan-shaped border of the binary fan-shaped image fan_seg;
[0030] If hit_num=2, execute the following loop: coordinate value x=x-1, then continue to use the hit_num algorithm to determine the number of times hit_num that the new left line l_left crosses the fan-shaped border; when hit_num is 0 or x is 0, jump out of the loop;
[0031] If hit_num=0, execute the following loop: coordinate value x=x+1, and then continue to use the hit_num algorithm to determine the number of times hit_num that the new left line l_left crosses the sector border; when it is determined that the number of times the new left line l_left crosses is 1, execute x=x-1 and jump out of the loop, and the latest l_left after adjustment is the left line of the minimum circumscribed matrix of the sector border;
[0032] Among them, the steps to adjust the right line l_right of the rectangular detection box fan_bbox are as follows:
[0033] By using the hit_num algorithm, determine the number of times hit_num that the right line l_right passes through the fan-shaped border of the binary fan-shaped image fan_seg;
[0034] If hit_num=2, execute the following loop: coordinate value x=x+1, then continue to determine the number of times hit_num that the new right line l_right crosses the fan-shaped border through the hit_num algorithm; when hit_num is 0 or x is the image width, jump out of the loop;
[0035] If hit_num=0, execute the following loop: coordinate value x=x-1, and then continue to use the hit_num algorithm to determine the number of times hit_num that the new right line l_right crosses the sector border; when it is determined that the number of times the new right line l_right crosses is 1, execute x=x+1, and jump out of the loop, and the latest adjusted l_right is the right line of the minimum circumscribed matrix of the sector border;
[0036] Among them, the steps to adjust the upper edge l_top of the rectangular detection box fan_bbox are as follows:
[0037] By using the hit_num algorithm, the number of times hit_num that the top line l_top passes through the fan-shaped border of the binary fan-shaped image fan_seg is determined;
[0038] If hit_num=2, execute the following loop: coordinate value y=y-1, then continue to determine the number of times hit_num that the new top line l_top passes through the fan-shaped border through the hit_num algorithm; when hit_num is 0 or y is 0, jump out of the loop;
[0039] If hit_num=0, execute the following loop: coordinate value y=y+1, and then continue to determine the number of times hit_num that the new upper edge line l_top passes through the sector border through the hit_num algorithm; when it is determined that the number of times the new upper edge line l_top passes through is 1, execute y=y-1, and jump out of the loop, and the latest l_top after adjustment is the upper edge line of the minimum circumscribed matrix of the sector border;
[0040] Among them, the steps to adjust the bottom line l_bottom of the rectangular detection box fan_bbox are as follows:
[0041] By using the hit_num algorithm, determine the number of times hit_num that the bottom line l_bottom passes through the fan-shaped border of the binary fan-shaped graph fan_seg;
[0042] If hit_num>2, execute the following loop: coordinate value y=y+1, then continue to determine the number of times hit_num that the new bottom line l_bottom passes through the fan-shaped border through the hit_num algorithm; when hit_num is 0 or y is the image height, jump out of the loop;
[0043] If hit_num=0, execute the following loop: coordinate value y=y-1, and then continue to use the hit_num algorithm to determine the number of times hit_num that the new bottom line l_bottom passes through the fan-shaped border; when it is determined that the number of times the new bottom line l_bottom passes through is greater than 1, execute y=y+1 and jump out of the loop. The adjusted latest l_bottom is the bottom line of the minimum circumscribed matrix of the fan-shaped border.
[0044] In a preferred embodiment, the step S50 includes:
[0045] Step S51: importing a graphic design template of a target paper cup model that meets the required dimensions for production and has a fan-shaped border;
[0046] Step S52: clear all other contents in the graphic design template, leaving only a clean fan-shaped border;
[0047] Step S53: cutting according to the minimum circumscribed matrix of the sector frame to obtain the final template image tmpl_image of the target paper cup model;
[0048] Step S54: obtaining accurate fan sheet specification data according to the template image tmpl_image; the fan sheet specification data includes: left side line, right side line, angle between two side lines, length of two side lines, lower arc vertex, upper arc vertex, center and radius of concentric circles of printing area, and bleeding position edge line;
[0049] Step S55: according to the template image tmpl_image, a precise binary mask tmpl_mask is produced, in which the pixel values of a sector-shaped border and its inner area are all 255, and the pixel values of other areas are all 0;
[0050] Step S56: storing the above tmpl_image corresponding parameters and tmpl_mask into the database;
[0051] Step S57: storing the fan specification data and the precise binary mask tmpl_mask of the target paper cup model into a database;
[0052] Step S58: Execute the steps S51-S58 in a loop until the data of all paper cup models are entered and a model list is generated.
[0053] In a preferred embodiment, the step S60 includes:
[0054] Step S61: importing the binarized image bin_image, the binarized mask fan_mask and the dilated_mask;
[0055] Step S62: Obtain the rough contour of the fan-shaped piece fan_contour=mask_contour and perform bitwise AND operation on bin_image; wherein, mask_contour=dilated_mask-fan_mask is morphologically eroded.
[0056] In a preferred embodiment, the step S70 includes:
[0057] Step S71: perform straight line search on the fan-shaped rough contour fan_contour, and add the straight lines or line segments with slope k>0 to the right line list r_line_list;
[0058] Step S72: traverse the right line list r_line_list, merge the line segments on the same straight line into a longer line segment, remove the merged line segments from the right line list r_line_list and add the merged line segments to obtain a new r_line_list with fewer line segments;
[0059] Step S73: According to a preset matching algorithm, select the right line list of the fan-shaped rough contour fan_contour
[0060] In r_line_list, find the line segment r_line'; wherein the line segment r_line' satisfies:
[0061] The right side of the cup_type's scalloped border is closest to the same straight line.
[0062] In a preferred embodiment, the matching algorithm includes:
[0063] Step S731: setting a threshold value epsilon of the absolute value of the difference between the slopes of the two straight lines, and setting an initial minimum value of the absolute value of the difference between the slopes of the two straight lines to abs_k_min=-1;
[0064] Step S732: Execute the following loop from the model list: Get the line segment line1 in the right line list r_line_list, and obtain the slope k1;
[0065] Traverse a paper cup model type_i in the model list, obtain the right line line2 of the fan-shaped border corresponding to the paper cup model type_i, and obtain the slope k2;
[0066] Find the absolute value of the difference in slope between line1 and line2 |k1-k2|;
[0067] If abs_k_min < |k1 - k2|, then the covering assignment makes abs_k_min = |k1 - k2|, cup_type = type_i, r_line’ = line1, and step S733 is executed;
[0068] Step S733: If abs_k_min < epsilon, then return the line segment r_line’ and the target paper cup model cup_type; otherwise, there is no corresponding paper cup model, and this matching loop is exited.
[0069] The second aspect of the present invention provides a device for accurately obtaining the border of a paper cup fan blade, including:
[0070] A rough rectangle obtaining module, configured to detect the imported image to be processed through a pre-trained fan blade detection model, and output a rectangular detection frame of the fan blade, denoted as fan_bbox;
[0071] A rough fan segmentation module, configured to perform fan segmentation on the imported image to be processed through a pre-trained fan segmentation model, and output a binary mask of the fan blade, denoted as fan_mask;
[0072] A binary fan obtaining module, configured to binarize the image to be processed to obtain a binary image, denoted as bin_image, and segment the binary image bin_image according to the binary mask fan_mask to obtain a binary fan image, denoted as fan_seg;
[0073] An external matrix adjustment module, configured to judge the number of times the side line of the rectangular detection frame fan_bbox passes through the border connection area of the binary fan image fan_seg through a preset hit_num algorithm, and adjust the position of the side line of the rectangular detection frame fan_bbox according to this number of times to obtain the minimum external matrix of the binary fan image fan_seg, denoted as min_bbox;
[0074] A model list obtaining module, configured to obtain a model list including template images of all paper cup models and their corresponding precise fan blade specification data and precise binary masks; wherein, the template image is denoted as tmpl_image, and the precise binary mask is denoted as tmpl_mask;
[0075] A fan contour obtaining module, configured to obtain a rough contour of the fan blade, denoted as fan_contour, according to the binary mask fan_mask and the binary image bin_image;
[0076] The paper cup model matching module is used to determine the target paper cup model corresponding to the fan-shaped sheet rough contour fan_contour by a preset algorithm, which is recorded as cup_type; wherein the judgment condition of the preset algorithm satisfies: the right line of the fan-shaped sheet rough contour fan_contour and the right line of the target paper cup model cup_type are closest to the same straight line;
[0077] The template parameter import module is used to import the template image tmpl_image of the target paper cup model cup_type, the image to be processed and its corresponding minimum external matrix min_bbox, and cut the image to be processed according to the minimum external matrix min_bbox to obtain the processing area roi_image;
[0078] The sector-shaped precise segmentation module is used to scale the processing area roi_image to the same size as the template image tmpl_image, and perform a bitwise AND operation on the precise binary mask tmpl_mask and the processing area roi_image to obtain the sector-shaped pieces of the image to be processed and their corresponding borders.
[0079] A third aspect of the present invention provides a terminal, which includes a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, the various steps of the method for accurately obtaining the fan frame of a paper cup as described in any of the above embodiments are implemented.
[0080] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for accurately obtaining a paper cup fan frame as described in any one of the above-mentioned embodiments.
[0081] A fifth aspect of the present invention provides a computer program product, including a computer program or instructions, which, when processed and executed, implement the various steps of the method for accurately obtaining the border of a paper cup fan as described in any of the above-mentioned embodiments.
[0082] The method and device for accurately obtaining the border of a paper cup fan provided by the present invention first obtain a rough external matrix through a fan-shaped piece detection model, and obtain a rough fan-shaped segmentation through a fan-shaped segmentation model. Based on the fan-shaped frame contained in the rough segmentation, the minimum external matrix is adjusted accordingly, and finally the corresponding paper cup model is judged by the straight line of the rough outline of the fan-shaped piece, so as to obtain a more accurate fan-shaped border size and range in combination with the minimum external matrix. Each of the above steps removes a large amount of interference and noise in the original image, gradually approximates, and finally obtains an accurate border. Among them, the model list containing the fan-shaped parameter library is the basis for the actual production of this method, and the paper cup model can be determined quickly and efficiently by judging the straight line, thereby improving the processing efficiency.
Brief Description of the Drawings
[0083] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0084] Figure 1 is a schematic diagram of an exemplary marking printing content area;
[0085] Figure 2 A flow chart of a method for accurately obtaining a paper cup fan frame provided by the present invention;
[0086] Figure 3 is an image to be processed in an exemplary embodiment;
[0087] Figure 4 for Figure 3 The schematic diagram of the rough sector and rough external matrix bbox obtained by model detection and segmentation of the image to be processed shown;
[0088] Figure 5 It is the precise sector diagram finally obtained after the image to be processed is processed by the method of the present invention;
[0089] Figure 6 A framework diagram of a device for accurately obtaining a paper cup fan frame provided by the present invention. [Specific implementation method]
[0090] In order to make the purpose, technical solution and beneficial technical effect of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. It should be understood that the specific implementation methods described in this specification are only for explaining the present invention, not for limiting the present invention.
[0091] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0092] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0093] Before describing the technical solution of the present invention in detail, the professional terms involved are explained first:
[0094] Mask / Segmentation Mask / Mask: It is a technique in computer vision that is used to accurately separate objects in an image from the background. It achieves fine-grained division of image areas by classifying and labeling each pixel. Each pixel is assigned a label to indicate whether it belongs to the foreground or background, or to a different object category. Such label information forms a two-dimensional matrix, namely the segmentation mask.
[0095] bbox / boundingbox: Bbox is a rectangular box that wraps around the target object. This rectangular box defines the size, position, and orientation of the target. Bbox is usually represented by four corner points, which are usually called the upper left corner, upper right corner, lower right corner, and lower left corner. In computer vision algorithms, Bbox is often associated with target detection tasks. Object detection is a computer vision task that aims to automatically detect the presence and position of target objects in images or videos.
[0096] Annotation / Data Annotation: Data annotation is a key link for most artificial intelligence algorithms to operate effectively. Simply put, data annotation is the process of processing unprocessed voice, image, text, video and other data to transform them into machine-recognizable information. The types of data annotation are mainly image annotation, voice annotation, 3D point cloud annotation and text annotation. Image annotation is to process unprocessed image data, convert it into machine-recognizable information, and then transmit it to the artificial intelligence algorithm and model for call. Common image annotation methods include semantic segmentation, rectangular box annotation, polygon annotation, key point annotation, point cloud annotation, 3D cube annotation, 2D / 3D fusion annotation, target tracking, etc.
[0097] Image segmentation model: a neural network model that implements semantic segmentation or instance segmentation
[0098] Fine tuning: large-scale pre-training of general domain data to adapt to specific tasks or domains.
[0099] Sector specification data: the left side, right side, angle between the two sides, length of the two sides, lower arc vertex, upper arc vertex, center point and radius of the concentric circles of the printing area of the sector frame of a specific model of cup.
[0100] Embodiment 1
[0101] In an embodiment of the present invention, a method for accurately obtaining a paper cup fan-shaped frame is provided, which is used to perform fan-shaped recognition on a paper cup design drawing with a fan-shaped piece, and can accurately and automatically mark the paper cup fan-shaped frame, and automatically generate accurate marking data, which is convenient for the training and fine-tuning of the neural network model in the subsequent process, and the precise positioning of the target area for printing, die-cutting, texture sampling, etc.
[0102] like Figure 2 As shown, the method for accurately obtaining the border of a paper cup fan includes steps S10-S90.
[0103] Step S10: Detect the imported image to be processed by using a pre-trained fan-shaped piece detection model, and output a rectangular detection frame of the fan-shaped piece, that is, a rectangular box, recorded as fan_bbox.
[0104] Step S20: Perform sector segmentation on the imported image to be processed using a pre-trained sector segmentation model, and output a binary mask of the sector slice, denoted as fan_mask.
[0105] It should be noted that the above-mentioned sector-shaped slice detection model and sector-shaped segmentation model can be implemented based on the existing technology, and the specific implementation principles and implementation methods thereof will not be described in detail in the present invention.
[0106] Step S30: binarizing the image to be processed to obtain a binarized image, recorded as bin_image, and segmenting the binarized image bin_image according to the binarization mask fan_mask to obtain a binary fan-shaped image, recorded as fan_seg.
[0107] Specifically, step S30 includes steps S31-S32.
[0108] Step S31: Perform morphological operations on the binary mask fan_mask, first perform a closing operation, then perform an opening operation, and calculate dilated_mask = fan_mask morphological dilation. The morphological dilation of fan_mask is the binary mask fan_mask after morphological dilation. Among them, the result of the dilation operation is that the bright area in the image (usually the foreground object or the highlight part) will become larger, while the dark area (usually the background or the low-light part) will remain unchanged or slightly reduced. This operation can be used to connect adjacent image elements, fill small holes, or increase the size of objects in the image. The erosion operation is the opposite of dilation, and it will make the bright area in the image smaller. By alternating between dilation and erosion, a variety of image processing effects can be achieved, such as opening operation (erosion first and then dilation) and closing operation (dilation first and then erosion), which are used to remove noise and separate objects that are in contact with each other.
[0109] Step S32: performing a bitwise AND operation on the binary mask fan_mask and the binary image bin_image after the morphological operation to obtain the segmented binary fan image fan_seg.
[0110] Step S40: determine the number of times the edge of the rectangular detection box fan_bbox passes through the border connected area of the binary fan graph fan_seg through the preset hit_num algorithm, and adjust the edge position of the rectangular detection box fan_bbox according to the number to obtain the minimum circumscribed matrix of the binary fan graph fan_seg, recorded as min_bbox.
[0111] That is, the upper left corner and the upper right corner of the binary fan image fan_seg are continuously approached by the edge lines of the rough rectangular box obtained by the previous detection. In this step, the hit_num algorithm includes steps S41-S42.
[0112] Step S41: importing the rectangular detection box fan_bbox and the binary fan image fan_seg, and passing in the straight line equation parameters based on the edge of the rectangular detection box fan_bbox.
[0113] Step S42: Starting from the leftmost or topmost side of the binary fan graph fan_seg, traverse all pixel points along the path determined by the input straight line equation. If the pixel value of the traversed pixel point is greater than the preset pixel threshold, the recorded number of passages is increased by 1. If the pixel value of the next pixel point traversed is also greater than the pixel threshold, the recorded number of passages remains unchanged.
[0114] Furthermore, in step S40, a left side line l_left, a right side line l_right, a top side line l_top, and a bottom side line l_bottom of the rectangular detection box fan_bbox are defined.
[0115] (1) The steps to adjust the left line l_left of fan_bbox are as follows:
[0116] Through the hit_num algorithm, determine the number of times hit_num that the left line l_left passes through the fan-shaped border of the binary fan graph fan_seg;
[0117] If hit_num=2, execute the following loop: coordinate value x=x-1, then continue to use the hit_num algorithm to determine the number of times the new left line l_left crosses the fan-shaped border hit_num; when hit_num is 0 or x is 0, jump out of the loop;
[0118] If hit_num=0, execute the following loop: coordinate value x=x+1, and then continue to use the hit_num algorithm to determine the number of times the new left line l_left crosses the sector border hit_num; when it is determined that the number of times the new left line l_left crosses is 1, execute x=x-1 and jump out of the loop. The adjusted latest l_left is the left line of the minimum circumscribed matrix of the sector border.
[0119] (2) The steps to adjust the right line l_right of fan_bbox are as follows:
[0120] Through the hit_num algorithm, determine the number of times hit_num that the right line l_right passes through the fan-shaped border of the binary fan graph fan_seg;
[0121] If hit_num=2, execute the following loop: coordinate value x=x+1, and then continue to use the hit_num algorithm to determine the number of times the new right line l_right crosses the fan-shaped border hit_num; when hit_num is 0 or x is the image width, jump out of the loop;
[0122] If hit_num=0, execute the following loop: coordinate value x=x-1, and then continue to use the hit_num algorithm to determine the number of times the new right line l_right crosses the sector border hit_num; when it is determined that the number of times the new right line l_right crosses is 1, execute x=x+1 and jump out of the loop. The adjusted latest l_right is the right line of the minimum circumscribed matrix of the sector border.
[0123] (3) The steps to adjust the top line l_top of fan_bbox are as follows:
[0124] Through the hit_num algorithm, determine the number of times hit_num that the top line l_top passes through the fan-shaped border of the binary fan graph fan_seg;
[0125] If hit_num=2, execute the following loop: coordinate value y=y-1, and then continue to use the hit_num algorithm to determine the number of times the new top line l_top crosses the fan-shaped border hit_num; when hit_num is 0 or y is 0, jump out of the loop;
[0126] If hit_num=0, execute the following loop: coordinate value y=y+1, and then continue to use the hit_num algorithm to determine the number of times the new top line l_top passes through the sector border hit_num; when it is determined that the number of times the new top line l_top passes through is 1, execute y=y-1 and jump out of the loop. The adjusted latest l_top is the top line of the minimum circumscribed matrix of the sector border.
[0127] (4) The steps to adjust the bottom line l_bottom of fan_bbox are as follows:
[0128] Through the hit_num algorithm, determine the number of times hit_num that the bottom line l_bottom passes through the fan-shaped border of the binary fan graph fan_seg;
[0129] If hit_num>2, execute the following loop: coordinate value y=y+1, and then continue to use the hit_num algorithm to determine the number of times the new bottom line l_bottom crosses the fan-shaped border hit_num; when hit_num is 0 or y is the image height, jump out of the loop;
[0130] If hit_num=0, execute the following loop: coordinate value y=y-1, and then continue to use the hit_num algorithm to determine the number of times the new bottom line l_bottom passes through the sector border hit_num; when it is determined that the number of times the new bottom line l_bottom passes through is greater than 1, execute y=y+1 and jump out of the loop. The adjusted latest l_bottom is the bottom line of the minimum circumscribed matrix of the sector border.
[0131] Therefore, through the above steps, the minimum outer rectangle of the binary fan graph fan_seg can be obtained, and interference and noise can be effectively removed during the processing.
[0132] Step S50: Obtain a model list including a template image of all paper cup models and their corresponding precise fan sheet specification data and precise binary mask; wherein the template image is recorded as tmpl_image, and the precise binary mask is recorded as tmpl_mask.
[0133] It should be noted that the establishment of a model list containing a fan parameter library is the basis for this method to be used in actual production. That is, first accurately determine the precise parameters of each paper cup model, then adjust the rough binary fan image fan_seg obtained based on the original image to obtain the minimum external matrix, and finally match the closest paper cup model, and obtain a more accurate size and range of the fan frame based on the determined paper cup model.
[0134] Specifically, step S50 includes steps S51-S58.
[0135] Step S51: importing a graphic design template of a target paper cup model that meets the size required for production and has a fan-shaped border.
[0136] Step S52: Clear all other contents in the graphic design template, leaving only a clean fan-shaped border.
[0137] Step S53: cutting according to the minimum circumscribed matrix of the sector frame to obtain the final template image tmpl_image of the target paper cup model. Since the sector frame referred to here is accurate, the corresponding minimum circumscribed matrix can be obtained by simple existing technology, so it will not be repeated here.
[0138] Step S54: Obtain accurate fan sheet specification data according to the template image tmpl_image. The fan sheet specification data includes: left side line, right side line, angle between two side lines, length of two side lines, lower arc vertex, upper arc vertex, center and radius of concentric circles of printing area, bleed edge line, etc.
[0139] Step S55: According to the template image tmpl_image, a precise binary mask tmpl_mask is produced, in which the pixel values of a sector-shaped border and its internal area are all 255, and the pixel values of other areas are all 0.
[0140] Step S56: Store the above tmpl_image corresponding parameters and tmpl_mask into the database.
[0141] Step S57: storing the fan specification data of the target paper cup model and the precise binary mask tmpl_mask into the database.
[0142] Step S58: Circulate steps S51-S58 until the data of all paper cup models are entered and a model list is generated. Therefore, the model list contains the relevant parameters of all paper cup models.
[0143] Step S60: Obtain a rough contour of the fan-shaped slice according to the binary mask fan_mask and the binary image bin_image, which is recorded as fan_contour.
[0144] Specifically, step S60 includes steps S61-S62.
[0145] Step S61: importing the binary image bin_image, the binary mask fan_mask, and the dilated_mask obtained in step S31.
[0146] Step S62: Obtain the fan-shaped rough contour fan_contour=mask_contour and perform bitwise AND operation on bin_image, wherein mask_contour=dilated_mask-fan_mask morphological corrosion. The fan_mask morphological corrosion is the binary mask fan_mask after the morphological corrosion processing.
[0147] Step S70: using a preset algorithm to determine the target paper cup model corresponding to the fan-shaped sheet rough contour fan_contour, denoted as cup_type; wherein the determination condition of the preset algorithm satisfies: the right side line of the fan-shaped sheet rough contour fan_contour and the right side line of the target paper cup model cup_type are closest to the same straight line.
[0148] Specifically, step S70 includes steps S71-S72.
[0149] Step S71: perform straight line search on the fan-shaped rough contour fan_contour, and add the straight lines or line segments with slope k>0 to the right line list r_line_list.
[0150] Step S72: traverse the right line list r_line_list, merge the line segments on the same straight line into a longer line segment, remove the merged line segments from the right line list r_line_list and add the merged line segments to obtain a new r_line_list with fewer line segments.
[0151] Step S73: According to a preset matching algorithm, select the right line list of the fan-shaped rough contour fan_contour
[0152] In r_line_list, find the line segment r_line'; where the line segment r_line' satisfies:
[0153] The right side of the cup_type's scalloped border is closest to the same straight line.
[0154] The matching algorithm includes steps S731-S733.
[0155] Step S731: Set the threshold epsilon (ε) for the absolute value of the slope difference between two lines, and set the initial minimum value of the absolute value of the slope difference between two lines as abs_k_min = -1.
[0156] Step S732: Execute the following loop from the model list:
[0157] Obtain the line segment line1 in the right line list r_line_list and get the slope k1; then execute the following loop:
[0158] Traverse to obtain a paper cup model type_i in the model list, and obtain the right line line2 of the sector border corresponding to the paper cup model type_i, and get the slope k2;
[0159] Calculate the absolute value of the slope difference |k1 - k2| between line1 and line2,
[0160] If abs_k_min < |k1 - k2|, then perform an overwrite assignment so that abs_k_min = |k1 - k2|, cup_type = type_i, r_line’ = line1, and then execute Step S733.
[0161] Step S733: If abs_k_min < epsilon, then return the line segment r_line’ and the target paper cup model cup_type; otherwise, it is considered that there is no corresponding paper cup model, and exit this matching loop.
[0162] Step S80: Import the template image tmpl_image of the target paper cup model cup_type, the image to be processed, and its corresponding minimum bounding rectangle min_bbox, and crop the image to be processed according to the minimum bounding rectangle min_bbox to obtain the processing region roi_image (also called the region of interest, which belongs to the core processing region).
[0163] Step S90: Scale the processing region roi_image to the same size as the template image tmpl_image, and perform a bitwise AND operation on the precise binary mask tmpl_mask and the processing region roi_image to obtain the precisely segmented sector piece of the image to be processed and its corresponding border.
[0164] To sum up, the principle of the above method is simply summarized as:
[0165] (1) First, obtain a rough bounding rectangle through the sector piece detection model, and obtain a rough sector segmentation through the sector segmentation model;
[0166] (2) Based on the sector frame included in the rough segmentation, adjust the minimum bounding rectangle accordingly;
[0167] (3) The corresponding paper cup model is determined by the straight line of the rough outline of the fan-shaped piece, so as to obtain a more accurate fan-shaped border size and range in combination with the minimum circumscribed matrix.
[0168] Each of the above steps removes a large amount of interference and noise in the original image, gradually approximates, and finally obtains an accurate frame. Therefore, the present invention can accurately determine the fan frame and model from images and files with uncertain positions, complex backgrounds, and serious noise interference, and then obtain the model of the paper cup corresponding to the precise fan, the minimum circumscribed matrix of the fan, and the right line of the corresponding fan frame, which is used for accurate segmentation of fan areas, laser die-cutting positioning, printing imposition, 3D rendering sampling, checking design problems, etc.
[0169] In an exemplary embodiment, Figure 3 It is the image to be processed, i.e. the original image, which contains a lot of noise and interference; Figure 4 It is the rough sector and rough external matrix bbox obtained after model detection and segmentation; Figure 5 This is the accurate fan-shaped diagram finally obtained after the above steps. It should be noted that Figure 3-Figure 5 The text in the figure is the printing and typesetting prompt content in the original image, and is not a specific limitation of this method.
[0170] The second aspect of the present invention provides a device 100 for accurately obtaining the border of a paper cup fan, which is used to perform fan-shaped recognition on a paper cup design drawing with a fan-shaped piece, and can accurately and automatically mark the border of the paper cup fan, and automatically generate accurate marking data. It should be noted that the implementation principle and specific implementation method of the device 100 for accurately obtaining the border of a paper cup fan can refer to the above-mentioned method for accurately obtaining the border of a paper cup fan, and will not be repeated below.
[0171] like Figure 6 As shown, the device 100 for accurately obtaining the border of a paper cup fan includes:
[0172] A rough rectangle acquisition module 10 is used to detect the imported image to be processed by using a pre-trained fan-shaped piece detection model, and output a rectangular detection frame of the fan-shaped piece, which is recorded as fan_bbox;
[0173] A rough sector segmentation module 20 is used to perform sector segmentation on the imported image to be processed by using a pre-trained sector segmentation model, and output a binary mask of the sector slice, which is recorded as fan_mask;
[0174] A binary fan acquisition module 30 is used to perform binarization processing on the image to be processed to obtain a binary image, recorded as bin_image, and segment the binary image bin_image according to the binary mask fan_mask to obtain a binary fan diagram, recorded as fan_seg;
[0175] The external matrix adjustment module 40 is used to determine the number of times the edge of the rectangular detection box fan_bbox passes through the border connected area of the binary fan image fan_seg through a preset hit_num algorithm, and adjust the edge position of the rectangular detection box fan_bbox according to the number to obtain the minimum external matrix of the binary fan image fan_seg, which is recorded as min_bbox;
[0176] The model list acquisition module 50 is used to acquire a model list including template images of all paper cup models and their corresponding precise fan sheet specification data and precise binary masks; wherein the template image is recorded as tmpl_image and the precise binary mask is recorded as tmpl_mask;
[0177] The fan contour acquisition module 60 is used to acquire the rough contour of the fan-shaped piece according to the binary mask fan_mask and the binary image bin_image, which is recorded as fan_contour;
[0178] The paper cup model matching module 70 is used to determine the target paper cup model corresponding to the fan-shaped sheet rough contour fan_contour by a preset algorithm, which is recorded as cup_type; wherein the judgment condition of the preset algorithm satisfies: the right line of the fan-shaped sheet rough contour fan_contour and the right line of the target paper cup model cup_type are closest to the same straight line;
[0179] The template parameter import module 80 is used to import the template image tmpl_image of the target paper cup model cup_type, the image to be processed and its corresponding minimum external matrix min_bbox, and cut the image to be processed according to the minimum external matrix min_bbox to obtain the processing area roi_image;
[0180] The sector-shaped precise segmentation module 90 is used to scale the processing area roi_image to the same size as the template image tmpl_image, and perform a bitwise AND operation on the precise binary mask tmpl_mask and the processing area roi_image to obtain the sector-shaped pieces of the image to be processed and their corresponding frames.
[0181] Embodiment 3
[0182] The present invention provides a terminal, which includes a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, each step of the method for accurately obtaining a paper cup fan frame as described in any one of the above-mentioned implementation modes is implemented.
[0183] Embodiment 4
[0184] The present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for accurately obtaining a paper cup fan frame as described in any one of the above-mentioned implementation modes are implemented.
[0185] Embodiment 5
[0186] The present invention provides a computer program product, including a computer program or instructions, which, when processed and executed, implements the various steps of the method for accurately obtaining a paper cup fan frame as described in any one of the above-mentioned implementation modes.
[0187] In summary, the method and device for accurately obtaining the border of the paper cup fan provided by the present invention first obtains a rough external matrix through the fan-shaped piece detection model, and obtains a rough fan-shaped segmentation through the fan-shaped segmentation model. Based on the fan-shaped frame contained in the rough segmentation, the minimum external matrix is adjusted accordingly, and finally the corresponding paper cup model is judged by the straight line of the rough outline of the fan-shaped piece, so as to obtain a more accurate fan-shaped border size and range in combination with the minimum external matrix. Each of the above steps removes a large amount of interference and noise in the original image, gradually approximates, and finally obtains an accurate border. Among them, the model list containing the fan-shaped parameter library is the basis for the actual production of this method, and the paper cup model is judged by the straight line, which can quickly and efficiently determine the model, thereby improving the processing efficiency.
[0188] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0189] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0190] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0191] In the embodiments provided by the present invention, it should be understood that the disclosed systems or devices / terminal equipment and methods can be implemented in other ways. For example, the system or device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the system or unit can be electrical, mechanical or other forms.
[0192] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0193] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0194] The present invention is not limited to what is described in the specification and implementation modes, and therefore additional advantages and modifications can be easily realized by those skilled in the art. Therefore, without departing from the spirit and scope of the general concept defined by the claims and their equivalents, the present invention is not limited to the specific details, representative devices, and illustrative examples shown and described herein.
Claims
1. A method for accurately obtaining the frame of a paper cup fan, characterized in that: include: Step S10: Detect the imported image to be processed by using a pre-trained fan-shaped piece detection model, and output a rectangular detection box of the fan-shaped piece, which is recorded as fan_bbox; Step S20: performing fan-shaped segmentation on the imported image to be processed by using a pre-trained fan-shaped segmentation model, and outputting a binary mask of the fan-shaped slice, which is recorded as fan_mask; Step S30: binarizing the image to be processed to obtain a binarized image, recorded as bin_image, and segmenting the binarized image bin_image according to the binarized mask fan_mask to obtain a binary fan-shaped image, recorded as fan_seg; Step S40: determining the number of times the edge of the rectangular detection box fan_bbox passes through the border connected area of the binary fan image fan_seg by a preset hit_num algorithm, and adjusting the edge position of the rectangular detection box fan_bbox according to the number, to obtain the minimum circumscribed matrix of the binary fan image fan_seg, recorded as min_bbox; Step S50: obtaining a model list including a template image of all paper cup models, precise fan sheet specification data corresponding to the template image, and a precise binary mask corresponding to the template image; wherein the template image is recorded as tmpl_image, and the precise binary mask is recorded as tmpl_mask; Step S60: obtaining a rough contour of the fan-shaped piece according to the binary mask fan_mask and the binary image bin_image, which is recorded as fan_contour; Step S70: determining the target paper cup model corresponding to the fan-shaped sheet rough contour fan_contour by a preset algorithm, which is recorded as cup_type; wherein the determination condition of the preset algorithm satisfies: the right side line of the fan-shaped sheet rough contour fan_contour and the right side line of the target paper cup model cup_type are closest to the same straight line; Step S80: importing the template image tmpl_image of the target paper cup model cup_type, the image to be processed and its corresponding minimum external matrix min_bbox, and cutting the image to be processed according to the minimum external matrix min_bbox to obtain the processing area roi_image; Step S90: scaling the processing region roi_image to the same size as the template image tmpl_image, and performing a bitwise AND operation on the precise binary mask tmpl_mask and the processing region roi_image to obtain the precisely segmented sector pieces of the image to be processed and their corresponding borders.
2. The method for accurately obtaining the frame of a paper cup fan as claimed in claim 1, characterized in that: The step S30 comprises: Step S31: performing a morphological operation on the binary mask fan_mask, first performing a closing operation and then performing an opening operation, to calculate and obtain a morphologically expanded fan_mask, which is a dilated_mask; Step S32: performing a bitwise AND operation on the binary mask fan_mask and the binary image bin_image after the morphological operation to obtain the segmented binary fan image fan_seg.
3. The method for accurately obtaining the frame of a paper cup fan as claimed in claim 1, characterized in that: In step S40, the hit_num algorithm includes: Step S41: importing the rectangular detection box fan_bbox and the binary fan image fan_seg, and passing in the straight line equation parameters based on the edge of the rectangular detection box fan_bbox; Step S42: Starting from the leftmost or topmost side of the binary fan graph fan_seg, traverse all pixel points along the path determined by the input straight line equation. If the pixel value of the traversed pixel point is greater than the preset pixel threshold, the recorded number of passages is increased by 1. If the pixel value of the next pixel point traversed is also greater than the pixel threshold, the recorded number of passages remains unchanged.
4. The method for accurately obtaining the frame of a paper cup fan as claimed in claim 3, characterized in that: In the step S40, a left line l_left, a right line l_right, a top line l_top, and a bottom line l_bottom of a rectangular detection box fan_bbox are defined; Among them, the steps to adjust the left line l_left of the rectangular detection box fan_bbox are as follows: By using the hit_num algorithm, determine the number of times hit_num that the left line l_left passes through the fan-shaped border of the binary fan-shaped image fan_seg; If hit_num=2, execute the following loop: coordinate value x=x-1, then continue to use the hit_num algorithm to determine the number of times hit_num that the new left line l_left crosses the fan-shaped border; when hit_num is 0 or x is 0, jump out of the loop; If hit_num=0, execute the following loop: coordinate value x=x+1, and then continue to use the hit_num algorithm to determine the number of times hit_num that the new left line l_left crosses the sector border; when it is determined that the number of times the new left line l_left crosses is 1, execute x=x-1 and jump out of the loop, and the latest l_left after adjustment is the left line of the minimum circumscribed matrix of the sector border; Among them, the steps to adjust the right line l_right of the rectangular detection box fan_bbox are as follows: By using the hit_num algorithm, determine the number of times hit_num that the right line l_right passes through the fan-shaped border of the binary fan-shaped image fan_seg; If hit_num=2, execute the following loop: coordinate value x=x+1, then continue to determine the number of times hit_num that the new right line l_right crosses the fan-shaped border through the hit_num algorithm; when hit_num is 0 or x is the image width, jump out of the loop; If hit_num=0, execute the following loop: coordinate value x=x-1, and then continue to use the hit_num algorithm to determine the number of times hit_num that the new right line l_right crosses the sector border; when it is determined that the number of times the new right line l_right crosses is 1, execute x=x+1, and jump out of the loop, and the latest adjusted l_right is the right line of the minimum circumscribed matrix of the sector border; Among them, the steps to adjust the upper edge l_top of the rectangular detection box fan_bbox are as follows: By using the hit_num algorithm, the number of times hit_num that the top line l_top passes through the fan-shaped border of the binary fan-shaped image fan_seg is determined; If hit_num=2, execute the following loop: coordinate value y=y-1, then continue to determine the number of times hit_num that the new top line l_top passes through the fan-shaped border through the hit_num algorithm; when hit_num is 0 or y is 0, jump out of the loop; If hit_num=0, execute the following loop: coordinate value y=y+1, and then continue to determine the number of times hit_num that the new upper edge line l_top passes through the sector border through the hit_num algorithm; when it is determined that the number of times the new upper edge line l_top passes through is 1, execute y=y-1, and jump out of the loop, and the latest l_top after adjustment is the upper edge line of the minimum circumscribed matrix of the sector border; Among them, the steps to adjust the bottom line l_bottom of the rectangular detection box fan_bbox are as follows: By using the hit_num algorithm, determine the number of times hit_num that the bottom line l_bottom passes through the fan-shaped border of the binary fan-shaped graph fan_seg; If hit_num>2, execute the following loop: coordinate value y=y+1, then continue to determine the number of times hit_num that the new bottom line l_bottom passes through the fan-shaped border through the hit_num algorithm; when hit_num is 0 or y is the image height, jump out of the loop; If hit_num=0, execute the following loop: coordinate value y=y-1, and then continue to use the hit_num algorithm to determine the number of times hit_num that the new bottom line l_bottom passes through the fan-shaped border; when it is determined that the number of times the new bottom line l_bottom passes through is greater than 1, execute y=y+1 and jump out of the loop. The adjusted latest l_bottom is the bottom line of the minimum circumscribed matrix of the fan-shaped border.
5. The method for accurately obtaining the frame of a paper cup fan as claimed in claim 1, characterized in that: The step S50 comprises: Step S51: importing a graphic design template of a target paper cup model that meets the required production dimensions and has a fan-shaped border; Step S52: clear all other contents in the graphic design template, leaving only a clean fan-shaped border; Step S53: cutting according to the minimum circumscribed matrix of the sector frame to obtain the final template image tmpl_image of the target paper cup model; Step S54: obtaining accurate fan sheet specification data according to the template image tmpl_image; the fan sheet specification data includes: left side line, right side line, angle between two side lines, length of two side lines, lower arc vertex, upper arc vertex, center and radius of concentric circles of printing area, and bleeding position edge line; Step S55: according to the template image tmpl_image, a precise binary mask tmpl_mask is produced, in which the pixel values of a sector-shaped border and its inner area are all 255, and the pixel values of other areas are all 0; Step S56: storing the above tmpl_image corresponding parameters and tmpl_mask into the database; Step S57: storing the fan specification data and the precise binary mask tmpl_mask of the target paper cup model into a database; Step S58: Execute the steps S51-S58 in a loop until the data of all paper cup models are entered and a model list is generated.
6. The method for accurately obtaining the frame of a paper cup fan as claimed in claim 2, characterized in that: The step S60 comprises: Step S61: importing the binarized image bin_image, the binarized mask fan_mask and the dilated_mask; Step S62: Obtain a fan-shaped rough contour fan_contour, wherein the fan-shaped rough contour fan_contour is obtained by performing a bitwise AND operation on mask_contour and bin_image, and the mask_contour is obtained by subtracting the morphologically eroded fan_mask from the dilated_mask.
7. The method for accurately obtaining the frame of a paper cup fan as claimed in claim 6, characterized in that: The step S70 includes: Step S71: perform straight line search on the fan-shaped rough contour fan_contour, and add the straight lines or line segments with slope k>0 to the right line list r_line_list; Step S72: traverse the right line list r_line_list, merge the line segments on the same straight line into a longer line segment, remove the merged line segments from the right line list r_line_list and add the merged line segments to obtain a new r_line_list with fewer line segments; Step S73: Find the line segment r_line' from the right line list r_line_list of the fan-shaped rough contour fan_contour according to a preset matching algorithm; wherein the line segment r_line' satisfies: being closest to the same straight line as the right line of the fan-shaped frame of the target paper cup model cup_type.
8. The method for accurately obtaining the frame of a paper cup fan as claimed in claim 7, characterized in that: The matching algorithm includes: Step S731: setting a threshold value epsilon of the absolute value of the difference between the slopes of the two straight lines, and setting an initial minimum value of the absolute value of the difference between the slopes of the two straight lines to abs_k_min=-1; Step S732: Execute the following loop from the model list: Get the line segment line1 in the right line list r_line_list, and obtain the slope k1; Traverse a paper cup model type_i in the model list, obtain the right line line2 of the fan-shaped border corresponding to the paper cup model type_i, and obtain the slope k2; Find the absolute value of the difference in slope between line1 and line2 |k1-k2|; If abs_k_min < |k1 - k2|, then the covering assignment makes abs_k_min = |k1 - k2|, cup_type = type_i, r_line’ = line1, and step S733 is executed; Step S733: If abs_k_min < epsilon, then return the line segment r_line’ and the target paper cup model cup_type; otherwise, there is no corresponding paper cup model, and this matching loop is exited.
9. A device for accurately obtaining the frame of a paper cup fan, characterized in that: Including: A rough rectangle acquisition module, which is used to detect the imported image to be processed through a pre-trained fan-shaped piece detection model, and output a rectangular detection frame of the fan-shaped piece, denoted as fan_bbox; A rough fan-shaped segmentation module, which is used to perform fan-shaped segmentation on the imported image to be processed through a pre-trained fan-shaped segmentation model, and output a binary mask of the fan-shaped piece, denoted as fan_mask; A binary fan-shaped acquisition module, which is used to binarize the image to be processed to obtain a binary image, denoted as bin_image, and segment the binary image bin_image according to the binary mask fan_mask to obtain a binary fan-shaped image, denoted as fan_seg; An external circumscribed matrix adjustment module, which is used to judge the number of times the side line of the rectangular detection frame fan_bbox passes through the border connection area of the binary fan-shaped image fan_seg through a preset hit_num algorithm, and adjust the position of the side line of the rectangular detection frame fan_bbox according to this number of times to obtain the minimum external circumscribed matrix of the binary fan-shaped image fan_seg, denoted as min_bbox; A model list acquisition module, which is used to acquire a model list including template images of all paper cup models, the corresponding precise fan-shaped piece specification data of the template images, and the corresponding precise binary masks of the template images; among them, the template image is denoted as tmpl_image, and the precise binary mask is denoted as tmpl_mask; A fan-shaped contour acquisition module, which is used to acquire a rough fan-shaped piece contour according to the binary mask fan_mask and the binary image bin_image, denoted as fan_contour; A paper cup model matching module, which is used to judge the target paper cup model corresponding to the rough fan-shaped piece contour fan_contour through a preset algorithm, denoted as cup_type; among them, the judgment condition of this preset algorithm is satisfied: the right side line of the rough fan-shaped piece contour fan_contour is closest to the same straight line as the right side line of the target paper cup model cup_type; A template parameter import module, which is used to import the template image tmpl_image of the target paper cup model cup_type, the image to be processed and its corresponding minimum external circumscribed matrix min_bbox, and crop the image to be processed according to the minimum external circumscribed matrix min_bbox to obtain a processing area roi_image; The sector-shaped precise segmentation module is used to scale the processing area roi_image to the same size as the template image tmpl_image, and perform a bitwise AND operation on the precise binary mask tmpl_mask and the processing area roi_image to obtain the sector-shaped pieces of the image to be processed and their corresponding borders.
Citation Information
Patent Citations
Hollow circular pointer type instrument identification method and system
CN111612836A
Mask R-CNN-based material label extraction method and system
CN115482538A