A method for measuring cuboid volume based on a single image
By using a monocular camera and geometric knowledge to measure the volume of a cuboid, the problems of high cost and large error in existing technologies have been solved, achieving low-cost and high-precision measurement of the volume of a cuboid.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ANHUI UNIVERSITY OF TECHNOLOGY
- Filing Date
- 2022-08-19
- Publication Date
- 2026-05-05
AI Technical Summary
Existing technologies struggle to accurately and cost-effectively measure the volume of cuboid objects, especially in everyday situations such as the entry and exit of express parcels. Methods based on depth cameras and binocular cameras are costly and prone to errors.
Using a monocular camera combined with a calibration board and geometric knowledge, the volume of a cuboid is measured through a single image. The camera's height above the ground and the pixel coordinates of the cuboid's vertices are calculated. Geometric relationships are then used to calculate the length, width, and height of the cuboid, thus determining its volume.
It achieves high-precision cuboid volume measurement with low cost and low computing equipment requirements, reducing the error to the millimeter level, and solving the problems of high cost and large error in existing technologies.
Smart Images

Figure CN115330856B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of dimensional measurement technology, specifically a method for measuring the volume of a cuboid based on a single image. Background Technology
[0002] Rectangular prisms are very common in daily life. For example, logistics and e-commerce companies handle express parcels every day. When these parcels are received and shipped, data such as length, width, height, volume, and weight need to be collected. Compared to the weight of the parcel, its volume is more difficult to obtain accurately. Methods for measuring volume using depth cameras and binocular cameras are costly. Therefore, this invention designs a method for measuring the volume of a rectangular prism based on a single image to solve the above problems. Summary of the Invention
[0003] The purpose of this invention is to provide a method for measuring the volume of a cuboid based on a single image, so as to solve the problems mentioned in the background art.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a method for measuring the volume of a cuboid based on a single image, comprising the following steps:
[0005] S1: Fix the monocular camera and take an image of the calibration board, obtain the translation vector of the camera relative to the calibration board in this pose, and then calculate the height of the origin of the monocular camera coordinate system above the ground.
[0006] S2: Capture an image containing one lower vertex of the cuboid and its corresponding length, width, and height, and pick up the pixel coordinates of the four vertices of the cuboid involved;
[0007] S3: Combining the intrinsic parameters of the monocular camera, the height above the ground, and the pixel coordinates of the four vertices of the cuboid, the length, width, and height of the cuboid are calculated using geometric knowledge, and then the volume of the cuboid is obtained.
[0008] Preferably, in S1, the translation vector T of the monocular camera relative to the calibration plate is obtained using the PNP algorithm. Since the Z-axis of the world coordinate system established on the calibration plate is perpendicular to the horizontal ground and pointing upwards, the Z-axis component of the T vector represents the height h1 of the origin of the camera coordinate system relative to the upper surface of the calibration plate. Adding the thickness h2 of the calibration plate, the height H of the origin of the camera coordinate system above the ground can be obtained.
[0009] Preferably, when using a monocular camera to capture an image containing a cuboid in S3, the lens of the monocular camera needs to remain fixed since S2, capture a complete image of the lower vertex of the cuboid and its corresponding length, width, and height, and manually pick up the pixel coordinates M0, M1, M2, and M3 of the four vertices m0, m1, m2, and m3 on the imaging plane.
[0010] Preferably, in S3, the intrinsic parameters of the monocular camera, the height H above the ground, and the pixel coordinates of the four vertices are combined. The height H above the ground is used to offset the scale uncertainty problem caused by the image captured by the monocular camera. The lengths of the three sides of the cuboid are calculated using geometric knowledge, and the volume of the cuboid is obtained.
[0011] Preferably, S3 further includes:
[0012] S31: Let the origin of the world coordinate system coincide with the lower vertex m0 of the cuboid, and establish the X, Y, and Z axes along the three sides corresponding to the lower vertex of the cuboid according to the right-hand rule;
[0013] S32: Using the pixel coordinates M0, M1, M2, and M3 determined in S2, calculate the straight line L of the projection lines M0M1, M0M2, and M0M3 of the three sides of the cuboid in the imaging plane. i Given the equations (i = 1, 2, 3), in the camera coordinate system, find the equations of the projection surfaces (ΔoM0M1, ΔoM0M2, ΔoM0M3) of the three sides of the cuboid, and then obtain the normal vector N of the projection surfaces. i (i = 1, 2, 3);
[0014] S33: Based on the pixel coordinates M0 of the lower vertex m0 of the cuboid, determine the direction of the translation vector t of the camera coordinate system relative to the world coordinate system established on the cuboid. The scale uncertainty of the monocular camera is canceled out after giving an H. Let t be... The Z-axis component is We can obtain:
[0015] S34: Based on the geometric relationship of vectors, obtain the dihedral angle cosφ of the three projection planes. ij (i≠j; i,j=1,2,3), due to the three side vectors of the cuboid Since they are perpendicular to each other and lie in their respective projection planes, their geometric relationships can be used to calculate... vectors in their respective projection planes The included angle θ i (i = 1, 2, 3), vector normal vector around the projection plane Rotate θ1 to obtain the vector The vector can be calculated Similarly, the vector can be calculated. The direction;
[0016] S35: In Δom0m1, due to Length and direction are known. Given the direction, we can find m0m1. Similarly, we can find m0m2 and m0m3, which are the actual lengths of the three sides of the cuboid.
[0017] Compared with existing technologies, the advantages of this invention are: This invention requires only a single image, and multiple subsequent measurements can be completed by calculating the camera's height H above the ground at the initial stage. Furthermore, by applying geometric knowledge, it enables the measurement of the volume of a cuboid placed on a horizontal surface using a monocular camera in a fixed scene. Its main advantages are low cost, low computational requirements, and ease of implementation. In general scenarios, the demand for measuring the volume of cuboid objects is relatively large; this invention solves this problem and significantly reduces measurement costs.
[0018] Furthermore, for volume measurement devices based on binocular cameras on the market, due to the limitations of the binocular measurement principle, their errors are usually at the centimeter level. However, the method of the present invention, which calculates the side length of the cuboid using geometric knowledge, can reduce the error to the millimeter level, greatly improving the accuracy of volume measurement.
[0019] Of course, any product implementing this invention does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating the method for measuring the volume of a cuboid from a single image according to the present invention.
[0022] Figure 2 This is a schematic diagram illustrating the solution for calculating the height H of the camera coordinate system origin O above the ground in this invention.
[0023] Figure 3 A schematic diagram of a camera capturing a cuboid according to the present invention;
[0024] Figure 4 A geometric diagram for solving the three side lengths of a cuboid;
[0025] Figure 5 To solve for the direction vectors of the three sides vectors in the corresponding projection plane The included angle θ i A schematic diagram. Detailed Implementation
[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] Please see Figure 1-5 This invention provides a technical solution: a method for measuring the volume of a cuboid based on a single image, characterized by comprising the following steps:
[0028] S1: Fix the monocular camera and take an image of the calibration board, obtain the translation vector of the camera relative to the calibration board in this pose, and then calculate the height of the origin of the monocular camera coordinate system above the ground.
[0029] Specifically, fix the camera's height and orientation; the tilt and height should be moderate, such as... Figure 2 As shown, the calibration plate is placed on a horizontal surface, and an image of the calibration plate is taken. The translation vector T of the camera relative to the calibration plate is measured using the PNP algorithm. The world coordinate system on the calibration plate is established with the Z-axis perpendicular to the horizontal working surface and upward, and the XOY plane is located at the checkerboard corner point on the surface of the calibration plate. The Z component of the translation vector T of the camera coordinate system origin relative to the world coordinate system origin represents the height h1 of the camera coordinate system relative to the surface of the calibration plate. Adding the thickness h2 of the calibration plate, the height H of the camera coordinate system relative to the horizontal working surface can be obtained.
[0030] S2: Capture an image containing one lower vertex of the cuboid and its corresponding length, width, and height, and pick up the pixel coordinates of the four vertices of the cuboid involved;
[0031] Specifically, such as Figure 3 As shown, step S2 requires capturing a complete image of the lower vertex of the cuboid (the vertex close to the horizontal working surface and facing the camera) and its corresponding three sides, and manually picking the two-dimensional pixel coordinates M0, M1, M2, and M3 of the four vertices m0, m1, m2, and m3.
[0032] S3: Combining the intrinsic parameters of the monocular camera, the height above the ground, and the pixel coordinates of the four vertices of the cuboid, the length, width, and height of the cuboid are calculated using geometric knowledge, and then the volume of the cuboid is obtained.
[0033] In S1, the translation vector T of the monocular camera (with known intrinsic parameters and focal length f) relative to the calibration board (a checkerboard calibration board is used in this invention) is obtained using the PNP algorithm. Since the Z-axis of the world coordinate system (O-XYZ) established on the calibration board is perpendicular to the horizontal ground and pointing upwards, the Z-axis component of the T vector represents the height h1 of the origin of the camera coordinate system (o-xyz) relative to the upper surface of the calibration board. Adding the thickness h2 of the calibration board, the height H of the origin of the camera coordinate system above the ground can be obtained.
[0034] In S3, when using a monocular camera to capture an image containing a cuboid, the lens of the monocular camera needs to remain fixed since S2, capturing a complete image of the lower vertex of the cuboid (the vertex facing the camera and close to the horizontal working surface) and its corresponding length, width, and height. The pixel coordinates M0, M1, M2, and M3 of the four vertices m0, m1, m2, and m3 on the imaging plane are then manually picked up.
[0035] In S3, the intrinsic parameters of the monocular camera, the height H above the ground, and the pixel coordinates of the four vertices are combined. The height H above the ground is used to offset the scale uncertainty problem caused by the image captured by the monocular camera. The lengths of the three sides of the cuboid are calculated through geometric knowledge, and the volume of the cuboid is obtained.
[0036] Specifically, S3 also includes:
[0037] S31: Let the origin of the world coordinate system coincide with the lower vertex m0 of the cuboid, and establish the X, Y, and Z axes along the three sides corresponding to the lower vertex of the cuboid according to the right-hand rule;
[0038] S32: Using the pixel coordinates M0, M1, M2, and M3 determined in S2, calculate the straight line L of the projection lines M0M1, M0M2, and M0M3 of the three sides of the cuboid in the imaging plane. i (i = 1, 2, 3) Equation (Linear Equation L) i A i x+B i y+C i =0, (i=1,2,3), in the camera coordinate system, find the equations of the projection planes (ΔoM0M1, ΔoM0M2, ΔoM0M3) of the three sides of the cuboid, and then find the normal vector of the projection planes.
[0039] S33: Based on the pixel coordinates M0 of the lower vertex m0 of the cuboid, determine the translation vector t of the camera coordinate system relative to the world coordinate system established on the cuboid (i.e.: The direction of the monocular camera's scale uncertainty is canceled out after a given H, denoted as... The Z-axis component is We can obtain:
[0040] S34: Based on the geometric relationship of vectors, obtain the dihedral angle cosφ of the three projection planes. ij (i≠j; i,j=1,2,3), due to the three side vectors of the cuboid Since they are perpendicular to each other and lie in their respective projection planes, their geometric relationships can be used to calculate... vectors in their respective projection planes The included angle θ i (i = 1, 2, 3), vector normal vector around the projection plane Rotate θ1 to obtain the vector The vector can be calculated Similarly, the vector can be calculated. The direction;
[0041] S35: In Δom0m1, due to Length and direction are known. Given the direction, we can find m0m1. Similarly, we can find m0m2 and m0m3, which are the actual lengths of the three sides of the cuboid.
[0042] It should be added that: vectors respectively with The outer product yields a vector By calculating the angle between these three vectors, the dihedral angles of the three projection planes can be obtained. (i≠j;i,j=1,2,3);
[0043] like Figure 5 As shown, let Equation 1 can be obtained:
[0044] |q' i q' j | 2 =|q i q j | 2 -(|q j q' j |-|q i q' i |) 2 =2-(sinθ) j -sinθ i ) 2 ;
[0045] In Δq' i m0m' j From this, we can obtain equation 2:
[0046] |q' i q'j | 2 =|m0q' i | 2 +|m0q' j | 2 -2|m0q' i ||m0q' j |cosφ ij =(cosθ) i ) 2 +(cosθ j ) 2 -2cosθ i cosθ j cosφ ij ;
[0047] From the above two equations, we can derive: tgθ i tgθ j +cosφ ij =0, (i≠j, i,j=1,2,3), and the vectors representing the directions of the three sides of the cuboid can be calculated. vectors in the corresponding projection plane The included angle θ i ;
[0048] Due to vectors Towards the vector Rotate θ1 to obtain the vector remember The unit vector is From the vector rotation formula: The vector can be calculated Similarly, the vector can be calculated.
[0049] In Δom0m1, due to Length and direction are known. (and Given the directions of the collinear lines, we can find: According to the law of sines, we can find that: m0m1=om0·sin∠m0om1 / sin∠m0m1o. Similarly, we can find m0m2 and m0m3, which are the lengths of the three sides of the cuboid.
[0050] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0051] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.
Claims
1. A method for measuring the volume of a cuboid based on a single image, characterized in that: Includes the following steps: S1: Fix the monocular camera and take an image of the calibration plate to obtain the translation vector of the camera relative to the calibration plate in this pose. Then calculate the height of the origin of the monocular camera coordinate system above the ground. The camera coordinate system is o-xyz. Use the PNP algorithm to obtain the translation vector T of the monocular camera relative to the calibration plate. Since the Z-axis of the world coordinate system established on the calibration plate is perpendicular to the horizontal ground and upward, the Z-axis component of the T vector represents the height h1 of the origin of the camera coordinate system relative to the upper surface of the calibration plate. Add the thickness h2 of the calibration plate to obtain the height H of the origin of the camera coordinate system above the ground. S2: Capture an image containing one lower vertex of the cuboid and its corresponding length, width, and height, and pick up the pixel coordinates of the four vertices of the cuboid involved; when using a monocular camera to capture an image containing the cuboid, the lens of the monocular camera needs to remain fixed from S2, capture a complete image of the lower vertex of the cuboid and its corresponding length, width, and height, and manually pick up the pixel coordinates M0, M1, M2, and M3 of the four vertices m0, m1, m2, and m3 on the imaging plane; S3: Combining the intrinsic parameters of the monocular camera, the height above the ground, and the pixel coordinates of the four vertices of the cuboid, the length, width, and height of the cuboid are calculated using geometric knowledge, and then the volume of the cuboid is obtained. S3 also includes: S31: Let the origin of the world coordinate system coincide with the lower vertex m0 of the cuboid. The world coordinate system is O-XYZ. The X, Y, and Z axes are established along the three sides corresponding to the lower vertex of the cuboid according to the right-hand rule. S32: Using the pixel coordinates M0, M1, M2, and M3 determined in S2, calculate the straight lines M0M1, M0M2, and M0M3 of the projection lines of the three sides of the cuboid in the imaging plane. The equation, in the camera coordinate system, is used to find the projection planes of the three sides of the cuboid. The equation is used to obtain the normal vector of the projection plane. ; S33: Based on the pixel coordinates M0 of the lower vertex m0 of the cuboid, determine the direction of the translation vector t of the camera coordinate system relative to the world coordinate system established on the cuboid. The scale uncertainty of the monocular camera is canceled out after giving an H. Let t be... The Z-axis component is We can obtain: ; S34: Based on the geometric relationships of vectors, obtain the dihedral angles of the three projection planes. ( Since the three side vectors of the cuboid , , They are perpendicular to each other and lie in their respective projection planes. Calculations are made based on geometric relationships. , , vectors in their respective projection planes , , The included angle ,vector normal vector around the projection plane Rotation Obtain vector Calculate the vector Similarly, the vector is calculated. , The direction; S35: In In China, due to Length and direction are known. , Given the direction, we can determine: Similarly, we can find , That is, the actual lengths of the three sides of the cuboid.
Citation Information
Patent Citations
Single image camera calibration method based on compressed sensing
CN107644444A
Intelligent express box size measurement method and system
CN114494401A