Object volume measurement method, device, computer equipment and storage medium
Through grating data processing and automated calculation, it solves the problem of volume measurement of irregular objects in the logistics industry, achieves fast and accurate volume measurement, improves measurement efficiency and accuracy, and is suitable for the measurement of irregular objects.
Patent Information
- Application Number
- CN202010954525.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-11
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-09-11
AI Technical Summary
In the logistics and express delivery industries, it is difficult to quickly and accurately measure the volume of irregular objects with existing technology, resulting in low measurement efficiency and cumbersome operations.
By obtaining the raster data of the object, constructing the bitmap and contour map, calculating the minimum external rectangle, and calculating the volume based on the side height, automatic volume measurement is achieved using grating device scanning and background calculation.
It realizes fast and accurate volume measurement of regular and irregular objects, simplifies operations, improves measurement efficiency, is suitable for obtaining the minimum circumscribed volume of irregular objects, and reduces manual measurement errors.
Smart Images

Figure CN112102393B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for measuring the volume of an object, and more specifically to a method, device, computer equipment and storage medium for measuring the volume of an object. Background Art
[0002] In the logistics and express delivery industries, it is often necessary to measure the volume of express items in order to calculate the volume weight of the items. Specifically, express delivery companies will calculate the volume weight of items with any single side of the three sides reaching 60 cm or more in length, width, and height. When measuring the volume, manual measurement is usually used. It is more troublesome to measure the minimum circumscribed volume of some irregular objects. In other words, it is currently difficult to measure the volume of express items, and the operation is cumbersome and inefficient.
[0003] Therefore, it is necessary to design a new method to automatically measure the size of express items, which is simple to operate, efficient, suitable for obtaining the minimum circumscribed volume of irregular objects, and has high measurement accuracy. Summary of the invention
[0004] The purpose of the present invention is to overcome the defects of the prior art and provide a method, device, computer equipment and storage medium for measuring the volume of an object.
[0005] To achieve the above object, the present invention adopts the following technical solution: a method for measuring the volume of an object, comprising:
[0006] Get the raster data of the bottom surface of the object;
[0007] Acquire a dot matrix image of the bottom surface of the object according to the raster data of the bottom surface of the object;
[0008] Obtaining the outline of the object according to the dot map of the bottom surface of the object;
[0009] Calculate the center of the bottom surface according to the outline of the object to obtain the center of the object;
[0010] Rotate the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object;
[0011] Get the raster data of the side of the object and calculate the height of the object based on the side of the object;
[0012] Calculating the volume of the object according to the height of the object and the minimum circumscribed rectangle of the bottom of the object;
[0013] The volume of the object is fed back to the terminal to calculate the volume weight.
[0014] A further technical solution is: the step of obtaining a dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object comprises:
[0015] Convert the raster data of the object's bottom surface into a byte array;
[0016] Insert the byte array to the end of the preset buffer array;
[0017] The aspect ratio of the preset buffer array is adjusted to the aspect ratio of the bottom surface of the object by the nearest neighbor interpolation method, so as to obtain a dot matrix image of the bottom surface of the object.
[0018] A further technical solution is: the step of obtaining a contour image of the object according to the dot pattern of the bottom surface of the object comprises:
[0019] Perform a depth-first traversal starting from one of the points in the dot map on the bottom surface of the object;
[0020] Determine whether the traversed point is an edge point of the object;
[0021] If the traversed point is an edge point of the object, the traversed point is added to the edge cache;
[0022] Determine whether the traversal is completed;
[0023] If the traversal is completed, the border formed by the points in the edge cache is obtained to obtain the outline of the object;
[0024] If the traversal is not finished, the depth-first traversal is performed starting from one of the points in the dot map of the bottom surface of the object.
[0025] A further technical solution is: after determining whether the traversed point is an edge point of the object, the method further includes:
[0026] If the traversed point is not an edge point of the object, the step of determining whether the traversal is finished is performed.
[0027] A further technical solution is: the feeding back of the volume of the object to the terminal to calculate the volume weight includes:
[0028] Get the barcode and weight of the object;
[0029] Pack the barcode, weight and volume of the objects to obtain a data package;
[0030] The data packet is sent to the terminal for volumetric weight calculation.
[0031] The present invention also provides an object volume measuring device, comprising:
[0032] A bottom surface data acquisition unit, used for acquiring raster data of the bottom surface of the object;
[0033] A dot pattern acquisition unit, used for acquiring a dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object;
[0034] A contour map acquisition unit, used for acquiring a contour map of the object according to a dot matrix map of the bottom surface of the object;
[0035] A center calculation unit, used for calculating the center of the bottom surface according to the contour map of the object to obtain the center of the object;
[0036] A rectangle calculation unit, used for rotating the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object;
[0037] A height calculation unit, used to obtain grating data of the side of the object and calculate the height of the object according to the side of the object;
[0038] A volume calculation unit, used to calculate the volume of the object according to the height of the object and the minimum circumscribed rectangle of the bottom surface of the object;
[0039] The feedback unit is used to feed back the volume of the object to the terminal for calculating the volume weight.
[0040] Its further technical solution is: the dot pattern acquisition unit comprises:
[0041] A data conversion subunit, used for converting the raster data of the bottom surface of the object into a byte array;
[0042] An insert subunit, used for inserting a byte array into the tail of a preset buffer array;
[0043] The ratio adjustment subunit is used to adjust the length-width ratio of the preset cache array to the length-width ratio of the bottom surface of the object through the nearest neighbor interpolation method to obtain a dot matrix of the bottom surface of the object.
[0044] Its further technical solution is: the contour map acquisition unit includes:
[0045] A traversal subunit is used to perform a depth-first traversal starting from one of the points in the dot map on the bottom surface of the object;
[0046] The point judgment subunit is used to judge whether the traversed point is an edge point of the object;
[0047] An adding subunit is used to add the traversed point to the edge cache if the traversed point is an edge point of the object;
[0048] A traversal judgment subunit is used to judge whether the traversal is finished; if the traversal is not finished, the depth-first traversal is performed starting from one of the points in the dot matrix of the bottom surface of the object;
[0049] The frame acquisition subunit is used to obtain the frame formed by the points in the edge cache if the traversal is completed, so as to obtain the outline of the object.
[0050] The present invention further provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor implements the above method when executing the computer program.
[0051] The present invention also provides a storage medium, wherein the storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0052] Compared with the prior art, the beneficial effects of the present invention are as follows: after obtaining the grating data of the bottom surface of the object, the present invention determines the dot matrix, and then traverses each point in the dot matrix to determine the contour of the bottom surface, and then obtains the minimum circumscribed rectangle of the bottom surface of the object, and then determines the volume according to the product of the minimum circumscribed rectangle of the bottom surface and the height of the object determined by the obtained side grating data. The method of scanning the object with a grating device and background measurement can realize the measurement of the volume of regular or irregular objects, without manual measurement, and can realize automatic measurement of the size of express objects. The operation is simple and efficient, and it is suitable for obtaining the minimum circumscribed volume of irregular objects with high measurement accuracy.
[0053] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0055] Figure 1 A schematic diagram of an application scenario of the object volume calculation method provided by an embodiment of the present invention;
[0056] Figure 2 A schematic diagram of a flow chart of a method for measuring the volume of an object provided in an embodiment of the present invention;
[0057] Figure 3 A schematic diagram of a sub-process of a method for measuring the volume of an object provided in an embodiment of the present invention;
[0058] Figure 4 A schematic diagram of a sub-process of a method for measuring the volume of an object provided in an embodiment of the present invention;
[0059] Figure 5 A schematic diagram of a sub-process of a method for measuring the volume of an object provided in an embodiment of the present invention;
[0060] Figure 6 A schematic block diagram of an object volume calculation device provided by an embodiment of the present invention;
[0061] Figure 7 A schematic block diagram of a dot pattern acquisition unit of an object volume measurement device provided in an embodiment of the present invention;
[0062] Figure 8 A schematic block diagram of a contour image acquisition unit of an object volume measurement device provided in an embodiment of the present invention;
[0063] Fig. 9 A schematic block diagram of a feedback unit of an object volume measurement device provided in an embodiment of the present invention;
[0064] Fig.10 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0066] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0067] 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.
[0068] 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.
[0069] See also Figure 1 and Figure 2 , Figure 1 A schematic diagram of an application scenario of the object volume calculation method provided in an embodiment of the present invention. Figure 2A schematic flow chart of an object volume measurement method provided in an embodiment of the present invention. The object volume measurement method is applied to a server, which exchanges data with a terminal and a grating device, scans the bottom and side surfaces of an object through the grating device to obtain corresponding grating data, and processes and calculates related data based on the bottom grating data, and combines the grating data of the side surfaces to calculate the volume of the object. Whether it is a regular or irregular object, the volume can be measured quickly and automatically.
[0070] Figure 2 FIG. 1 is a flow chart of a method for measuring the volume of an object provided by an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S110 to S180.
[0071] S110, obtaining raster data of the bottom surface of the object.
[0072] In this embodiment, the grating data refers to data obtained by scanning the bottom surface of an object using a grating device.
[0073] S120 , obtaining a dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object.
[0074] In this embodiment, the dot pattern of the bottom surface of the object refers to an image composed of single dots of pixels of the bottom surface of the object.
[0075] In one embodiment, see Figure 3 , the above-mentioned step S120 may include steps S121 to S123.
[0076] S121. Convert the raster data of the bottom surface of the object into a byte array.
[0077] In this embodiment, the byte array refers to an array formed by converting raster data into a byte type.
[0078] S122: insert the byte array into the tail of the preset cache array.
[0079] In this embodiment, the preset cache array refers to a cache for temporarily storing an array.
[0080] S123, adjusting the aspect ratio of the preset cache array to the aspect ratio of the bottom surface of the object by using the nearest neighbor interpolation method, so as to obtain a dot matrix of the bottom surface of the object.
[0081] The raster data is read through the serial port, converted into a byte array, and inserted into the end of the preset cache array. Through the nearest neighbor interpolation method, the length and width ratio of the preset cache array is adjusted to the actual length and width ratio, and the original array of the raster dot matrix can be obtained.
[0082] MergeData(arr,ref result);
[0083] arr1=PreProcess(arr) / / data preprocessing, arr is raster data;
[0084] append arr1 onto the end of result.
[0085] Specifically, after preprocessing the grating data, the ground dot map is obtained according to the moving speed and the grating data of the bottom surface. The grating device is scanned to obtain the grating data and perform corresponding processing. The volume is automatically measured without human participation in the calculation, which can improve the accuracy and efficiency of the entire measurement.
[0086] S130, obtaining a contour map of the object according to the dot map of the bottom surface of the object.
[0087] In this embodiment, the outline image of the object refers to a frame image formed by edge points of the bottom surface of the object.
[0088] In one embodiment, see Figure 4 , the above-mentioned step S130 may include steps S131 to S135.
[0089] S131. Perform a depth-first traversal starting from one of the points in the dot map on the bottom surface of the object.
[0090] In this embodiment, any point in the dot matrix of the bottom surface of the object is traversed to screen out points at the edge of the bottom surface of the object, thereby confirming the contour map of the bottom surface of the object.
[0091] S132, determining whether the traversed point is an edge point of the object;
[0092] S133. If the traversed point is an edge point of the object, the traversed point is added to the edge cache.
[0093] In this embodiment, the edge buffer refers to a buffer for storing relevant information of points located at the edge of the bottom surface of the object, including the coordinates of the points.
[0094] S134, judging whether the traversal is finished;
[0095] S135 . If the traversal is completed, a border formed by the points in the edge cache is obtained to obtain a contour map of the object.
[0096] In this embodiment, the coordinates of a border are determined according to the coordinates of the points in the edge buffer, thereby determining the contour map of the object.
[0097] If the traversal is not finished, execute step S131;
[0098] If the traversed point is not an edge point of the object, then the step S134 is executed.
[0099] Starting from a point in the bitmap of the bottom surface of the object, a depth-first traversal is performed to determine whether the traversed point is the edge of the bottom surface of the object. If it is on the edge of the bottom surface of the object, the point is added to the edge cache. After the traversal is completed, the data in the cache is the contour bitmap of the bottom surface of the object.
[0100] / / Convert the dot matrix image to the outline dot matrix image, x is the horizontal coordinate of the point of any object, y is the vertical coordinate of the point of any object, data is the dot matrix image, and the return value is the outline dot matrix image;
[0101] GetContour(x,y,data);
[0102] DFS(x,y,data,ref countour) / / Depth-first traversal;
[0103] return countour;
[0104] / / Depth-first traversal to obtain the border coordinate data, x is the horizontal coordinate of a point in any object, y is the vertical coordinate of a point in any object, data is a dot matrix, contour is the contour data
[0105] DFS(x,y,data,ref contour);
[0106] If IsBorder(x,y,data) / / Judge whether it is contour data;
[0107] append(x,y)onto the end of contour;
[0108] If IsInside(x,y,data) / / Judge whether the coordinates are contained by the object;
[0109] DFS(x+1,y,data,ref contour);
[0110] DFS(x-1,y,data,ref contour);
[0111] DFS(x,y+1,data,ref contour);
[0112] DFS(x,y-1,data,ref contour).
[0113] There is no need to manually determine the edge of the object. The points on the edge of the object are determined automatically to avoid omissions and errors in manually determining the outline of the object.
[0114] S140, calculating the center of the bottom surface according to the contour diagram of the object to obtain the center of the object.
[0115] In this embodiment, the center of the object refers to the center point of the bottom surface of the object.
[0116] / / Calculate the center point based on the contour data, contour is the contour data, and the return value is the coordinates of the center point;
[0117] CalculateCentre(Contour);
[0118] x = AverageXaxis(Contour);
[0119] y = AverageYaxis(Contour);
[0120] return(x,y).
[0121] S150 , rotating the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object.
[0122] / / Get the minimum bottom area, contour is the contour data, midX is the horizontal coordinate of the center point, midY is the vertical coordinate of the center point, and the return value is the minimum area;
[0123] GetMinArea(contour,midX,midY);
[0124] let m be the length of contour;
[0125] let result be max of int;
[0126] for i=0to90;
[0127] rotateContour = rotate(contour,i,midX,midY); / / Get the rotated contour image;
[0128] result = Min (result, GetArea (rotateContour)); / / Get the horizontal rectangular area under the contour map;
[0129] return result.
[0130] S160, obtaining grating data of the side of the object, and calculating the height of the object according to the side of the object.
[0131] In this embodiment, the height of the object refers to the height value obtained by pre-processing the raster data on the side of the object.
[0132] / / Get height data, arr is the side grating data, and the return value is height;
[0133] GetHeight(arr);
[0134] arr1=PreProcessHeight(arr);
[0135] return CaculateHeight(arr1).
[0136] S170: Calculate the volume of the object according to the height of the object and the minimum circumscribed rectangle of the bottom surface of the object.
[0137] In this embodiment, the volume of an object refers to the product of the height of the object and the minimum circumscribed rectangle of the bottom of the object.
[0138] CaculateVolume(area,height);
[0139] return area*height.
[0140] S180, feeding back the volume of the object to the terminal to calculate the volume weight.
[0141] In one embodiment, see Figure 5 , the above-mentioned step S180 may include steps S181 to S183.
[0142] S181. Obtain the barcode and weight of the object.
[0143] In this embodiment, each object is provided with a barcode, and the weight of the object can be obtained by a weighing device.
[0144] S182. Pack the barcode, weight and volume of the object to obtain a data package.
[0145] In this embodiment, the data packet refers to a package formed by combining the barcode, weight and volume of the object in a specified format.
[0146] In this embodiment, the object may be packaged in the arrangement format of barcode+weight+volume.
[0147] S183. Send the data packet to the terminal to calculate the volume weight.
[0148] When the terminal obtains the data packet, it can determine the type of object based on the barcode of the object, and then determine the volumetric weight based on the actual weight and volume, and then determine the logistics cost based on this.
[0149] Simply place the object on the device to get the exact size of the object, solving the problem of difficult volume measurement and cumbersome operation, and can measure the minimum circumscribed volume of irregular objects. It is used in the fields of cargo volume measurement, warehouse management, etc. in the logistics and express delivery industries. It has high measurement accuracy and low cost, and improves the automation level of logistics and warehousing. The volume measurement of objects is no longer done manually, but is carried out in a fully automatic way, which not only improves the measurement efficiency, but also avoids the errors caused by manual measurement.
[0150] The above-mentioned method for measuring the volume of an object obtains the grating data of the bottom surface of the object, determines the dot matrix, and then traverses each point in the dot matrix to determine the contour of the bottom surface, and then obtains the minimum circumscribed rectangle of the bottom surface of the object, and then determines the volume according to the product of the minimum circumscribed rectangle of the bottom surface and the height of the object determined by the obtained side grating data. The method uses a grating device to scan the object and background measurement to realize the measurement of the volume of regular or irregular objects. No manual measurement is required, and the size of express objects can be automatically measured. The operation is simple and efficient, and it is suitable for obtaining the minimum circumscribed volume of irregular objects with high measurement accuracy.
[0151] Figure 6 is a schematic block diagram of an object volume calculation device 300 provided in an embodiment of the present invention. Figure 6 As shown, corresponding to the above object volume calculation method, the present invention also provides an object volume calculation device 300. The object volume calculation device 300 includes a unit for executing the above object volume calculation method, and the device can be configured in a server. Figure 6 The object volume measuring device 300 includes a bottom surface data acquisition unit 301, a dot map acquisition unit 302, a contour map acquisition unit 303, a center calculation unit 304, a rectangle calculation unit 305, a height calculation unit 306, a volume calculation unit 307 and a feedback unit 308.
[0152] The bottom surface data acquisition unit 301 is used to acquire the raster data of the bottom surface of the object; the dot pattern acquisition unit 302 is used to acquire the dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object; the contour pattern acquisition unit 303 is used to acquire the contour pattern of the object according to the dot pattern of the bottom surface of the object; the center calculation unit 304 is used to calculate the center of the bottom surface according to the contour pattern of the object to obtain the center of the object; the rectangle calculation unit 305 is used to rotate the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object; the height calculation unit 306 is used to acquire the raster data of the side surface of the object and calculate the height of the object according to the side surface of the object; the volume calculation unit 307 is used to calculate the volume of the object according to the height of the object and the minimum circumscribed rectangle of the bottom surface of the object; the feedback unit 308 is used to feed back the volume of the object to the terminal to calculate the volume weight.
[0153] In one embodiment, if Figure 7 As shown, the bitmap acquisition unit 302 includes a data conversion subunit 3021 , an insertion subunit 3022 , and a ratio adjustment subunit 3023 .
[0154] The data conversion subunit 3021 is used to convert the raster data of the bottom surface of the object into a byte array; the insertion subunit 3022 is used to insert the byte array into the end of the preset cache array; the ratio adjustment subunit 3023 is used to adjust the length and width ratio of the preset cache array to the length and width ratio of the bottom surface of the object through the nearest neighbor interpolation method to obtain a dot matrix of the bottom surface of the object.
[0155] In one embodiment, if Figure 8 As shown, the contour image acquisition unit 303 includes a traversal subunit 3031 , a point judgment subunit 3032 , an adding subunit 3033 , a traversal judgment subunit 3034 and a frame acquisition subunit 3035 .
[0156] The traversal subunit 3031 is used to perform a depth-first traversal starting from one of the points in the dot map of the bottom surface of the object; the point judgment subunit 3032 is used to judge whether the traversed point is an edge point of the object; if the traversed point is not an edge point of the object, the judgment of whether the traversal is finished is executed; the adding subunit 3033 is used to add the traversed point to the edge cache if the traversed point is an edge point of the object; the traversal judgment subunit 3034 is used to judge whether the traversal is finished; if the traversal is not finished, the depth-first traversal starting from one of the points in the dot map of the bottom surface of the object is executed; the border acquisition subunit 3035 is used to obtain the border formed by the points in the edge cache if the traversal is finished, so as to obtain the outline of the object.
[0157] In one embodiment, if Fig. 9As shown, the feedback unit 308 includes an information acquisition subunit 3081 , a packaging subunit 3082 , and a sending subunit 3083 .
[0158] The information acquisition subunit 3081 is used to obtain the barcode and weight of the object; the packing subunit 3082 is used to pack the barcode, weight and volume of the object to obtain a data packet; the sending subunit 3083 is used to send the data packet to the terminal to calculate the volume weight.
[0159] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned object volume measurement device 300 and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0160] The object volume measuring device 300 may be implemented in the form of a computer program. The computer program may be implemented in the form of a computer program. Fig.10 Runs on the computer device shown.
[0161] See also Fig.10 , Fig.10 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a server, wherein the server may be an independent server or a server cluster composed of multiple servers.
[0162] See also Fig.10 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0163] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a method for measuring the volume of an object.
[0164] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0165] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a method for measuring the volume of an object.
[0166] The network interface 505 is used to communicate with other devices over the network. Fig.10The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0167] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:
[0168] Obtain raster data of the bottom surface of the object; obtain a dot map of the bottom surface of the object based on the raster data of the bottom surface of the object; obtain an outline of the object based on the dot map of the bottom surface of the object; calculate the center of the bottom surface based on the outline of the object to obtain the center of the object; rotate the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object; obtain raster data of the side surface of the object, and calculate the height of the object based on the side surface of the object; calculate the volume of the object based on the height of the object and the minimum circumscribed rectangle of the bottom surface of the object; and feed back the volume of the object to the terminal to calculate the volume weight.
[0169] In one embodiment, when the processor 502 implements the step of acquiring the dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object, the processor 502 specifically implements the following steps:
[0170] The raster data of the bottom surface of the object is converted into a byte array; the byte array is inserted into the tail of the preset cache array; the aspect ratio of the preset cache array is adjusted to the aspect ratio of the bottom surface of the object through the nearest neighbor interpolation method to obtain a dot matrix image of the bottom surface of the object.
[0171] In one embodiment, when the processor 502 implements the step of acquiring the contour image of the object according to the dot pattern of the bottom surface of the object, the processor 502 specifically implements the following steps:
[0172] Perform a depth-first traversal starting from one of the points in the dot map of the bottom surface of the object; determine whether the traversed point is an edge point of the object; if the traversed point is an edge point of the object, add the traversed point to the edge cache; determine whether the traversal is completed; if the traversal is completed, obtain the border formed by the points in the edge cache to obtain a contour map of the object; if the traversal is not completed, execute the depth-first traversal starting from one of the points in the dot map of the bottom surface of the object.
[0173] In one embodiment, after implementing the step of determining whether the traversed point is an edge point of the object, the processor 502 further implements the following steps:
[0174] If the traversed point is not an edge point of the object, the step of determining whether the traversal is finished is performed.
[0175] In one embodiment, when the processor 502 implements the step of feeding back the volume of the object to the terminal to calculate the volume weight, the processor 502 specifically implements the following steps:
[0176] Obtain the barcode and weight of the object; pack the barcode, weight and volume of the object to obtain a data packet; send the data packet to the terminal to calculate the volume weight.
[0177] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0178] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0179] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps:
[0180] Obtain raster data of the bottom surface of the object; obtain a dot map of the bottom surface of the object based on the raster data of the bottom surface of the object; obtain an outline of the object based on the dot map of the bottom surface of the object; calculate the center of the bottom surface based on the outline of the object to obtain the center of the object; rotate the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object; obtain raster data of the side surface of the object, and calculate the height of the object based on the side surface of the object; calculate the volume of the object based on the height of the object and the minimum circumscribed rectangle of the bottom surface of the object; and feed back the volume of the object to the terminal to calculate the volume weight.
[0181] In one embodiment, when the processor executes the computer program to implement the step of acquiring a dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object, the processor specifically implements the following steps:
[0182] The raster data of the bottom surface of the object is converted into a byte array; the byte array is inserted into the tail of the preset cache array; the aspect ratio of the preset cache array is adjusted to the aspect ratio of the bottom surface of the object through the nearest neighbor interpolation method to obtain a dot matrix image of the bottom surface of the object.
[0183] In one embodiment, when the processor executes the computer program to implement the step of obtaining a contour image of the object according to the dot matrix image of the bottom surface of the object, the processor specifically implements the following steps:
[0184] Perform a depth-first traversal starting from one of the points in the dot map of the bottom surface of the object; determine whether the traversed point is an edge point of the object; if the traversed point is an edge point of the object, add the traversed point to the edge cache; determine whether the traversal is completed; if the traversal is completed, obtain the border formed by the points in the edge cache to obtain a contour map of the object; if the traversal is not completed, execute the depth-first traversal starting from one of the points in the dot map of the bottom surface of the object.
[0185] In one embodiment, after executing the computer program to implement the step of determining whether the traversed point is an edge point of the object, the processor further implements the following steps:
[0186] If the traversed point is not an edge point of the object, the step of determining whether the traversal is finished is performed.
[0187] In one embodiment, when the processor executes the computer program to implement the step of feeding back the volume of the object to the terminal to calculate the volume weight, the processor specifically implements the following steps:
[0188] Obtain the barcode and weight of the object; pack the barcode, weight and volume of the object to obtain a data packet; send the data packet to the terminal to calculate the volume weight.
[0189] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.
[0190] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. 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 several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0192] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0193] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0194] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for calculating the volume of an object, characterized in that: include: Get the raster data of the bottom surface of the object; Acquire a dot matrix image of the bottom surface of the object according to the raster data of the bottom surface of the object; Obtaining the outline of the object according to the dot map of the bottom surface of the object; Calculate the center of the bottom surface according to the outline of the object to obtain the center of the object; Rotate the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object; Get the raster data of the side of the object and calculate the height of the object based on the side of the object; Calculating the volume of the object according to the height of the object and the minimum circumscribed rectangle of the bottom of the object; Feedback the volume of the object to the terminal to calculate the volume weight; The step of obtaining a dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object comprises: Convert the raster data of the object's bottom surface into a byte array; Insert the byte array to the end of the preset buffer array; The aspect ratio of the preset buffer array is adjusted to the aspect ratio of the bottom surface of the object by the nearest neighbor interpolation method, so as to obtain a dot matrix image of the bottom surface of the object.
2. The object volume calculation method according to claim 1, characterized in that: The step of obtaining a contour image of the object according to the dot map of the bottom surface of the object comprises: Perform a depth-first traversal starting from one of the points in the dot map on the bottom surface of the object; Determine whether the traversed point is an edge point of the object; If the traversed point is an edge point of the object, the traversed point is added to the edge cache; Determine whether the traversal is completed; If the traversal is completed, the border formed by the points in the edge cache is obtained to obtain the outline of the object; If the traversal is not finished, the depth-first traversal is performed starting from one of the points in the dot map of the bottom surface of the object.
3. The object volume measurement method according to claim 2, characterized in that: After determining whether the traversed point is an edge point of the object, the method further includes: If the traversed point is not an edge point of the object, the step of determining whether the traversal is finished is performed.
4. The object volume calculation method according to claim 1, characterized in that: Feedback of the volume of the object to the terminal for calculating the volume weight includes: Get the barcode and weight of the object; Pack the barcode, weight and volume of the objects to obtain a data package; The data packet is sent to the terminal for volumetric weight calculation.
5. An object volume measuring device, characterized in that: include: A bottom surface data acquisition unit, used for acquiring raster data of the bottom surface of the object; A dot pattern acquisition unit, used for acquiring a dot pattern of the bottom surface of the object according to the raster data of the bottom surface of the object; A contour map acquisition unit, used for acquiring a contour map of the object according to a dot matrix map of the bottom surface of the object; A center calculation unit, used for calculating the center of the bottom surface according to the contour map of the object to obtain the center of the object; A rectangle calculation unit, used for rotating the object according to the center of the object to calculate the circumscribed rectangle of the bottom surface of the object and the minimum circumscribed rectangle of the bottom surface of the object; A height calculation unit, used to obtain grating data of the side of the object and calculate the height of the object according to the side of the object; A volume calculation unit, used to calculate the volume of the object according to the height of the object and the minimum circumscribed rectangle of the bottom surface of the object; A feedback unit, used for feeding back the volume of the object to the terminal for calculating the volume weight; The dot map acquisition unit comprises: A data conversion subunit, used for converting the raster data of the bottom surface of the object into a byte array; An insert subunit, used for inserting a byte array into the tail of a preset buffer array; The ratio adjustment subunit is used to adjust the length-width ratio of the preset cache array to the length-width ratio of the bottom surface of the object through the nearest neighbor interpolation method to obtain a dot matrix of the bottom surface of the object.
6. The object volume measuring device according to claim 5, characterized in that: The contour map acquisition unit comprises: A traversal subunit is used to perform a depth-first traversal starting from one of the points in the dot map on the bottom surface of the object; The point judgment subunit is used to judge whether the traversed point is an edge point of the object; An adding subunit is used to add the traversed point to the edge cache if the traversed point is an edge point of the object; A traversal judgment subunit is used to judge whether the traversal is finished; if the traversal is not finished, the depth-first traversal is performed starting from one of the points in the dot matrix of the bottom surface of the object; The frame acquisition subunit is used to obtain the frame formed by the points in the edge cache if the traversal is completed, so as to obtain the outline of the object.
7. A computer device, characterized in that: The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 4 when executing the computer program.
