Search

CN-115330856-B - Method for measuring cuboid volume based on single image

CN115330856BCN 115330856 BCN115330856 BCN 115330856BCN-115330856-B

Abstract

The invention provides a method for measuring the volume of a cuboid based on a single image, which relates to the technical field of size measurement and comprises the steps of fixing a monocular camera and shooting an image of a calibration plate to obtain a translation vector of the camera relative to the calibration plate under the pose, further calculating the ground clearance of an origin of a coordinate system of the monocular camera, shooting an image containing a lower vertex of the cuboid and three sides of the corresponding length, width and height, picking up pixel coordinates of four vertices of the cuboid, combining internal parameters, ground clearance and four vertex pixel coordinates of the cuboid of the monocular camera, and calculating the length, width and height of the cuboid by utilizing geometric knowledge to obtain the volume of the cuboid.

Inventors

  • SHAN JIANHUA
  • ZHANG DING
  • DING XINGYU

Assignees

  • 安徽工业大学

Dates

Publication Date
20260505
Application Date
20220819

Claims (1)

  1. 1. A method for measuring a cuboid volume based on a single image is characterized by comprising the following steps: S1, fixing a monocular camera and shooting an image of a calibration plate to obtain a translation vector of the camera relative to the calibration plate under the pose, and further calculating the ground clearance of the origin of a monocular camera coordinate system, wherein the camera coordinate system is o-xyz; the translation vector T of the monocular camera relative to the calibration plate is obtained by utilizing a pnp algorithm, and as the Z axis of a world coordinate system established on the calibration plate is vertical to the horizontal ground, 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, and the ground clearance H of the origin of the camera coordinate system can be obtained by adding the thickness H2 of the calibration plate; When the monocular camera is adopted to shoot the image containing the cuboid, the lens of the monocular camera needs to be kept fixed from S2, the lower vertex of the cuboid and the complete image of the corresponding three sides of the length, the width and the height are shot, and the pixel coordinates M0, M1, M2 and M3 of the corresponding four vertexes M0, M1, M2 and M3 on an imaging plane are manually picked up; S3, calculating the length, width and height of the cuboid by utilizing geometric knowledge by combining the internal reference, the ground clearance height and the four vertex pixel coordinates of the cuboid of the monocular camera, so as to obtain the volume of the cuboid; s3 further comprises: S31, setting a world coordinate system origin to coincide with a lower vertex m0 of the cuboid, wherein the world coordinate system is O-XYZ, and X, Y, Z axes are respectively established along three sides corresponding to the lower vertex of the cuboid according to a right-hand rule; S32, calculating straight lines of projection lines M0M1, M0M2 and M0M3 of three sides of the cuboid in the imaging plane by using the pixel coordinates M0, M1, M2 and M3 of M0, M1, M2 and M3 determined by S2 Equation, under the camera coordinate system, calculate the projection plane of three sides of cuboid ) Equation to further calculate the normal vector of the projection plane ; S33, determining the direction of a translation vector t of a camera coordinate system relative to a world coordinate system established on the cuboid according to the pixel coordinate M0 of the vertex M0 under the cuboid, counteracting the scale uncertainty of the monocular camera after one H is given, and recording In the Z-axis component of The method can be used for obtaining: ; S34, obtaining dihedral angles of three projection surfaces according to the geometric relation of the vectors ( ) Due to the rectangular three-sided vector 、 、 Are mutually perpendicular and are positioned in respective projection planes, and are calculated according to the geometric relationship 、 、 Vector in each projection plane 、 、 Included angle of (2) Vector quantity Normal vector of direction winding projection plane Rotating Obtaining vectors Calculating a vector The vector is calculated by the same method 、 Is a direction of (2); S35 at In (C) due to The length and direction of the sheet are known, 、 The direction of (2) is known, and can be obtained by: can be found by the same way 、 I.e. the true length of the three sides of the cuboid.

Description

Method for measuring cuboid volume based on single image Technical Field The invention relates to the technical field of size measurement, in particular to a method for measuring the volume of a cuboid based on a single image. Background Cuboid objects are quite common in daily life, for example, logistics e-commerce enterprises need to process express packages every day, and when the packages are put in and put out, data information such as length, width, height, volume, weight and the like needs to be acquired, and compared with the package quality, the volume of the cuboid objects is more difficult to accurately acquire. The method for measuring the volume by using the depth camera and the binocular camera has higher cost, and based on the method, the invention designs a method for measuring the volume of a cuboid based on a single image so as to solve the problems. Disclosure of Invention The invention aims to provide a method for measuring the volume of a cuboid based on a single image, so as to solve the problems in the background technology. In order to achieve the purpose, the invention provides the following technical scheme that the method for measuring the volume of the cuboid based on the single image comprises the following steps: S1, fixing a monocular camera and shooting an image of a calibration plate to obtain a translation vector of the camera relative to the calibration plate under the pose, and further calculating the ground clearance of the origin of a monocular camera coordinate system; S2, shooting an image containing a lower vertex of the cuboid and three sides of the corresponding length, width and height, and picking up pixel coordinates of four vertices of the cuboid; And S3, calculating the length, width and height of the cuboid by utilizing geometric knowledge in combination with the internal reference, the ground clearance and the pixel coordinates of four vertexes of the cuboid of the monocular camera, and further obtaining the volume of the cuboid. Preferably, in S1, the translation vector T of the monocular camera relative to the calibration plate is obtained by using a pnp algorithm, and since the Z axis of the world coordinate system established on the calibration plate is perpendicular to the horizontal ground, 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, and the ground clearance H of the origin of the camera coordinate system can be obtained by adding the thickness H2 of the calibration plate. Preferably, when the monocular camera is adopted to shoot an image containing a cuboid in S3, the lens of the monocular camera needs to be kept stationary from S2, a complete image of the lower vertex of the cuboid and the corresponding three sides of length, width and height is shot, and pixel coordinates M0, M1, M2 and M3 of the corresponding four vertices M0, M1, M2 and M3 on an imaging plane are manually picked up. Preferably, in S3, the reference of the monocular camera, the ground clearance H, and the coordinates of four vertex pixels are combined, the ground clearance H is used to offset the problem of scale uncertainty caused by the image captured by the monocular camera, and the three sides of the cuboid are calculated through geometric knowledge, and the volume of the cuboid is obtained. Preferably, S3 specifically further includes: S31, setting the origin of a world coordinate system to coincide with the lower vertex m0 of the cuboid, and setting X, Y, Z axes along three sides corresponding to the lower vertex of the cuboid according to a right-hand rule; S32, calculating straight lines L i (i=1, 2 and 3) equations of three sides of a cuboid in an imaging plane by using pixel coordinates M0, M1, M2 and M3 of M0, M1, M2 and M3 determined in S2, and calculating a projection plane (delta oM 0M1、ΔoM0M2、ΔoM0M3) equation of the three sides of the cuboid under a camera coordinate system, thereby further calculating a normal vector N i (i=1, 2 and 3) of the projection plane; s33, determining the direction of a translation vector t of a camera coordinate system relative to a world coordinate system established on the cuboid according to the pixel coordinate M0 of the vertex M0 under the cuboid, counteracting the scale uncertainty of the monocular camera after one H is given, and recording In the Z-axis component ofThe method can be characterized by comprising the following steps: S34, according to the geometric relationship of the vectors, obtaining the dihedral angles cos phi ij (i not equal to j; i, j=1, 2, 3) of the three projection surfaces, and due to the cuboid three-side vector Are perpendicular to each other and are positioned in the respective projection planes, and can be calculated according to the geometric relationshipVector in each projection planeIncluded angle θ i (i=1, 2, 3), vectorNormal vector of direction winding projection planeRotating theta