Region identification method and device, equipment and storage medium
By extracting and correcting lines in the image and identifying the product appearance area with the appearance proportional data, the problem of low recognition accuracy in the prior art is solved, and the recognition effect of uneven grayscale values and complex background images is improved.
Patent Information
- Application Number
- CN202411140982.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2025-01-14
AI Technical Summary
When identifying the appearance area of the product, the accuracy of images with uneven grayscale values or small differences in the foreground background is poor, and the accuracy of image recognition with complex background textures and many interference lines is also low.
By obtaining the appearance proportional data of the image to be identified and the target product, extracting the lines in the image, determining the target edge lines, calculating the offset angle based on these lines for image correction, extracting the lines in the corrected image, and identifying the product based on the appearance proportional data. appearance area.
The accuracy of appearance recognition of images with uneven grayscale values and small differences in foreground backgrounds is improved, and the accuracy of appearance recognition of images with complex background textures and many interference lines is enhanced.
Smart Images

Figure CN119313864A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing, and in particular to a region recognition method, device, equipment and storage medium. Background Art
[0002] In the manufacturing process of electronic products, it is usually necessary to inspect the appearance of the product, and the premise of inspecting the appearance of the product is to identify the product appearance area. Common product appearance area recognition methods include appearance area recognition methods based on connected domains and appearance area extraction methods based on line features. However, the appearance area recognition method based on connected domains has poor appearance recognition accuracy for images with uneven imaging grayscale values or small differences from the foreground and background, and the appearance area extraction method based on line features has poor appearance recognition accuracy for images with complex background textures and many interference lines. Therefore, how to identify the accurate product appearance area to meet the needs of appearance inspection has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The present disclosure provides a region identification method, device, equipment and storage medium to at least solve the above technical problems existing in the prior art.
[0004] According to a first aspect of the present disclosure, a region identification method is provided, the method comprising:
[0005] Obtaining an image to be recognized, and obtaining appearance ratio data of a target product;
[0006] Extracting a plurality of first lines from the image to be recognized;
[0007] Determine a target first line from the plurality of first lines according to the attribute information of each first line, wherein the target first line is a line representing an edge of the target product;
[0008] Determining a deviation angle corresponding to the image to be identified based on the first target line, and performing correction processing on the image to be identified based on the deviation angle to obtain a corrected image;
[0009] extracting a plurality of second lines in the corrected image;
[0010] Based on the appearance ratio data, a plurality of target edge lines corresponding to the target product are determined from the plurality of second lines, and an appearance region of the target product is identified based on the plurality of target edge lines.
[0011] In one possible implementation, the determining, based on the appearance ratio data, a plurality of target edge lines corresponding to the target product from the plurality of second lines comprises:
[0012] Classifying each second line according to the positional relationship between each second line and the target center position to obtain a plurality of line sets, wherein the line sets include a bottom line set, a top line set, a left line set, and a right line set;
[0013] Based on the multiple line sets and the appearance ratio data, multiple target edge lines corresponding to the target product are determined.
[0014] In one possible implementation, the determining a plurality of target edge lines corresponding to the target product based on the plurality of line sets and the appearance ratio data includes:
[0015] Selecting second lines from each line set to form a plurality of line groups, and determining the aspect ratio of the area defined by each second line in each line group;
[0016] Each of the line groups includes a line from each line set, and the second lines from the same line set included in different line groups are different;
[0017] A line group corresponding to a minimum difference between the aspect ratio and the ratio data is determined as a target line group, and each second line in the target line group is determined as a plurality of target edge lines corresponding to the target product.
[0018] In one possible implementation manner, the attribute information of the first line includes the length of the first line and position information in the image to be recognized;
[0019] The step of determining a target first line from the plurality of first lines according to the attribute information of each first line includes:
[0020] filtering the first lines at the edge of the image to be identified according to the position information of each of the first lines in the image to be identified;
[0021] The line with the longest length among the first lines remaining after filtering is determined as the target first line.
[0022] In one possible implementation manner, determining the offset angle corresponding to the image to be recognized based on the target first line includes:
[0023] Obtaining position information of the endpoint of the first target line in the image to be identified;
[0024] Determine the slope corresponding to the first target line based on the position information;
[0025] The offset angle corresponding to the image to be recognized is calculated according to the slope.
[0026] In one possible implementation manner, the correcting the image to be recognized based on the offset angle to obtain a corrected image includes:
[0027] If the target first line is a line representing the top edge or the bottom edge of the target product, the image to be identified is rotated clockwise by the offset angle to obtain a corrected image;
[0028] If the target first line is a line representing the left edge or the right edge of the target product, the image to be identified is rotated 90° clockwise minus the difference angle of the offset angle to obtain a corrected image.
[0029] In one possible implementation, the appearance ratio data includes an appearance aspect ratio of the target product.
[0030] According to a second aspect of the present disclosure, a region identification device is provided, the device comprising:
[0031] A data acquisition module is used to acquire the image to be recognized and the appearance ratio data of the target product;
[0032] A first line extraction module, used to extract a plurality of first lines in the image to be identified;
[0033] An edge determination module, configured to determine a target first line from the plurality of first lines according to attribute information of each first line, wherein the target first line is a line representing an edge of the target product;
[0034] An image correction module, used to determine the offset angle corresponding to the image to be identified based on the target first line, and perform correction processing on the image to be identified based on the offset angle to obtain a corrected image;
[0035] A second line extraction module, used to extract a plurality of second lines in the corrected image;
[0036] The region identification module is used to determine a plurality of target edge lines corresponding to the target product from the plurality of second lines based on the appearance ratio data, and to identify the appearance region of the target product based on the plurality of target edge lines.
[0037] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0038] at least one processor; and
[0039] a memory communicatively connected to the at least one processor; wherein,
[0040] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.
[0041] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method described in the present disclosure.
[0042] The region recognition method, device, equipment and storage medium disclosed in the present invention obtain an image to be recognized, and obtain the appearance ratio data of the target product, extract multiple first lines in the image to be recognized, determine the target first line from the multiple first lines according to the attribute information of each first line, the target first line is a line that characterizes the edge of the target product, determine the offset angle corresponding to the image to be recognized based on the target first line, and perform correction processing on the image to be recognized based on the offset angle to obtain a corrected image, extract multiple second lines in the corrected image, determine multiple target edge lines corresponding to the target product from the multiple second lines based on the appearance ratio data, and recognize the appearance region of the target product based on the multiple target edge lines. That is, the first line can be extracted using the appearance ratio data of the target product, and then the image to be recognized can be corrected based on the first line to extract the second line, and the appearance region of the target product can be further determined using the second line and the appearance ratio data, thereby improving the appearance recognition accuracy of images with uneven imaging grayscale values and small foreground and background differences, and by extracting the appearance region lines step by step, the appearance recognition accuracy of images with complex background textures and many interference lines is also improved.
[0043] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:
[0045] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0046] Figure 1 A schematic diagram of the implementation process of the region identification method provided by the embodiment of the present disclosure is shown;
[0047] Figure 2 A schematic diagram of the D surface of a laptop computer provided by an embodiment of the present disclosure is shown;
[0048] Figure 3 A schematic diagram of the D surface of another notebook computer provided by an embodiment of the present disclosure is shown;
[0049] Figure 4 A schematic diagram of the structure of a region identification device provided by an embodiment of the present disclosure is shown;
[0050] Figure 5 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0051] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0052] Since the commonly used appearance region recognition methods have poor appearance recognition accuracy for images with uneven imaging grayscale values or little difference from the foreground and background, and also have poor appearance recognition accuracy for images with complex background textures and many interference lines, in order to identify accurate product appearance regions and meet appearance inspection requirements, the embodiments of the present disclosure provide a region recognition method, device, equipment, and storage medium. The region recognition method provided by the present disclosure can be applied to image processing devices, such as computers and tablet computers.
[0053] The technical solution of the embodiment of the present disclosure will be described below in conjunction with the drawings in the embodiment of the present disclosure.
[0054] Figure 1 FIG. 4 shows a schematic diagram of the implementation process of the region identification method provided by the embodiment of the present disclosure, such as Figure 1 As shown, the method includes:
[0055] S101, obtaining an image to be recognized, and obtaining appearance ratio data of a target product.
[0056] In the present disclosure, an image acquisition device may be used to acquire an appearance image of a target product as an image to be identified. The image acquisition device may be a camera or a mobile phone camera, etc. The target product may be a mobile phone, a computer, or a tablet computer electronic product. For example, if the target product is a laptop computer, an image acquisition device may be used to acquire an appearance image of the D surface of the laptop computer as an image to be identified. The D surface of the laptop computer refers to the bottom surface of the laptop computer, and the D surface of the laptop computer is provided with components such as heat dissipation holes, a battery compartment, and an anti-skid pad.
[0057] The appearance ratio data of the target product may include the appearance aspect ratio of the target product. For example, if the target product is a laptop computer, the appearance ratio data of the target product may include the aspect ratio of the D surface of the laptop computer.
[0058] In the present disclosure, the appearance ratio data of the target product may be acquired in advance through actual manual measurement, or the appearance ratio data of the target product may be acquired from the product design document data of the target product.
[0059] S102: extracting a plurality of first lines from the image to be recognized.
[0060] In the present disclosure, edge detection, line detection or morphological detection methods can be used to extract line features of the image to be identified to obtain multiple first lines in the image to be identified. For example, the FastDetectLine (an efficient line feature extraction method) algorithm can be used to extract line segments in the image to be identified as first lines.
[0061] S103 , determining a target first line from the plurality of first lines according to the attribute information of each first line, wherein the target first line is a line representing an edge of the target product.
[0062] In the present disclosure, a target first line representing the edge of the target product can be determined from multiple first lines according to the characteristics of the target product itself and the attribute information of each first line. For example, taking a laptop as an example, Figure 2 FIG. 4 shows a schematic diagram of a D surface of a notebook computer provided by an embodiment of the present disclosure, such as Figure 2 As shown, the bottom line 201 of the D surface of the laptop computer 210 is relatively long, and the shorter first lines can be filtered out according to the length information of the first lines, and the longest first line is retained as the target first line.
[0063] In a possible implementation manner, the attribute information of the first line includes the length of the first line and position information in the image to be recognized; and determining the target first line from the plurality of first lines according to the attribute information of each first line may include steps A1-A2:
[0064] Step A1: filtering first lines at the edge of the image to be identified according to position information of each of the first lines in the image to be identified.
[0065] like Figure 2As shown, the image to be identified includes a laptop image area and a background area. The first line 201 is the edge line of the laptop computer. Usually, the edge area of the image to be identified has nothing to do with the laptop computer. Therefore, the first line at the edge of the image to be identified can be filtered out according to the position information of the first line in the image to be identified.
[0066] Step A2: determine the line with the longest length among the first lines remaining after filtering as the target first line.
[0067] Usually, the edge line of the target product is long, and the line with the longest length can be selected from the first lines remaining after filtering as the target first line.
[0068] S104, determining a deviation angle corresponding to the image to be identified based on the target first line, and performing correction processing on the image to be identified based on the deviation angle to obtain a corrected image.
[0069] In the present disclosure, the image area corresponding to the target product in the image to be identified may be offset, and the offset is not conducive to extracting the accurate product appearance area. Therefore, the image area of the target product can be corrected first.
[0070] In a possible implementation manner, determining the offset angle corresponding to the image to be identified based on the target first line may include steps B1-B3:
[0071] Step B1, obtaining the position information of the endpoint of the first target line in the image to be identified.
[0072] In the present disclosure, the position coordinates of the pixel points corresponding to the two endpoints of the first target line in the image to be identified can be obtained as the position information of the endpoints of the first target line in the image to be identified.
[0073] Step B2: determining the slope corresponding to the target first line based on the position information.
[0074] In the present disclosure, the following formula may be used to determine the slope corresponding to the first target line based on the position information:
[0075]
[0076] Among them, k represents the slope corresponding to the first line of the target, start x and start y Respectively represent the horizontal and vertical coordinates of the starting endpoint of the first line of the target, end x and end y Respectively represent the horizontal and vertical coordinates of the endpoint of the first line of the target.
[0077] Step B3: calculating the offset angle corresponding to the image to be identified according to the slope.
[0078] In the present disclosure, the inverse tangent value of the slope can be calculated, and the angle corresponding to the inverse tangent value of the slope is used as the offset angle corresponding to the image to be identified. For example, if the slope is k, the offset angle corresponding to the image to be identified can be calculated according to the slope using the following formula:
[0079] Dcover_angle = arctan (k)
[0080] Wherein, Dcover_angle represents the offset angle corresponding to the image to be identified.
[0081] In the present disclosure, after calculating the offset angle corresponding to the image to be identified, the image to be identified can be rotated by the offset angle to complete the correction processing of the image to be identified, and the image to be identified obtained after the rotation is used as the corrected image. In a possible implementation, the correction processing of the image to be identified based on the offset angle to obtain the corrected image may include steps C1-C2:
[0082] Step C1: if the target first line is a line representing the top edge or the bottom edge of the target product, the image to be identified is rotated clockwise by the offset angle to obtain a corrected image.
[0083] For example, Figure 3 FIG. 2 shows another D-surface schematic diagram of a notebook computer provided by an embodiment of the present disclosure. Figure 3 The D side diagram of the laptop shown is for Figure 2 The D-surface schematic diagram of the laptop shown in the figure is the corrected image obtained by rotating the offset angle. Figure 2 In the example, the target first line 201 is the line at the bottom edge of the target product, so the image to be identified can be rotated clockwise by an offset angle to obtain a corrected image. Figure 2 compared to, Figure 3 The bottom edge of the image of the laptop is parallel to the bottom edge of the image.
[0084] Step C2: if the target first line is a line representing the left edge or the right edge of the target product, the image to be identified is rotated 90° clockwise minus the difference angle of the offset angle to obtain a corrected image.
[0085] In the present disclosure, if the first target line is a line representing the left edge or the right edge of the target product, the offset angle calculated according to the method experienced in the present disclosure is the acute angle of the angle between the line of the left edge or the right edge of the target product and the horizontal coordinate axis. Therefore, the difference angle after the image to be identified is rotated 90° clockwise minus the offset angle is the angle between the bottom edge of the image of the target product and the horizontal coordinate axis of the image to be identified. Therefore, in order to make the bottom edge of the image of the target product and the horizontal coordinate axis of the image to be identified parallel to each other, the image to be identified can be rotated 90° clockwise minus the difference angle after the offset angle is subtracted to obtain a corrected image.
[0086] S105: extracting a plurality of second lines from the corrected image.
[0087] In the present disclosure, edge detection, line detection or morphological detection methods can be used to extract line features of the corrected image to obtain multiple second lines in the image to be identified. For example, the FastDetectLine algorithm can be used to extract line segments in the corrected image as second lines.
[0088] S106 , based on the appearance ratio data, determining a plurality of target edge lines corresponding to the target product from the plurality of second lines, and identifying an appearance region of the target product based on the plurality of target edge lines.
[0089] The region recognition method disclosed in the present invention is adopted to obtain an image to be recognized, and to obtain the appearance ratio data of a target product, extract multiple first lines in the image to be recognized, determine a target first line from the multiple first lines according to the attribute information of each first line, the target first line is a line characterizing the edge of the target product, determine the offset angle corresponding to the image to be recognized based on the target first line, and perform correction processing on the image to be recognized based on the offset angle to obtain a corrected image, extract multiple second lines in the corrected image, determine multiple target edge lines corresponding to the target product from the multiple second lines based on the appearance ratio data, and recognize the appearance region of the target product based on the multiple target edge lines. That is, the first line can be extracted using the appearance ratio data of the target product, and then the image to be recognized can be corrected based on the first line to extract the second line, and the appearance region of the target product can be further determined using the second line and the appearance ratio data, thereby improving the appearance recognition accuracy of images with uneven imaging grayscale values and small foreground and background differences, and by extracting the appearance region lines step by step, the appearance recognition accuracy of images with complex background textures and many interference lines is also improved.
[0090] In a possible implementation manner, determining a plurality of target edge lines corresponding to the target product from the plurality of second lines based on the appearance ratio data may include steps D1-D2:
[0091] Step D1, classifying each second line according to the positional relationship between each second line and the target center position to obtain multiple line sets, wherein the line sets include a bottom line set, a top line set, a left line set and a right line set.
[0092] In the present disclosure, the target center position may be the center position point of the corrected image. In the present disclosure, each second line may be classified according to the positional relationship between each second line and the center position point of the corrected image. For example, the second lines located to the left of the center position point of the corrected image may constitute a left line set, the second lines located to the right of the center position point of the corrected image may constitute a right line set, the second lines located above the center position point of the corrected image may constitute a top line set, and the second lines located below the center position point of the corrected image may constitute a bottom line set.
[0093] In the present disclosure, a coordinate system can be established with the upper left corner of the corrected image as the coordinate origin, the horizontal edge of the corrected image as the horizontal axis, and the vertical edge of the corrected image as the vertical axis. Then the coordinates of the center point can be calculated using the following formula:
[0094] Ce1nte.xima,ge_dst_rotate.width / 2
[0095] center.y=image_dst_rotate.height / 2
[0096] Among them, center.x and center.y are the horizontal and vertical coordinates of the center point respectively, image_dst_rotate.width represents the width of the corrected image, and image_dst_rotate.height represents the height of the corrected image.
[0097] In the present disclosure, the endpoint coordinates of the second line can be calculated using the following formula:
[0098] line_x_max(i)=max(linei.start_x,linei.end_x)
[0099] line_y_max(i)=max(linei.start_y,linei.end_y)
[0100] line_x_min(i)=min(linei.start_x,linei.end_x)
[0101] line_y_min(i)=min(linei.start_y,linei.end_y)
[0102] Among them, line_x_max(i) is the horizontal coordinate of the right endpoint of the i-th second line, line_y_max(i) is the vertical coordinate of the right endpoint of the i-th second line, line_x_min(i) is the horizontal coordinate of the left endpoint of the i-th second line, line_y_min(i) is the vertical coordinate of the left endpoint of the i-th second line, linei.start_x is the horizontal coordinate of the starting endpoint of the i-th second line, linei.start_y is the vertical coordinate of the starting endpoint of the i-th second line, linei.end_x is the horizontal coordinate of the ending endpoint of the i-th second line, and linei.end_y is the vertical coordinate of the ending endpoint of the i-th second line.
[0103] In the present disclosure, the following formula can be used to classify each second line to obtain multiple line sets:
[0104]
[0105] Among them, abs() means taking the absolute value, top_line.push(linei) means that the i-th second line belongs to the top line set, bottom_line.push(linei) means that the i-th second line belongs to the bottom line set, left_line.push(linei) means that the i-th second line belongs to the left line set, right_line.push(linei) means that the i-th second line belongs to the right line set, linei means the i-th second line, Tx is the difference value threshold on both sides of the horizontal direction line, Ty is the difference value threshold on both sides of the vertical direction line, Tx and Ty are generally set to 30 pixels, Tx and Ty can be used to determine whether the second line is an approximate horizontal line and vertical line, respectively.
[0106] Step D2: determining a plurality of target edge lines corresponding to the target product based on the plurality of line sets and the appearance ratio data.
[0107] In a possible implementation manner, determining a plurality of target edge lines corresponding to the target product based on the plurality of line sets and the appearance ratio data may include steps E1-E3:
[0108] Step E1, selecting second lines from each line set to form multiple line groups, and determining the aspect ratio of the area determined by each second line in each line group, each of the line groups includes a line from each line set, and the second lines from the same line set included in different line groups are different.
[0109] In the present disclosure, the second lines can be taken out one by one from each t line set, and the taken out second lines are used as the upper, lower, left and right boundaries of the region to calculate the aspect ratio of the region. For example, the second lines tl, bl, ll and rl can be taken out from the top line set, the bottom line set, the left line set and the right line set, and the second lines tl, bl, ll and rl can be used as the upper, lower, left and right boundaries of the region, and then the aspect ratio of the region is calculated using the following method:
[0110] width_dst=min(rl.start_x,rl.end_x)-max(ll.start_x,ll.end_x)
[0111] height_dst=min(bl.start_y,bl.end_y)-max(rl.start_y,rl.end_y)
[0112] aspectRatio=width_dst / height_dst
[0113] Among them, width_dst is the width of the region, height_dst is the height of the region, aspectRatio is the aspect ratio of the region, rl.start_x and rl.end_x are the horizontal coordinates of the two endpoints of the second line rl, ll.start_x and ll.end_x are the horizontal coordinates of the two endpoints of the second line ll, bl.start_y and bl.end_y are the vertical coordinates of the two endpoints of the second line bl, and rl.start_y and rl.end_y are the vertical coordinates of the two endpoints of the second line rl.
[0114] In the present disclosure, all second lines in the line set may be randomly combined in the above manner, and the aspect ratio of the randomly combined area may be calculated, and each random combination is performed by combining four second lines from different line sets.
[0115] Step E2: determining a line group corresponding to a minimum difference between the aspect ratio and the ratio data as a target line group, and determining each second line in the target line group as a plurality of target edge lines corresponding to the target product.
[0116] After obtaining the aspect ratios of the areas corresponding to multiple line combinations, the difference between the aspect ratios of the areas corresponding to each line combination and the aspect ratios of the image to be identified in the ratio data can be compared, and the four second lines corresponding to the aspect ratios with the smallest differences can be determined as the target edge lines of the target product.
[0117] In the present disclosure, the following formula can be used to determine the target edge line:
[0118] true_top_line=tl,true_bottom_line=bl,true_left_line=ll,true_right_line
[0119] =rl,if abs(aspectRatio-aspectRatioTemple) <ratioThreshold
[0120] Among them, true_top_line is the target edge line representing the upper edge of the target product, true_bottom_line is the target edge line representing the lower edge of the target product, true_left_line is the target edge line representing the left edge of the target product, true_right_line is the target edge line representing the right edge of the target product, aspectRatioTemple is the aspect ratio of the target product in the ratio data, ratioThreshold is the aspect ratio difference threshold, and ratioThreshold can generally be set to 0.015 or 0.016.
[0121] In the present disclosure, if the calculated difference between the aspect ratio of a region and the aspect ratio in the ratio data is greater than the aspect ratio difference threshold, the difference between the aspect ratio of the next region and the aspect ratio in the ratio data can be repeatedly calculated until a region with a difference less than the aspect ratio difference threshold is found.
[0122] After determining the four target edge lines corresponding to the target product, the intersection points of each target edge line can be obtained, and the minimum enclosing rectangle can be determined based on the four intersection points. The minimum enclosing rectangle can be determined as the area corresponding to the target product. Alternatively, the area formed by the four target edge lines corresponding to the target product can be determined as the area corresponding to the target product.
[0123] The adoption of this method not only solves the problem of low accuracy in extracting the target product area due to uneven imaging grayscale values or low color distinction between the target area and the background area, but also eliminates the influence of a large number of interference lines on the extraction of the target product area. Moreover, the method provided by the present invention can support the extraction of product areas of various colors such as silver, blue and black, thereby improving the compatibility of product area extraction.
[0124] Based on the same inventive concept, according to the region identification method provided by the above embodiment of the present disclosure, correspondingly, another embodiment of the present disclosure further provides a region identification device, whose structural schematic diagram is shown as follows: Figure 4 As shown, specifically including:
[0125] The data acquisition module 401 is used to acquire the image to be recognized and acquire the appearance ratio data of the target product;
[0126] A first line extraction module 402, used to extract a plurality of first lines in the image to be recognized;
[0127] An edge determination module 403 is used to determine a target first line from the plurality of first lines according to the attribute information of each first line, wherein the target first line is a line representing the edge of the target product;
[0128] An image correction module 404 is used to determine the offset angle corresponding to the image to be identified based on the target first line, and perform correction processing on the image to be identified based on the offset angle to obtain a corrected image;
[0129] A second line extraction module 405, used to extract a plurality of second lines in the corrected image;
[0130] The region identification module 406 is configured to determine a plurality of target edge lines corresponding to the target product from the plurality of second lines based on the appearance ratio data, and identify the appearance region of the target product based on the plurality of target edge lines.
[0131] The region recognition device disclosed in the present invention is used to obtain an image to be recognized, and to obtain the appearance ratio data of a target product, extract multiple first lines in the image to be recognized, determine a target first line from the multiple first lines according to the attribute information of each first line, the target first line is a line that characterizes the edge of the target product, determine the offset angle corresponding to the image to be recognized based on the target first line, and perform correction processing on the image to be recognized based on the offset angle to obtain a corrected image, extract multiple second lines in the corrected image, determine multiple target edge lines corresponding to the target product from the multiple second lines based on the appearance ratio data, and recognize the appearance region of the target product based on the multiple target edge lines. That is, the first line can be extracted using the appearance ratio data of the target product, and then the image to be recognized can be corrected based on the first line to extract the second line, and the appearance region of the target product can be further determined using the second line and the appearance ratio data, thereby improving the appearance recognition accuracy of images with uneven imaging grayscale values and small foreground and background differences, and by extracting the appearance region lines step by step, the appearance recognition accuracy of images with complex background textures and many interference lines is also improved.
[0132] In one embodiment, the area identification module 406 is specifically used to classify each second line according to the positional relationship between each second line and the target center position to obtain multiple line sets, wherein the line sets include a bottom line set, a top line set, a left line set and a right line set; based on the multiple line sets and the appearance ratio data, determine multiple target edge lines corresponding to the target product.
[0133] In one possible implementation, the region identification module 406 is specifically used to select second lines from each line set to form a plurality of line groups, and determine the aspect ratio of the region determined by each second line in each line group; each of the line groups includes a line from each line set, and different line groups include different second lines from the same line set; a line group having the smallest difference between the corresponding aspect ratio and the ratio data is determined as a target line group, and each second line in the target line group is determined as a plurality of target edge lines corresponding to the target product.
[0134] In one possible implementation manner, the attribute information of the first line includes the length of the first line and position information in the image to be recognized;
[0135] The edge determination module 403 is specifically configured to filter the first lines at the edge of the image to be identified according to the position information of each of the first lines in the image to be identified; and determine the line with the largest length among the first lines remaining after filtering as the target first line.
[0136] In one possible implementation, the image correction module 404 is specifically used to obtain the position information of the endpoint of the target first line in the image to be identified; determine the slope corresponding to the target first line based on the position information; and calculate the offset angle corresponding to the image to be identified based on the slope.
[0137] In one possible implementation, the image correction module 404 is specifically used to, if the target first line is a line representing the top edge or the bottom edge of the target product, rotate the image to be identified in a clockwise direction by the offset angle to obtain a corrected image; if the target first line is a line representing the left edge or the right edge of the target product, rotate the image to be identified in a clockwise direction by 90° minus the difference angle obtained by subtracting the offset angle to obtain a corrected image.
[0138] In one possible implementation, the appearance ratio data includes an appearance aspect ratio of the target product.
[0139] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0140] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0141] like Figure 5 As shown, the device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0142] A number of components in the device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0143] The computing unit 501 may be a variety of general and / or special processing development components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as the region recognition method. For example, in some embodiments, the region recognition method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the region recognition method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the region recognition method in any other appropriate manner (e.g., by means of firmware).
[0144] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0145] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0146] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0147] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0148] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0149] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0150] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0151] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0152] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A region recognition method, characterized in that: The method comprises: Obtaining an image to be recognized, and obtaining appearance ratio data of a target product; Extracting a plurality of first lines from the image to be recognized; Determine a target first line from the plurality of first lines according to the attribute information of each first line, wherein the target first line is a line representing an edge of the target product; Determining a deviation angle corresponding to the image to be identified based on the first target line, and performing correction processing on the image to be identified based on the deviation angle to obtain a corrected image; extracting a plurality of second lines in the corrected image; Based on the appearance ratio data, a plurality of target edge lines corresponding to the target product are determined from the plurality of second lines, and an appearance region of the target product is identified based on the plurality of target edge lines.
2. The method according to claim 1, characterized in that The step of determining a plurality of target edge lines corresponding to the target product from the plurality of second lines based on the appearance ratio data includes: Classifying each second line according to the positional relationship between each second line and the target center position to obtain a plurality of line sets, wherein the line sets include a bottom line set, a top line set, a left line set, and a right line set; Based on the multiple line sets and the appearance ratio data, multiple target edge lines corresponding to the target product are determined.
3. The method according to claim 2, characterized in that The step of determining a plurality of target edge lines corresponding to the target product based on the plurality of line sets and the appearance ratio data includes: Selecting second lines from each line set to form a plurality of line groups, and determining the aspect ratio of the area defined by each second line in each line group; Each of the line groups includes a line from each line set, and the second lines from the same line set included in different line groups are different; A line group corresponding to a minimum difference between the aspect ratio and the ratio data is determined as a target line group, and each second line in the target line group is determined as a plurality of target edge lines corresponding to the target product.
4. The method according to claim 1, characterized in that: The attribute information of the first line includes the length of the first line and the position information of the first line in the image to be recognized; The step of determining a target first line from the plurality of first lines according to the attribute information of each first line includes: filtering first lines at the edge of the image to be identified according to position information of each of the first lines in the image to be identified; The line with the longest length among the first lines remaining after filtering is determined as the target first line.
5. The method according to claim 1, characterized in that The step of determining the offset angle corresponding to the image to be identified based on the first target line includes: Obtaining position information of the endpoint of the first target line in the image to be identified; Determine the slope corresponding to the first target line based on the position information; The offset angle corresponding to the image to be recognized is calculated according to the slope.
6. The method according to claim 5, characterized in that The correcting the image to be identified based on the offset angle to obtain a corrected image includes: If the target first line is a line representing the top edge or the bottom edge of the target product, the image to be identified is rotated clockwise by the offset angle to obtain a corrected image; If the target first line is a line representing the left edge or the right edge of the target product, the image to be identified is rotated 90° clockwise minus the difference angle of the offset angle to obtain a corrected image.
7. The method according to claim 1, characterized in that The appearance ratio data includes the appearance aspect ratio of the target product.
8. A region recognition device, characterized in that: The device comprises: A data acquisition module is used to acquire the image to be recognized and the appearance ratio data of the target product; A first line extraction module, used to extract a plurality of first lines in the image to be identified; An edge determination module, configured to determine a target first line from the plurality of first lines according to attribute information of each first line, wherein the target first line is a line representing an edge of the target product; An image correction module, used to determine the offset angle corresponding to the image to be identified based on the target first line, and perform correction processing on the image to be identified based on the offset angle to obtain a corrected image; A second line extraction module, used to extract a plurality of second lines in the corrected image; The region identification module is used to determine a plurality of target edge lines corresponding to the target product from the plurality of second lines based on the appearance ratio data, and to identify the appearance region of the target product based on the plurality of target edge lines.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1-7.