Disclosure of Invention
In view of the above, the embodiment of the application provides a pitch angle correction method and a pitch angle correction system for monocular ranging of a dome camera.
In order to solve the above technical problems, the embodiments of the present specification are implemented as follows:
the embodiment of the specification provides a pitch angle correction method for monocular distance measurement of a dome camera, which is characterized by comprising the following steps:
Solving a relation between the measured distance of the target object and the pitch angle of the spherical camera based on a monocular ranging principle;
setting a first zoom multiple of the spherical camera, and calibrating camera parameters of the spherical camera to obtain parameters of the camera;
taking a photo, selecting a reference point, and measuring the distance between the reference point and the dome camera and the pixel coordinates of the reference point in the photo;
and solving a pitch angle of the reference point relative to the first zoom multiple based on the relation, the distance between the reference point and the dome camera and the pixel coordinate of the reference point in the photo.
Optionally, the solving the relation between the measured distance of the target object and the pitch angle of the spherical camera based on the monocular ranging principle specifically includes:
Constructing the relation between the true value and the calculated value of the reference point in the image by a gradient descent method, and solving the true pitch angle of the dome camera and the horizontal plane;
the small-hole imaging model based on monocular distance measurement simplifies the relation between the measured distance of a target object in an image and the pitch angle of a spherical camera.
Optionally, a Zhang Zhengyou camera calibration method is adopted to calibrate camera parameters of the dome camera.
Optionally, the solving the pitch angle of the reference point relative to the first zoom multiple based on the relation, the distance between the reference point and the dome camera, and the pixel coordinates of the reference point in the photo specifically includes:
and constructing an objective function by adopting a gradient descent method based on the relation, the distance between the reference point and the spherical camera and the pixel coordinates of the reference point in the photo, and deriving, wherein the angle value corresponding to the derivative 0 point is the pitch angle under the first zoom multiple.
Optionally, when the reference points are multiple, multiple pitch angles can be solved, and an optimal value is selected as the pitch angle of the dome camera under the first zoom magnification.
Optionally, the selecting the optimal value as the pitch angle of the dome camera under the first zoom multiple specifically includes:
calculating the average error of the distance between each reference point and the dome camera and the true value;
And selecting the pitch angle corresponding to the reference point with the minimum average error and the error value smaller than 5% as the pitch angle of the spherical camera under the first zoom multiple.
Optionally, the formula of the relation between the measured distance of the target object and the pitch angle of the dome camera is as follows:
Where h is the camera height, α is the camera pitch angle, (x 0,y0) is the focal point of the optical axis and the image plane, HF is the measured distance of the target object, f is the effective focal length of the camera, and (x, y) is the coordinates of the target object in the image plane coordinate system.
Optionally, the objective function is:
Where h is the camera height, f x is the normalized focal length on the u-axis of the pixel coordinate system, f y is the normalized focal length on the v-axis of the pixel coordinate system, Δs i is the range error value for monocular vision, oc is the pitch angle, (u i,vi) is the pixel coordinate of reference point i, (u 0,v0) is the pixel coordinate of the image center point, and S i is the actual distance from reference point i to the camera on the image.
Optionally, the photo is divided into 4 quadrants by drawing the plane direct coordinates with the center point of the photo as the base point, and at least three reference points are selected in each quadrant.
The embodiment of the specification provides a pitch angle correction system towards monocular range finding of ball-type camera, includes:
the relational determination module is used for solving a relational expression between the measured distance of the target object and the pitch angle of the spherical camera based on the monocular distance measurement principle;
the zoom multiple setting module is used for setting a first zoom multiple of the spherical camera, calibrating camera parameters of the spherical camera and obtaining parameters of the camera;
The reference point selecting and distance measuring module is used for taking a photo, selecting a reference point and measuring the distance between the reference point and the dome camera and the pixel coordinates of the reference point in the photo;
And the pitch angle solving module is used for solving the pitch angle of the reference point relative to the first zoom multiple based on the relation, the distance between the reference point and the spherical camera and the pixel coordinate of the reference point in the picture.
The above-mentioned at least one technical scheme that this description embodiment adopted can reach following beneficial effect:
according to the embodiment of the specification, the pitching angle deviation caused by installation of the dome camera can be effectively corrected, the monocular ranging error caused by the pitching angle deviation is avoided, and the measurement precision of the dome camera is ensured.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be clearly and completely described below with reference to specific embodiments of the present application and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the monocular ranging method, the geometric relation derivation algorithm has stronger practicability and portability. Many solutions exist at present, such as basic models of similar triangle ranging algorithms discuss the effect of pixel errors on ranging accuracy, but do not consider the effect of camera pose angles on distance measurements; the method is simple in derivation, but large in error.
These methods generally consider measurement errors from the perspective of monocular ranging models or camera parameters, but often neglect parameter deviations caused by equipment installation, such as deviations in elevation and camera pitch angles caused by non-perpendicular rods for installing cameras to the horizontal plane, and thus the accuracy of measurement is imaged. Therefore, aiming at the problem, the invention provides a spherical camera monocular ranging-oriented pitch angle correction method, which acquires the real pitch angle between the camera and the horizontal plane during monitoring, thereby reducing the influence of external factors such as installation on the ranging precision.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a flow chart of a pitch angle correction method for monocular ranging of a dome camera according to an embodiment of the present disclosure. From the program perspective, the execution subject of the flow may be a program or an application client that is installed on an application server.
As shown in fig. 1, the process may include the steps of:
step 101: and solving a relation between the measured distance of the target object and the pitch angle of the spherical camera based on the monocular distance measurement principle.
In one or more embodiments, step 101 may specifically include:
Constructing the relation between the true value and the calculated value of the reference point in the image by a gradient descent method, and solving the true pitch angle of the dome camera and the horizontal plane;
the small-hole imaging model based on monocular distance measurement simplifies the relation between the measured distance of a target object in an image and the pitch angle of a spherical camera.
Step 102: setting a first zoom multiple of the spherical camera, calibrating camera parameters of the spherical camera, and obtaining parameters of the camera.
In one or more embodiments, a Zhang Zhengyou camera calibration method may be used to calibrate camera parameters for the dome camera.
Step 103: taking a photo, selecting a reference point, and measuring the distance between the reference point and the dome camera and the pixel coordinates of the reference point in the photo.
In one or more embodiments, the drawing plane direct coordinates divide the photograph into 4 quadrants with the photograph center point as a base point, and at least three reference points are selected in each quadrant. The number of the reference points is not less than 12.
Step 104: and solving a pitch angle of the reference point relative to the first zoom multiple based on the relation, the distance between the reference point and the dome camera and the pixel coordinate of the reference point in the photo.
In one or more embodiments, the solving the pitch angle of the reference point relative to the first zoom multiple based on the relation, the distance between the reference point and the dome camera, and the pixel coordinates of the reference point in the photograph may specifically include:
and constructing an objective function by adopting a gradient descent method based on the relation, the distance between the reference point and the spherical camera and the pixel coordinates of the reference point in the photo, and deriving, wherein the angle value corresponding to the derivative 0 point is the pitch angle under the first zoom multiple.
In one or more embodiments, when the reference points are multiple, multiple pitch angles can be solved, and an optimal value is selected as the pitch angle of the dome camera under the first zoom multiple.
In one or more embodiments, the selecting the optimal value as the pitch angle of the dome camera under the first zoom multiple specifically includes:
calculating the average error of the distance between each reference point and the dome camera and the true value;
And selecting the pitch angle corresponding to the reference point with the minimum average error and the error value smaller than 5% as the pitch angle of the spherical camera under the first zoom multiple.
Optionally, the formula of the relation between the measured distance of the target object and the pitch angle of the dome camera is as follows:
Where h is the camera height, α is the camera pitch angle, (x 0,y0) is the focal point of the optical axis and the image plane, HF is the measured distance of the target object, f is the effective focal length of the camera, and (x, y) is the coordinates of the target object in the image plane coordinate system.
Optionally, the objective function is:
Where h is the camera height, f x is the normalized focal length on the u-axis of the pixel coordinate system, f y is the normalized focal length on the v-axis of the pixel coordinate system, Δs i is the range error value for monocular vision, oc is the pitch angle, (u i,vi) is the pixel coordinate of reference point i, (u 0,v0) is the pixel coordinate of the image center point, and S i is the actual distance from reference point i to the camera on the image.
Based on the method of fig. 1, the examples of the present specification also provide some specific implementations of the method, as described below.
According to the invention, the relation between the true value and the calculated value of the reference point in the image is constructed by a gradient descent method, and the true pitch angle of the dome camera and the horizontal plane is solved. Simplifying the relation between the measured distance of a target object in an image and the pitch angle of a spherical camera based on a small-hole imaging model of monocular distance measurement; setting a camera zoom multiple, and acquiring parameters of a camera by adopting a Zhang Zhengyou camera calibration method; taking a photo, selecting a reference point, measuring the distance between the reference point and a camera and the pixel coordinates of the reference point in the photo, constructing a gradient function of a true value and a calculated value by combining a measurement distance formula on the basis, and then carrying out derivation, wherein the derivative is an angle value corresponding to the 0 point, namely a pitch angle under a certain multiple of the solved ball machine; and (5) according to the multiples of the ball machine, repeating the steps to solve the pitch angles corresponding to all the multiples of the ball machine.
The specific operation is as follows:
1. solving the relation between the measured distance and the pitch angle based on the monocular ranging principle
In the monocular ranging model shown in fig. 2, F is a point on the ground plane, P is the projection of the ground point F on the Y w axis in the world coordinate system O w-XwYwZw, O c is the camera optical center, H is the foot of the camera optical center perpendicular to the ground point, H is the camera height, and oc is the pitch angle. A. B is the projection of P, F points on the image plane, and (x 0,y0) is the origin of the coordinate system of the image plane, and is generally taken as (0, 0). (x, y) is the coordinates of B in the image plane coordinate system.
From the monocular ranging model shown in fig. 2, it is possible to obtain:
AB=x-x0
According to the principle of similar triangle:
From the following components And (3) obtaining: /(I)
According to the principle formula, the relation formula of the measured distance HF is arranged as follows:
In the formula (1), h is the camera height, α is the camera pitch angle, x, y is the image coordinates, (x 0,y0) is the focal point of the optical axis and the image plane, and is generally taken as (0, 0) as the origin of the image plane coordinate system. The coordinates of the target point in the imaging plane coordinate system are expressed by the following formula, i.e., the pixel coordinates of the target object are converted into image coordinates:
(u i,vi) is the coordinates of the feature point in the pixel coordinate system, and d x,dy represents the physical dimensions of each pixel in the pixel coordinate system in the x-axis and y-axis directions; (u 0,v0) is the pixel coordinate of the origin of the imaging plane coordinate system in the pixel coordinate system.
The following steps are obtained:
equation (2) is the distance HF of the measured target object i as a function of pitch angle.
2. Setting the magnification (namely zoom multiple) of the camera, and measuring the height h of the camera under the condition that the zoom multiple is determined; shooting a checkerboard photo, and calibrating camera parameters by adopting a Zhang Zhengyou calibration method to obtain parameters such as a normalized focal length f x,fy of the camera on a pixel coordinate system u and a v axis, a pixel coordinate (u 0,v0) of the center of the image and the like.
3. Taking a photo, selecting a reference point in the photo, measuring, and acquiring the distance between the reference point and the camera and a pixel coordinate system of the reference point.
(1) Drawing a plane direct coordinate by taking a photo center point as a base point to divide the photo into 4 quadrants, selecting at least three reference points in each quadrant, and taking N reference points (N is more than or equal to 12) in the four quadrants;
(2) The distances s1, the i, si, sn of the N reference points were measured with a total station;
() Programming to obtain pixel coordinates (x 1,y1),......,(xi,yi),......,(xn,yn) of a photo reference point;
4. solving a pitch angle alpha i of the reference point i;
(1) Substituting the parameters solved in the steps 2 and 3 into the formula (2) and subtracting the reference point to obtain the formula (3)
In the formula (3), h, u i,vi,fx,fy,u0,v0,si are obtained in the steps 2 and 3, and are known. Δs i is the range error value of monocular vision, oc is the pitch angle, and, (u i,vi) is the pixel coordinate of the target i, (u 0,v0) is the pixel coordinate of the center point of the image, and S i is the actual distance of the target i from the camera on the image, i.e., the true value of HF.
Equation (3) is an objective function constructed based on the idea of the gradient descent method (GRADIENT DESCENT). On the basis of the formula (2), subtracting S i (the true value of the measured target object HF) and taking the absolute value to construct an objective function for solving the gradient decline of alpha. The formula (3) is an application scene for correcting the pitch angle of the monocular ranging by using the concept of gradient descent, and the combination of an abstract formula and a specific application scene of the monocular ranging is originally created according to the specific application scene.
The gradient descent method is one of iterative methods, and is commonly used to optimize an objective function, and the essence of the gradient descent method is to solve the maximum value along the gradient change direction. Such as for an optimization problem
Wherein f (x) is an objective function, which is a slightly convex function, and the minimum value of the objective function is solved by using a step degree, the iterative process of the gradient descent method can be described as follows:
where x k represents the argument value for the current position, x k+1 represents the argument for the next position to be solved, μ represents the iteration step, also called the learning rate, Representing a first order gradient of the current position. When the absolute value of the gradient of the objective function is smaller than a certain set threshold value, the iteration is stopped, and x k at the moment is the optimized result.
Iterative computation using the gradient descent method first requires the construction of an objective function, i.e., the relationship between dependent and independent variables, f (x k). Equation (3) is equation (5)But/>Only one abstract concept, while the formula (3) is specific, and has a specific application scene supported by a monocular ranging model, which is original by the inventor.
(2) And (3) deriving the formula (3), wherein the alpha i value corresponding to the derivative of 0 is the calculated pitch angle value, as shown in fig. 3.
5. And (3) respectively calculating the values of other reference points alpha in the photo according to the step (4), and obtaining the value alpha 1,......,αi,.....αn of each reference point.
6. An optimal alpha value is selected from the calculated alpha i to be used as the pitch angle of the camera under the multiple, and the selection method is as follows:
(1) Selecting alpha i and related parameters thereof, and respectively calculating the distance cs 1,cs2,......csi,......,csn of each reference point according to a formula 2;
(2) Calculating average errors between all reference point distances and a true value (measured value) under the angle value alpha i according to a formula (6);
(3) Repeating the step6 (2), calculating the average error between the calculated distance of the reference points of all alpha values and the true value, selecting the optimal value of alpha, and selecting the conditions:
1) The error value of each reference point is less than 5%
2) Under the condition of 1), the average error delta S is minimum
7. And (3) repeating the steps 2,3,4, 5 and 6 according to different magnification (namely zoom magnification) of the spherical camera, and calculating pitch angles under different zoom magnification.
Compared with the prior art, the invention has the following advantages:
1. solving the pitch angle of the spherical camera, and correcting the deviation of the pitch angle of the camera due to installation, other external factors and the like;
2. the error caused by equipment installation is corrected, and the accuracy of monocular ranging is ensured.
Based on the same thought, the embodiment of the specification also provides a device corresponding to the method. Fig. 4 is a schematic structural diagram of a pitch angle correction device for monocular ranging of a dome camera corresponding to fig. 1 according to an embodiment of the present disclosure. As shown in fig. 4, the apparatus may include:
The relational determination module 401 is configured to solve a relational expression between a measurement distance of the target object and a pitch angle of the dome camera based on a monocular ranging principle;
the zoom multiple setting module 402 is configured to set a first zoom multiple of the dome camera, perform camera parameter calibration on the dome camera, and obtain parameters of the camera;
the reference point selecting and distance measuring module 403 is configured to take a photo, select a reference point, and measure a distance between the reference point and the dome camera and a pixel coordinate of the reference point in the photo;
and the pitch angle solving module 404 is configured to solve a pitch angle of the reference point relative to the first zoom multiple based on the relation, the distance between the reference point and the dome camera, and the pixel coordinates of the reference point in the photograph.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the application are to be included in the scope of the claims of the present application.