Disclosure of Invention
The invention aims to at least solve one of the technical problems in the prior art and provides a method and a device for generating commodity marking points.
In order to achieve the above object, a first aspect of the present invention provides a method for generating a commodity annotation point, including:
establishing an identification library;
rendering all commodities in a target environment to obtain a rendering graph;
according to the identification library, identifying the area of each commodity in the rendering graph to obtain the identification area of each commodity;
calculating the position of each commodity marking point according to the identification area of each commodity;
and generating each commodity labeling point according to the position of each commodity labeling point.
Preferably, the step of establishing an identification library comprises:
establishing a corresponding relation between commodities and colors to form the identification library; wherein each item corresponds to a color.
Preferably, the step of calculating the position of each commodity labeling point according to the identification area of each commodity includes:
extracting all pixels of each commodity in the identification area;
and calculating the distance from each pixel of each commodity to the edge position of the identification area corresponding to the pixel, and taking the pixel farthest from the edge position as the position of the commodity labeling point.
Preferably, the step of calculating the distance from each pixel of each commodity to the edge position of the identification area corresponding to the pixel, and using the pixel farthest from the edge position as the position of the commodity labeling point includes:
calculating the distance between a preset number of pixels around each pixel and the edge position, and extracting the minimum distance between the preset number of pixels around the pixel and the edge position;
and obtaining the farthest distance from each pixel to the edge position of the identification area corresponding to the pixel based on the minimum distance.
Preferably, the step of obtaining the farthest distance from each pixel to the edge position of the identification region corresponding to each pixel based on the minimum distance includes:
and adding the minimum distance and a preset value to obtain the maximum distance from each pixel to the edge position of the corresponding identification area.
In a second aspect of the present invention, there is provided an apparatus for generating a labeling point of a commodity, including:
the establishing module is used for establishing an identification library;
the rendering module is used for rendering all commodities in the target environment to obtain a rendering graph;
the identification module is used for identifying the area of each commodity in the rendering map according to the identification library to obtain the identification area of each commodity;
the calculation module is used for calculating the position of each commodity marking point according to the identification area of each commodity;
and the generating module is used for generating each commodity labeling point according to the position of each commodity labeling point.
Preferably, the establishing module is configured to establish a corresponding relationship between the commodity and the color to form the identification library; wherein each item corresponds to a color.
Preferably, the calculation module is configured to extract all pixels of each commodity in the identification area corresponding to the commodity; and the number of the first and second groups,
the calculation module is further configured to calculate a distance from each pixel of each commodity to an edge position of the identification area corresponding to the pixel, and use a pixel farthest from the edge position as a position of a commodity labeling point.
Preferably, the calculation module is configured to calculate distances between a predetermined number of pixels around each pixel and the edge position, and extract a minimum distance between the predetermined number of pixels around the pixel and the edge position; and the number of the first and second groups,
and the calculation module is further used for obtaining the farthest distance from each pixel to the edge position of the identification area corresponding to the pixel based on the minimum distance.
Preferably, the calculation module is configured to add the minimum distance to a preset value to obtain a maximum distance from each pixel to an edge position of the identification area corresponding to the pixel.
The invention relates to a method and a device for generating commodity marking points, which comprises the following steps of firstly, establishing an identification library; secondly, rendering all commodities in the target environment to obtain a rendering image; thirdly, according to the identification library, identifying the area of each commodity in the rendering graph to obtain the identification area of each commodity; then, calculating the position of each commodity marking point according to the identification area of each commodity; and finally, generating each commodity labeling point according to the position of each commodity labeling point. Therefore, the method for generating the commodity marking points can effectively improve the efficiency of the commodity marking points and can also effectively improve the accuracy of the commodity marking points, thereby reducing the marking cost and improving the economic benefit.
Detailed Description
The following detailed description of embodiments of the invention refers to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present invention, are given by way of illustration and explanation only, not limitation.
Referring to fig. 1, a first aspect of the present invention relates to a method S100 for generating a commodity annotation point, where the method S100 includes:
and S110, establishing an identification library.
Specifically, in this step, for example, a correspondence relationship between the product and the color (or a mapping relationship between the product and the color) may be established. That is, each article corresponds to a particular color. In this way, in the rendering map described below, the region where the product corresponding to the color is located can be obtained from the color. Of course, in addition to using the corresponding relationship between the product and the color as the identification library, the identification library may be constructed by determining the corresponding relationship between the product and other key features according to actual needs.
And S120, rendering all commodities in the target environment to obtain a rendering graph.
Specifically, in this step, all the commodities in the target environment may be rendered by a rendering tool (e.g., rendering software), so that a desired rendering map may be obtained.
S130, according to the identification library, identifying the area of each commodity in the rendering graph, and obtaining the identification area of each commodity.
Specifically, the description will be given taking as an example that the identification library is constructed from the correspondence between the product and the color. In this step, according to the obtained rendering map, the rendering map includes a plurality of commodities, and each commodity has been subjected to coloring processing with a color corresponding thereto. In this way, by identifying the colors in the rendering map, the area of each commodity in the rendering map can be determined, and thus the identification area of each commodity can be obtained.
And S140, calculating the position of each commodity marking point according to the identification area of each commodity.
Specifically, according to the obtained identification area of each commodity, the position of the commodity marking point corresponding to the identification area can be obtained according to each identification area.
And S150, generating each commodity labeling point according to the position of each commodity labeling point.
In the method S100 for generating a commodity annotation point according to this embodiment, first, an identification library is established; secondly, rendering all commodities in the target environment to obtain a rendering image; thirdly, according to the identification library, identifying the area of each commodity in the rendering graph to obtain the identification area of each commodity; then, calculating the position of each commodity marking point according to the identification area of each commodity; and finally, generating each commodity labeling point according to the position of each commodity labeling point. Therefore, the method S100 for generating a commodity annotation point according to this embodiment can effectively improve the efficiency of the commodity annotation point, and can also effectively improve the accuracy of the commodity annotation point, thereby reducing the annotation cost and improving the economic benefit.
Preferably, the step S110 includes:
establishing a corresponding relation between commodities and colors to form the identification library; wherein each item corresponds to a color.
That is, in this step, a product corresponds to a specific target color, for example, the computer host corresponds to black, the refrigerator corresponds to white, and so on.
In the method S100 for generating a commodity labeling point according to this embodiment, the identification library is constructed and formed by establishing a corresponding relationship between a commodity and a color, so that the efficiency of the commodity labeling point can be further effectively improved, and the accuracy of the commodity labeling point can also be effectively improved, thereby reducing the labeling cost and improving the economic benefit.
It should be understood that when rendering the product, it should be ensured that the color of the product in the rendered rendering map is consistent with the color corresponding to the product in the identification library, that is, when the computer host corresponds to black in the identification library, the computer host also corresponds to black in the rendering map.
Preferably, the step 140 includes:
all pixels of each article in the identification area are extracted.
And calculating the distance from each pixel of each commodity to the edge position of the identification area corresponding to the pixel, and taking the pixel farthest from the edge position as the position of the commodity labeling point.
In the method S100 for generating a product labeling point according to this embodiment, all pixels of each product in the identification area are extracted, the distance from each pixel of each product to the edge position of the identification area corresponding to each pixel is calculated, the pixel farthest from the edge position is used as the position of the product labeling point, and the obtained position of the product labeling point is used to generate each product labeling point. Therefore, the efficiency of the commodity marking points can be further effectively improved, and the accuracy of the commodity marking points can also be effectively improved, so that the marking cost can be reduced, and the economic benefit can be improved.
Preferably, the step S140 includes:
distances of a predetermined number of pixels around each pixel from the edge position are calculated, and a minimum distance of the predetermined number of pixels around the edge position is extracted.
And obtaining the farthest distance from each pixel to the edge position of the identification area corresponding to the pixel based on the minimum distance.
Specifically, the distances of four number of pixels around each pixel from the edge position may be calculated. Specifically, as shown in table 1 below:
TABLE 1
As shown in table 1, the distances between the four pixels around the x pixel located in the middle area and the edge position are 1, 2, and 3, respectively, so that the minimum distance between the four pixels around the x pixel and the edge position can be determined to be 1, and the maximum distance between the x pixel and the edge position of the corresponding identification area can be determined according to the minimum distance 1.
In the method S100 for generating a commodity labeling point according to this embodiment, the distances between the predetermined number of pixels around each pixel and the edge position are calculated, and the minimum distances between the predetermined number of pixels around each pixel and the edge position are extracted, so that the maximum distance between the pixel and the edge position can be obtained according to the minimum distances. Therefore, the efficiency of the commodity marking points can be further effectively improved, and the accuracy of the commodity marking points can also be effectively improved, so that the marking cost can be reduced, and the economic benefit can be improved.
It should be noted that the rendering map includes a normal rendering map and a panorama rendering map, and in the normal rendering map, when the distance is calculated, four edges of the rendering map serve as boundaries for calculating the farthest distance; in the panoramic rendering, each rendering is connected with 4 renderings, the boundary of a commodity is calculated, all renderings where the commodity is located need to be considered, for example, if the commodity appears in 2 renderings, the boundary of the commodity needs to be determined by using 2 renderings.
Preferably, the step of obtaining the farthest distance from each pixel to the edge position of the identification region corresponding to each pixel based on the minimum distance includes:
and adding the minimum distance and a preset value to obtain the maximum distance from each pixel to the edge position of the corresponding identification area.
Similarly, referring to table 1 above, the distances between the four pixels around the pixel x and the edge position are 1, 2, and 3, respectively, so that the minimum distance between the four pixels around the pixel x and the edge position can be determined to be 1, and thus the minimum distance can be added to a preset value, for example, the preset value can be 1, and of course, the preset value can also be other values according to actual needs, for example, 0.5 or 1.5, and so on. Therefore, the farthest distance from the pixel x to the edge position can be determined to be 2 according to table 1.
In the mark area of each product, the distance edge position where there is no pixel is 0.
More specifically, as shown in Table 2 below, all pixels of one of the articles in the identification area are identified.
|
|
|
|
|
|
|
|
|
|
X
|
X
|
X
|
X
|
X
|
|
|
|
|
X
|
X
|
x
|
x
|
x
|
x
|
|
|
|
X
|
X
|
X
|
X
|
X
|
X
|
X
|
|
|
|
X
|
x
|
x
|
x
|
x
|
x
|
x
|
|
|
x
|
x
|
x
|
x
|
x
|
x
|
|
|
|
|
x
|
x
|
x
|
x
|
|
|
|
|
|
x
|
x
|
x
|
|
|
|
|
|
|
|
|
|
|
|
|
TABLE 2
From the above tables 1 and 2, the distance from any one pixel x to the edge position can be calculated as shown in table 3 below.
|
|
|
|
|
|
|
|
|
|
1
|
1
|
1
|
1
|
1
|
|
|
|
|
1
|
2
|
2
|
2
|
2
|
2
|
|
|
|
1
|
2
|
3
|
3
|
3
|
2
|
1
|
|
|
|
1
|
2
|
3
|
4
|
3
|
2
|
1
|
|
|
1
|
2
|
3
|
3
|
2
|
1
|
|
|
|
|
1
|
2
|
2
|
1
|
|
|
|
|
|
1
|
1
|
1
|
|
|
|
|
|
|
|
|
|
|
|
|
TABLE 3
Therefore, as can be seen from table 3, the distance distribution of each pixel of the commodity in the identification area is obtained by selecting the position where the pixel is farthest from the edge position as the commodity marking point position, that is, the position where the pixel with the distance of 4 is located in table 3 as the commodity marking point position.
In a second aspect of the present invention, as shown in fig. 2, there is provided an apparatus 100 for generating a labeling point of a commodity, comprising:
an establishing module 110, configured to establish an identification library;
the rendering module 120 is configured to render all the commodities in the target environment to obtain a rendering map;
the identification module 130 is configured to identify an area of each commodity in the rendering map according to the identification library, and obtain an identification area of each commodity;
the calculation module 140 is configured to calculate a position of each commodity marking point according to the identification area of each commodity;
the generating module 150 is configured to generate each commodity labeling point according to the position of each commodity labeling point.
In the device 100 for generating a commodity annotation point according to this embodiment, first, an identification library is established by using an establishing module 110; secondly, rendering all commodities in the target environment by using a rendering module 120 to obtain a rendering map; thirdly, identifying the area of each commodity in the rendering map by using the identification module 130 according to the identification library to obtain the identification area of each commodity; then, calculating the position of each commodity marking point by using the calculating module 140 according to the identification area of each commodity; finally, the generating module 150 generates each commodity labeling point according to the position of each commodity labeling point. Therefore, the device 100 for generating the commodity labeling point of the embodiment can effectively improve the efficiency of the commodity labeling point, and can also effectively improve the accuracy of the commodity labeling point, thereby reducing the labeling cost and improving the economic benefit.
Preferably, the establishing module 110 is configured to establish a corresponding relationship between a commodity and a color to form the identification library; wherein each item corresponds to a color.
The device 100 for generating the commodity labeling points of the embodiment builds the identification library by establishing the corresponding relationship between the commodity and the color, so that the efficiency of the commodity labeling points can be further effectively improved, the accuracy of the commodity labeling points can also be effectively improved, the labeling cost can be reduced, and the economic benefit can be improved.
Preferably, the calculation module 140 is configured to extract all pixels of each article in the identification area corresponding to the article; and the number of the first and second groups,
the calculating module 140 is further configured to calculate a distance from each pixel of each commodity to an edge position of the identification area corresponding to the pixel, and use a pixel farthest from the edge position as a position of a commodity labeling point.
In the device 100 for generating a labeling point for a commodity according to this embodiment, the calculation module 140 is used to extract all pixels of each commodity in the identification area, calculate the distance from each pixel of each commodity to the edge position of the identification area corresponding to the pixel, and use the pixel farthest from the edge position as the position of the labeling point for the commodity, and the generation module 150 is used to generate each labeling point for the commodity according to the obtained position of the labeling point for the commodity. Therefore, the efficiency of the commodity marking points can be further effectively improved, and the accuracy of the commodity marking points can also be effectively improved, so that the marking cost can be reduced, and the economic benefit can be improved.
Preferably, the calculating module 140 is configured to calculate distances between a predetermined number of surrounding pixels of each pixel and the edge position, and extract a minimum distance between the predetermined number of surrounding pixels and the edge position; and the number of the first and second groups,
the calculating module 140 is further configured to obtain a farthest distance from each pixel to an edge position of the identified region corresponding to the pixel based on the minimum distance.
Reference may be made to the above related descriptions, which are not repeated herein.
The device 100 for generating a labeling point of a commodity according to this embodiment calculates distances between a predetermined number of pixels around each pixel and the edge position by using the calculation module 140, and extracts the minimum distances between the predetermined number of pixels around and the edge position, so that the maximum distance between the pixel and the edge position can be obtained according to the minimum distance. Therefore, the efficiency of the commodity marking points can be further effectively improved, and the accuracy of the commodity marking points can also be effectively improved, so that the marking cost can be reduced, and the economic benefit can be improved.
Preferably, the calculating module 140 is configured to add the minimum distance to a preset value to obtain a maximum distance from each pixel to an edge position of the corresponding identification area. Reference may be made to the above related descriptions, which are not repeated herein.
It will be understood that the above embodiments are merely exemplary embodiments taken to illustrate the principles of the present invention, which is not limited thereto. It will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the spirit and substance of the invention, and these modifications and improvements are also considered to be within the scope of the invention.